select2.js 167 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577
  1. import {
  2. require_jquery
  3. } from "./chunk-DH55I632.js";
  4. import {
  5. __commonJS
  6. } from "./chunk-WFTEJBJX.js";
  7. // node_modules/select2/dist/js/select2.js
  8. var require_select2 = __commonJS({
  9. "node_modules/select2/dist/js/select2.js"(exports, module) {
  10. (function(factory) {
  11. if (typeof define === "function" && define.amd) {
  12. define(["jquery"], factory);
  13. } else if (typeof module === "object" && module.exports) {
  14. module.exports = function(root, jQuery2) {
  15. if (jQuery2 === void 0) {
  16. if (typeof window !== "undefined") {
  17. jQuery2 = require_jquery();
  18. } else {
  19. jQuery2 = require_jquery()(root);
  20. }
  21. }
  22. factory(jQuery2);
  23. return jQuery2;
  24. };
  25. } else {
  26. factory(jQuery);
  27. }
  28. })(function(jQuery2) {
  29. var S2 = function() {
  30. if (jQuery2 && jQuery2.fn && jQuery2.fn.select2 && jQuery2.fn.select2.amd) {
  31. var S22 = jQuery2.fn.select2.amd;
  32. }
  33. var S22;
  34. (function() {
  35. if (!S22 || !S22.requirejs) {
  36. if (!S22) {
  37. S22 = {};
  38. } else {
  39. require2 = S22;
  40. }
  41. var requirejs, require2, define2;
  42. (function(undef) {
  43. var main, req, makeMap, handlers, defined = {}, waiting = {}, config = {}, defining = {}, hasOwn = Object.prototype.hasOwnProperty, aps = [].slice, jsSuffixRegExp = /\.js$/;
  44. function hasProp(obj, prop) {
  45. return hasOwn.call(obj, prop);
  46. }
  47. function normalize(name, baseName) {
  48. var nameParts, nameSegment, mapValue, foundMap, lastIndex, foundI, foundStarMap, starI, i, j, part, normalizedBaseParts, baseParts = baseName && baseName.split("/"), map = config.map, starMap = map && map["*"] || {};
  49. if (name) {
  50. name = name.split("/");
  51. lastIndex = name.length - 1;
  52. if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
  53. name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, "");
  54. }
  55. if (name[0].charAt(0) === "." && baseParts) {
  56. normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
  57. name = normalizedBaseParts.concat(name);
  58. }
  59. for (i = 0; i < name.length; i++) {
  60. part = name[i];
  61. if (part === ".") {
  62. name.splice(i, 1);
  63. i -= 1;
  64. } else if (part === "..") {
  65. if (i === 0 || i === 1 && name[2] === ".." || name[i - 1] === "..") {
  66. continue;
  67. } else if (i > 0) {
  68. name.splice(i - 1, 2);
  69. i -= 2;
  70. }
  71. }
  72. }
  73. name = name.join("/");
  74. }
  75. if ((baseParts || starMap) && map) {
  76. nameParts = name.split("/");
  77. for (i = nameParts.length; i > 0; i -= 1) {
  78. nameSegment = nameParts.slice(0, i).join("/");
  79. if (baseParts) {
  80. for (j = baseParts.length; j > 0; j -= 1) {
  81. mapValue = map[baseParts.slice(0, j).join("/")];
  82. if (mapValue) {
  83. mapValue = mapValue[nameSegment];
  84. if (mapValue) {
  85. foundMap = mapValue;
  86. foundI = i;
  87. break;
  88. }
  89. }
  90. }
  91. }
  92. if (foundMap) {
  93. break;
  94. }
  95. if (!foundStarMap && starMap && starMap[nameSegment]) {
  96. foundStarMap = starMap[nameSegment];
  97. starI = i;
  98. }
  99. }
  100. if (!foundMap && foundStarMap) {
  101. foundMap = foundStarMap;
  102. foundI = starI;
  103. }
  104. if (foundMap) {
  105. nameParts.splice(0, foundI, foundMap);
  106. name = nameParts.join("/");
  107. }
  108. }
  109. return name;
  110. }
  111. function makeRequire(relName, forceSync) {
  112. return function() {
  113. var args = aps.call(arguments, 0);
  114. if (typeof args[0] !== "string" && args.length === 1) {
  115. args.push(null);
  116. }
  117. return req.apply(undef, args.concat([relName, forceSync]));
  118. };
  119. }
  120. function makeNormalize(relName) {
  121. return function(name) {
  122. return normalize(name, relName);
  123. };
  124. }
  125. function makeLoad(depName) {
  126. return function(value) {
  127. defined[depName] = value;
  128. };
  129. }
  130. function callDep(name) {
  131. if (hasProp(waiting, name)) {
  132. var args = waiting[name];
  133. delete waiting[name];
  134. defining[name] = true;
  135. main.apply(undef, args);
  136. }
  137. if (!hasProp(defined, name) && !hasProp(defining, name)) {
  138. throw new Error("No " + name);
  139. }
  140. return defined[name];
  141. }
  142. function splitPrefix(name) {
  143. var prefix, index = name ? name.indexOf("!") : -1;
  144. if (index > -1) {
  145. prefix = name.substring(0, index);
  146. name = name.substring(index + 1, name.length);
  147. }
  148. return [prefix, name];
  149. }
  150. function makeRelParts(relName) {
  151. return relName ? splitPrefix(relName) : [];
  152. }
  153. makeMap = function(name, relParts) {
  154. var plugin, parts = splitPrefix(name), prefix = parts[0], relResourceName = relParts[1];
  155. name = parts[1];
  156. if (prefix) {
  157. prefix = normalize(prefix, relResourceName);
  158. plugin = callDep(prefix);
  159. }
  160. if (prefix) {
  161. if (plugin && plugin.normalize) {
  162. name = plugin.normalize(name, makeNormalize(relResourceName));
  163. } else {
  164. name = normalize(name, relResourceName);
  165. }
  166. } else {
  167. name = normalize(name, relResourceName);
  168. parts = splitPrefix(name);
  169. prefix = parts[0];
  170. name = parts[1];
  171. if (prefix) {
  172. plugin = callDep(prefix);
  173. }
  174. }
  175. return {
  176. f: prefix ? prefix + "!" + name : name,
  177. //fullName
  178. n: name,
  179. pr: prefix,
  180. p: plugin
  181. };
  182. };
  183. function makeConfig(name) {
  184. return function() {
  185. return config && config.config && config.config[name] || {};
  186. };
  187. }
  188. handlers = {
  189. require: function(name) {
  190. return makeRequire(name);
  191. },
  192. exports: function(name) {
  193. var e = defined[name];
  194. if (typeof e !== "undefined") {
  195. return e;
  196. } else {
  197. return defined[name] = {};
  198. }
  199. },
  200. module: function(name) {
  201. return {
  202. id: name,
  203. uri: "",
  204. exports: defined[name],
  205. config: makeConfig(name)
  206. };
  207. }
  208. };
  209. main = function(name, deps, callback, relName) {
  210. var cjsModule, depName, ret, map, i, relParts, args = [], callbackType = typeof callback, usingExports;
  211. relName = relName || name;
  212. relParts = makeRelParts(relName);
  213. if (callbackType === "undefined" || callbackType === "function") {
  214. deps = !deps.length && callback.length ? ["require", "exports", "module"] : deps;
  215. for (i = 0; i < deps.length; i += 1) {
  216. map = makeMap(deps[i], relParts);
  217. depName = map.f;
  218. if (depName === "require") {
  219. args[i] = handlers.require(name);
  220. } else if (depName === "exports") {
  221. args[i] = handlers.exports(name);
  222. usingExports = true;
  223. } else if (depName === "module") {
  224. cjsModule = args[i] = handlers.module(name);
  225. } else if (hasProp(defined, depName) || hasProp(waiting, depName) || hasProp(defining, depName)) {
  226. args[i] = callDep(depName);
  227. } else if (map.p) {
  228. map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
  229. args[i] = defined[depName];
  230. } else {
  231. throw new Error(name + " missing " + depName);
  232. }
  233. }
  234. ret = callback ? callback.apply(defined[name], args) : void 0;
  235. if (name) {
  236. if (cjsModule && cjsModule.exports !== undef && cjsModule.exports !== defined[name]) {
  237. defined[name] = cjsModule.exports;
  238. } else if (ret !== undef || !usingExports) {
  239. defined[name] = ret;
  240. }
  241. }
  242. } else if (name) {
  243. defined[name] = callback;
  244. }
  245. };
  246. requirejs = require2 = req = function(deps, callback, relName, forceSync, alt) {
  247. if (typeof deps === "string") {
  248. if (handlers[deps]) {
  249. return handlers[deps](callback);
  250. }
  251. return callDep(makeMap(deps, makeRelParts(callback)).f);
  252. } else if (!deps.splice) {
  253. config = deps;
  254. if (config.deps) {
  255. req(config.deps, config.callback);
  256. }
  257. if (!callback) {
  258. return;
  259. }
  260. if (callback.splice) {
  261. deps = callback;
  262. callback = relName;
  263. relName = null;
  264. } else {
  265. deps = undef;
  266. }
  267. }
  268. callback = callback || function() {
  269. };
  270. if (typeof relName === "function") {
  271. relName = forceSync;
  272. forceSync = alt;
  273. }
  274. if (forceSync) {
  275. main(undef, deps, callback, relName);
  276. } else {
  277. setTimeout(function() {
  278. main(undef, deps, callback, relName);
  279. }, 4);
  280. }
  281. return req;
  282. };
  283. req.config = function(cfg) {
  284. return req(cfg);
  285. };
  286. requirejs._defined = defined;
  287. define2 = function(name, deps, callback) {
  288. if (typeof name !== "string") {
  289. throw new Error("See almond README: incorrect module build, no module name");
  290. }
  291. if (!deps.splice) {
  292. callback = deps;
  293. deps = [];
  294. }
  295. if (!hasProp(defined, name) && !hasProp(waiting, name)) {
  296. waiting[name] = [name, deps, callback];
  297. }
  298. };
  299. define2.amd = {
  300. jQuery: true
  301. };
  302. })();
  303. S22.requirejs = requirejs;
  304. S22.require = require2;
  305. S22.define = define2;
  306. }
  307. })();
  308. S22.define("almond", function() {
  309. });
  310. S22.define("jquery", [], function() {
  311. var _$ = jQuery2 || $;
  312. if (_$ == null && console && console.error) {
  313. console.error(
  314. "Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page."
  315. );
  316. }
  317. return _$;
  318. });
  319. S22.define("select2/utils", [
  320. "jquery"
  321. ], function($2) {
  322. var Utils = {};
  323. Utils.Extend = function(ChildClass, SuperClass) {
  324. var __hasProp = {}.hasOwnProperty;
  325. function BaseConstructor() {
  326. this.constructor = ChildClass;
  327. }
  328. for (var key in SuperClass) {
  329. if (__hasProp.call(SuperClass, key)) {
  330. ChildClass[key] = SuperClass[key];
  331. }
  332. }
  333. BaseConstructor.prototype = SuperClass.prototype;
  334. ChildClass.prototype = new BaseConstructor();
  335. ChildClass.__super__ = SuperClass.prototype;
  336. return ChildClass;
  337. };
  338. function getMethods(theClass) {
  339. var proto = theClass.prototype;
  340. var methods = [];
  341. for (var methodName in proto) {
  342. var m = proto[methodName];
  343. if (typeof m !== "function") {
  344. continue;
  345. }
  346. if (methodName === "constructor") {
  347. continue;
  348. }
  349. methods.push(methodName);
  350. }
  351. return methods;
  352. }
  353. Utils.Decorate = function(SuperClass, DecoratorClass) {
  354. var decoratedMethods = getMethods(DecoratorClass);
  355. var superMethods = getMethods(SuperClass);
  356. function DecoratedClass() {
  357. var unshift = Array.prototype.unshift;
  358. var argCount = DecoratorClass.prototype.constructor.length;
  359. var calledConstructor = SuperClass.prototype.constructor;
  360. if (argCount > 0) {
  361. unshift.call(arguments, SuperClass.prototype.constructor);
  362. calledConstructor = DecoratorClass.prototype.constructor;
  363. }
  364. calledConstructor.apply(this, arguments);
  365. }
  366. DecoratorClass.displayName = SuperClass.displayName;
  367. function ctr() {
  368. this.constructor = DecoratedClass;
  369. }
  370. DecoratedClass.prototype = new ctr();
  371. for (var m = 0; m < superMethods.length; m++) {
  372. var superMethod = superMethods[m];
  373. DecoratedClass.prototype[superMethod] = SuperClass.prototype[superMethod];
  374. }
  375. var calledMethod = function(methodName) {
  376. var originalMethod = function() {
  377. };
  378. if (methodName in DecoratedClass.prototype) {
  379. originalMethod = DecoratedClass.prototype[methodName];
  380. }
  381. var decoratedMethod2 = DecoratorClass.prototype[methodName];
  382. return function() {
  383. var unshift = Array.prototype.unshift;
  384. unshift.call(arguments, originalMethod);
  385. return decoratedMethod2.apply(this, arguments);
  386. };
  387. };
  388. for (var d = 0; d < decoratedMethods.length; d++) {
  389. var decoratedMethod = decoratedMethods[d];
  390. DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
  391. }
  392. return DecoratedClass;
  393. };
  394. var Observable = function() {
  395. this.listeners = {};
  396. };
  397. Observable.prototype.on = function(event, callback) {
  398. this.listeners = this.listeners || {};
  399. if (event in this.listeners) {
  400. this.listeners[event].push(callback);
  401. } else {
  402. this.listeners[event] = [callback];
  403. }
  404. };
  405. Observable.prototype.trigger = function(event) {
  406. var slice = Array.prototype.slice;
  407. var params = slice.call(arguments, 1);
  408. this.listeners = this.listeners || {};
  409. if (params == null) {
  410. params = [];
  411. }
  412. if (params.length === 0) {
  413. params.push({});
  414. }
  415. params[0]._type = event;
  416. if (event in this.listeners) {
  417. this.invoke(this.listeners[event], slice.call(arguments, 1));
  418. }
  419. if ("*" in this.listeners) {
  420. this.invoke(this.listeners["*"], arguments);
  421. }
  422. };
  423. Observable.prototype.invoke = function(listeners, params) {
  424. for (var i = 0, len = listeners.length; i < len; i++) {
  425. listeners[i].apply(this, params);
  426. }
  427. };
  428. Utils.Observable = Observable;
  429. Utils.generateChars = function(length) {
  430. var chars = "";
  431. for (var i = 0; i < length; i++) {
  432. var randomChar = Math.floor(Math.random() * 36);
  433. chars += randomChar.toString(36);
  434. }
  435. return chars;
  436. };
  437. Utils.bind = function(func, context) {
  438. return function() {
  439. func.apply(context, arguments);
  440. };
  441. };
  442. Utils._convertData = function(data) {
  443. for (var originalKey in data) {
  444. var keys = originalKey.split("-");
  445. var dataLevel = data;
  446. if (keys.length === 1) {
  447. continue;
  448. }
  449. for (var k = 0; k < keys.length; k++) {
  450. var key = keys[k];
  451. key = key.substring(0, 1).toLowerCase() + key.substring(1);
  452. if (!(key in dataLevel)) {
  453. dataLevel[key] = {};
  454. }
  455. if (k == keys.length - 1) {
  456. dataLevel[key] = data[originalKey];
  457. }
  458. dataLevel = dataLevel[key];
  459. }
  460. delete data[originalKey];
  461. }
  462. return data;
  463. };
  464. Utils.hasScroll = function(index, el) {
  465. var $el = $2(el);
  466. var overflowX = el.style.overflowX;
  467. var overflowY = el.style.overflowY;
  468. if (overflowX === overflowY && (overflowY === "hidden" || overflowY === "visible")) {
  469. return false;
  470. }
  471. if (overflowX === "scroll" || overflowY === "scroll") {
  472. return true;
  473. }
  474. return $el.innerHeight() < el.scrollHeight || $el.innerWidth() < el.scrollWidth;
  475. };
  476. Utils.escapeMarkup = function(markup) {
  477. var replaceMap = {
  478. "\\": "&#92;",
  479. "&": "&amp;",
  480. "<": "&lt;",
  481. ">": "&gt;",
  482. '"': "&quot;",
  483. "'": "&#39;",
  484. "/": "&#47;"
  485. };
  486. if (typeof markup !== "string") {
  487. return markup;
  488. }
  489. return String(markup).replace(/[&<>"'\/\\]/g, function(match) {
  490. return replaceMap[match];
  491. });
  492. };
  493. Utils.__cache = {};
  494. var id = 0;
  495. Utils.GetUniqueElementId = function(element) {
  496. var select2Id = element.getAttribute("data-select2-id");
  497. if (select2Id != null) {
  498. return select2Id;
  499. }
  500. if (element.id) {
  501. select2Id = "select2-data-" + element.id;
  502. } else {
  503. select2Id = "select2-data-" + (++id).toString() + "-" + Utils.generateChars(4);
  504. }
  505. element.setAttribute("data-select2-id", select2Id);
  506. return select2Id;
  507. };
  508. Utils.StoreData = function(element, name, value) {
  509. var id2 = Utils.GetUniqueElementId(element);
  510. if (!Utils.__cache[id2]) {
  511. Utils.__cache[id2] = {};
  512. }
  513. Utils.__cache[id2][name] = value;
  514. };
  515. Utils.GetData = function(element, name) {
  516. var id2 = Utils.GetUniqueElementId(element);
  517. if (name) {
  518. if (Utils.__cache[id2]) {
  519. if (Utils.__cache[id2][name] != null) {
  520. return Utils.__cache[id2][name];
  521. }
  522. return $2(element).data(name);
  523. }
  524. return $2(element).data(name);
  525. } else {
  526. return Utils.__cache[id2];
  527. }
  528. };
  529. Utils.RemoveData = function(element) {
  530. var id2 = Utils.GetUniqueElementId(element);
  531. if (Utils.__cache[id2] != null) {
  532. delete Utils.__cache[id2];
  533. }
  534. element.removeAttribute("data-select2-id");
  535. };
  536. Utils.copyNonInternalCssClasses = function(dest, src) {
  537. var classes;
  538. var destinationClasses = dest.getAttribute("class").trim().split(/\s+/);
  539. destinationClasses = destinationClasses.filter(function(clazz) {
  540. return clazz.indexOf("select2-") === 0;
  541. });
  542. var sourceClasses = src.getAttribute("class").trim().split(/\s+/);
  543. sourceClasses = sourceClasses.filter(function(clazz) {
  544. return clazz.indexOf("select2-") !== 0;
  545. });
  546. var replacements = destinationClasses.concat(sourceClasses);
  547. dest.setAttribute("class", replacements.join(" "));
  548. };
  549. return Utils;
  550. });
  551. S22.define("select2/results", [
  552. "jquery",
  553. "./utils"
  554. ], function($2, Utils) {
  555. function Results($element, options, dataAdapter) {
  556. this.$element = $element;
  557. this.data = dataAdapter;
  558. this.options = options;
  559. Results.__super__.constructor.call(this);
  560. }
  561. Utils.Extend(Results, Utils.Observable);
  562. Results.prototype.render = function() {
  563. var $results = $2(
  564. '<ul class="select2-results__options" role="listbox"></ul>'
  565. );
  566. if (this.options.get("multiple")) {
  567. $results.attr("aria-multiselectable", "true");
  568. }
  569. this.$results = $results;
  570. return $results;
  571. };
  572. Results.prototype.clear = function() {
  573. this.$results.empty();
  574. };
  575. Results.prototype.displayMessage = function(params) {
  576. var escapeMarkup = this.options.get("escapeMarkup");
  577. this.clear();
  578. this.hideLoading();
  579. var $message = $2(
  580. '<li role="alert" aria-live="assertive" class="select2-results__option"></li>'
  581. );
  582. var message = this.options.get("translations").get(params.message);
  583. $message.append(
  584. escapeMarkup(
  585. message(params.args)
  586. )
  587. );
  588. $message[0].className += " select2-results__message";
  589. this.$results.append($message);
  590. };
  591. Results.prototype.hideMessages = function() {
  592. this.$results.find(".select2-results__message").remove();
  593. };
  594. Results.prototype.append = function(data) {
  595. this.hideLoading();
  596. var $options = [];
  597. if (data.results == null || data.results.length === 0) {
  598. if (this.$results.children().length === 0) {
  599. this.trigger("results:message", {
  600. message: "noResults"
  601. });
  602. }
  603. return;
  604. }
  605. data.results = this.sort(data.results);
  606. for (var d = 0; d < data.results.length; d++) {
  607. var item = data.results[d];
  608. var $option = this.option(item);
  609. $options.push($option);
  610. }
  611. this.$results.append($options);
  612. };
  613. Results.prototype.position = function($results, $dropdown) {
  614. var $resultsContainer = $dropdown.find(".select2-results");
  615. $resultsContainer.append($results);
  616. };
  617. Results.prototype.sort = function(data) {
  618. var sorter = this.options.get("sorter");
  619. return sorter(data);
  620. };
  621. Results.prototype.highlightFirstItem = function() {
  622. var $options = this.$results.find(".select2-results__option--selectable");
  623. var $selected = $options.filter(".select2-results__option--selected");
  624. if ($selected.length > 0) {
  625. $selected.first().trigger("mouseenter");
  626. } else {
  627. $options.first().trigger("mouseenter");
  628. }
  629. this.ensureHighlightVisible();
  630. };
  631. Results.prototype.setClasses = function() {
  632. var self = this;
  633. this.data.current(function(selected) {
  634. var selectedIds = selected.map(function(s) {
  635. return s.id.toString();
  636. });
  637. var $options = self.$results.find(".select2-results__option--selectable");
  638. $options.each(function() {
  639. var $option = $2(this);
  640. var item = Utils.GetData(this, "data");
  641. var id = "" + item.id;
  642. if (item.element != null && item.element.selected || item.element == null && selectedIds.indexOf(id) > -1) {
  643. this.classList.add("select2-results__option--selected");
  644. $option.attr("aria-selected", "true");
  645. } else {
  646. this.classList.remove("select2-results__option--selected");
  647. $option.attr("aria-selected", "false");
  648. }
  649. });
  650. });
  651. };
  652. Results.prototype.showLoading = function(params) {
  653. this.hideLoading();
  654. var loadingMore = this.options.get("translations").get("searching");
  655. var loading = {
  656. disabled: true,
  657. loading: true,
  658. text: loadingMore(params)
  659. };
  660. var $loading = this.option(loading);
  661. $loading.className += " loading-results";
  662. this.$results.prepend($loading);
  663. };
  664. Results.prototype.hideLoading = function() {
  665. this.$results.find(".loading-results").remove();
  666. };
  667. Results.prototype.option = function(data) {
  668. var option = document.createElement("li");
  669. option.classList.add("select2-results__option");
  670. option.classList.add("select2-results__option--selectable");
  671. var attrs = {
  672. "role": "option"
  673. };
  674. var matches = window.Element.prototype.matches || window.Element.prototype.msMatchesSelector || window.Element.prototype.webkitMatchesSelector;
  675. if (data.element != null && matches.call(data.element, ":disabled") || data.element == null && data.disabled) {
  676. attrs["aria-disabled"] = "true";
  677. option.classList.remove("select2-results__option--selectable");
  678. option.classList.add("select2-results__option--disabled");
  679. }
  680. if (data.id == null) {
  681. option.classList.remove("select2-results__option--selectable");
  682. }
  683. if (data._resultId != null) {
  684. option.id = data._resultId;
  685. }
  686. if (data.title) {
  687. option.title = data.title;
  688. }
  689. if (data.children) {
  690. attrs.role = "group";
  691. attrs["aria-label"] = data.text;
  692. option.classList.remove("select2-results__option--selectable");
  693. option.classList.add("select2-results__option--group");
  694. }
  695. for (var attr in attrs) {
  696. var val = attrs[attr];
  697. option.setAttribute(attr, val);
  698. }
  699. if (data.children) {
  700. var $option = $2(option);
  701. var label = document.createElement("strong");
  702. label.className = "select2-results__group";
  703. this.template(data, label);
  704. var $children = [];
  705. for (var c = 0; c < data.children.length; c++) {
  706. var child = data.children[c];
  707. var $child = this.option(child);
  708. $children.push($child);
  709. }
  710. var $childrenContainer = $2("<ul></ul>", {
  711. "class": "select2-results__options select2-results__options--nested",
  712. "role": "none"
  713. });
  714. $childrenContainer.append($children);
  715. $option.append(label);
  716. $option.append($childrenContainer);
  717. } else {
  718. this.template(data, option);
  719. }
  720. Utils.StoreData(option, "data", data);
  721. return option;
  722. };
  723. Results.prototype.bind = function(container, $container) {
  724. var self = this;
  725. var id = container.id + "-results";
  726. this.$results.attr("id", id);
  727. container.on("results:all", function(params) {
  728. self.clear();
  729. self.append(params.data);
  730. if (container.isOpen()) {
  731. self.setClasses();
  732. self.highlightFirstItem();
  733. }
  734. });
  735. container.on("results:append", function(params) {
  736. self.append(params.data);
  737. if (container.isOpen()) {
  738. self.setClasses();
  739. }
  740. });
  741. container.on("query", function(params) {
  742. self.hideMessages();
  743. self.showLoading(params);
  744. });
  745. container.on("select", function() {
  746. if (!container.isOpen()) {
  747. return;
  748. }
  749. self.setClasses();
  750. if (self.options.get("scrollAfterSelect")) {
  751. self.highlightFirstItem();
  752. }
  753. });
  754. container.on("unselect", function() {
  755. if (!container.isOpen()) {
  756. return;
  757. }
  758. self.setClasses();
  759. if (self.options.get("scrollAfterSelect")) {
  760. self.highlightFirstItem();
  761. }
  762. });
  763. container.on("open", function() {
  764. self.$results.attr("aria-expanded", "true");
  765. self.$results.attr("aria-hidden", "false");
  766. self.setClasses();
  767. self.ensureHighlightVisible();
  768. });
  769. container.on("close", function() {
  770. self.$results.attr("aria-expanded", "false");
  771. self.$results.attr("aria-hidden", "true");
  772. self.$results.removeAttr("aria-activedescendant");
  773. });
  774. container.on("results:toggle", function() {
  775. var $highlighted = self.getHighlightedResults();
  776. if ($highlighted.length === 0) {
  777. return;
  778. }
  779. $highlighted.trigger("mouseup");
  780. });
  781. container.on("results:select", function() {
  782. var $highlighted = self.getHighlightedResults();
  783. if ($highlighted.length === 0) {
  784. return;
  785. }
  786. var data = Utils.GetData($highlighted[0], "data");
  787. if ($highlighted.hasClass("select2-results__option--selected")) {
  788. self.trigger("close", {});
  789. } else {
  790. self.trigger("select", {
  791. data
  792. });
  793. }
  794. });
  795. container.on("results:previous", function() {
  796. var $highlighted = self.getHighlightedResults();
  797. var $options = self.$results.find(".select2-results__option--selectable");
  798. var currentIndex = $options.index($highlighted);
  799. if (currentIndex <= 0) {
  800. return;
  801. }
  802. var nextIndex = currentIndex - 1;
  803. if ($highlighted.length === 0) {
  804. nextIndex = 0;
  805. }
  806. var $next = $options.eq(nextIndex);
  807. $next.trigger("mouseenter");
  808. var currentOffset = self.$results.offset().top;
  809. var nextTop = $next.offset().top;
  810. var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset);
  811. if (nextIndex === 0) {
  812. self.$results.scrollTop(0);
  813. } else if (nextTop - currentOffset < 0) {
  814. self.$results.scrollTop(nextOffset);
  815. }
  816. });
  817. container.on("results:next", function() {
  818. var $highlighted = self.getHighlightedResults();
  819. var $options = self.$results.find(".select2-results__option--selectable");
  820. var currentIndex = $options.index($highlighted);
  821. var nextIndex = currentIndex + 1;
  822. if (nextIndex >= $options.length) {
  823. return;
  824. }
  825. var $next = $options.eq(nextIndex);
  826. $next.trigger("mouseenter");
  827. var currentOffset = self.$results.offset().top + self.$results.outerHeight(false);
  828. var nextBottom = $next.offset().top + $next.outerHeight(false);
  829. var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset;
  830. if (nextIndex === 0) {
  831. self.$results.scrollTop(0);
  832. } else if (nextBottom > currentOffset) {
  833. self.$results.scrollTop(nextOffset);
  834. }
  835. });
  836. container.on("results:focus", function(params) {
  837. params.element[0].classList.add("select2-results__option--highlighted");
  838. params.element[0].setAttribute("aria-selected", "true");
  839. });
  840. container.on("results:message", function(params) {
  841. self.displayMessage(params);
  842. });
  843. if ($2.fn.mousewheel) {
  844. this.$results.on("mousewheel", function(e) {
  845. var top = self.$results.scrollTop();
  846. var bottom = self.$results.get(0).scrollHeight - top + e.deltaY;
  847. var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
  848. var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();
  849. if (isAtTop) {
  850. self.$results.scrollTop(0);
  851. e.preventDefault();
  852. e.stopPropagation();
  853. } else if (isAtBottom) {
  854. self.$results.scrollTop(
  855. self.$results.get(0).scrollHeight - self.$results.height()
  856. );
  857. e.preventDefault();
  858. e.stopPropagation();
  859. }
  860. });
  861. }
  862. this.$results.on(
  863. "mouseup",
  864. ".select2-results__option--selectable",
  865. function(evt) {
  866. var $this = $2(this);
  867. var data = Utils.GetData(this, "data");
  868. if ($this.hasClass("select2-results__option--selected")) {
  869. if (self.options.get("multiple")) {
  870. self.trigger("unselect", {
  871. originalEvent: evt,
  872. data
  873. });
  874. } else {
  875. self.trigger("close", {});
  876. }
  877. return;
  878. }
  879. self.trigger("select", {
  880. originalEvent: evt,
  881. data
  882. });
  883. }
  884. );
  885. this.$results.on(
  886. "mouseenter",
  887. ".select2-results__option--selectable",
  888. function(evt) {
  889. var data = Utils.GetData(this, "data");
  890. self.getHighlightedResults().removeClass("select2-results__option--highlighted").attr("aria-selected", "false");
  891. self.trigger("results:focus", {
  892. data,
  893. element: $2(this)
  894. });
  895. }
  896. );
  897. };
  898. Results.prototype.getHighlightedResults = function() {
  899. var $highlighted = this.$results.find(".select2-results__option--highlighted");
  900. return $highlighted;
  901. };
  902. Results.prototype.destroy = function() {
  903. this.$results.remove();
  904. };
  905. Results.prototype.ensureHighlightVisible = function() {
  906. var $highlighted = this.getHighlightedResults();
  907. if ($highlighted.length === 0) {
  908. return;
  909. }
  910. var $options = this.$results.find(".select2-results__option--selectable");
  911. var currentIndex = $options.index($highlighted);
  912. var currentOffset = this.$results.offset().top;
  913. var nextTop = $highlighted.offset().top;
  914. var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset);
  915. var offsetDelta = nextTop - currentOffset;
  916. nextOffset -= $highlighted.outerHeight(false) * 2;
  917. if (currentIndex <= 2) {
  918. this.$results.scrollTop(0);
  919. } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) {
  920. this.$results.scrollTop(nextOffset);
  921. }
  922. };
  923. Results.prototype.template = function(result, container) {
  924. var template = this.options.get("templateResult");
  925. var escapeMarkup = this.options.get("escapeMarkup");
  926. var content = template(result, container);
  927. if (content == null) {
  928. container.style.display = "none";
  929. } else if (typeof content === "string") {
  930. container.innerHTML = escapeMarkup(content);
  931. } else {
  932. $2(container).append(content);
  933. }
  934. };
  935. return Results;
  936. });
  937. S22.define("select2/keys", [], function() {
  938. var KEYS = {
  939. BACKSPACE: 8,
  940. TAB: 9,
  941. ENTER: 13,
  942. SHIFT: 16,
  943. CTRL: 17,
  944. ALT: 18,
  945. ESC: 27,
  946. SPACE: 32,
  947. PAGE_UP: 33,
  948. PAGE_DOWN: 34,
  949. END: 35,
  950. HOME: 36,
  951. LEFT: 37,
  952. UP: 38,
  953. RIGHT: 39,
  954. DOWN: 40,
  955. DELETE: 46
  956. };
  957. return KEYS;
  958. });
  959. S22.define("select2/selection/base", [
  960. "jquery",
  961. "../utils",
  962. "../keys"
  963. ], function($2, Utils, KEYS) {
  964. function BaseSelection($element, options) {
  965. this.$element = $element;
  966. this.options = options;
  967. BaseSelection.__super__.constructor.call(this);
  968. }
  969. Utils.Extend(BaseSelection, Utils.Observable);
  970. BaseSelection.prototype.render = function() {
  971. var $selection = $2(
  972. '<span class="select2-selection" role="combobox" aria-haspopup="true" aria-expanded="false"></span>'
  973. );
  974. this._tabindex = 0;
  975. if (Utils.GetData(this.$element[0], "old-tabindex") != null) {
  976. this._tabindex = Utils.GetData(this.$element[0], "old-tabindex");
  977. } else if (this.$element.attr("tabindex") != null) {
  978. this._tabindex = this.$element.attr("tabindex");
  979. }
  980. $selection.attr("title", this.$element.attr("title"));
  981. $selection.attr("tabindex", this._tabindex);
  982. $selection.attr("aria-disabled", "false");
  983. this.$selection = $selection;
  984. return $selection;
  985. };
  986. BaseSelection.prototype.bind = function(container, $container) {
  987. var self = this;
  988. var resultsId = container.id + "-results";
  989. this.container = container;
  990. this.$selection.on("focus", function(evt) {
  991. self.trigger("focus", evt);
  992. });
  993. this.$selection.on("blur", function(evt) {
  994. self._handleBlur(evt);
  995. });
  996. this.$selection.on("keydown", function(evt) {
  997. self.trigger("keypress", evt);
  998. if (evt.which === KEYS.SPACE) {
  999. evt.preventDefault();
  1000. }
  1001. });
  1002. container.on("results:focus", function(params) {
  1003. self.$selection.attr("aria-activedescendant", params.data._resultId);
  1004. });
  1005. container.on("selection:update", function(params) {
  1006. self.update(params.data);
  1007. });
  1008. container.on("open", function() {
  1009. self.$selection.attr("aria-expanded", "true");
  1010. self.$selection.attr("aria-owns", resultsId);
  1011. self._attachCloseHandler(container);
  1012. });
  1013. container.on("close", function() {
  1014. self.$selection.attr("aria-expanded", "false");
  1015. self.$selection.removeAttr("aria-activedescendant");
  1016. self.$selection.removeAttr("aria-owns");
  1017. self.$selection.trigger("focus");
  1018. self._detachCloseHandler(container);
  1019. });
  1020. container.on("enable", function() {
  1021. self.$selection.attr("tabindex", self._tabindex);
  1022. self.$selection.attr("aria-disabled", "false");
  1023. });
  1024. container.on("disable", function() {
  1025. self.$selection.attr("tabindex", "-1");
  1026. self.$selection.attr("aria-disabled", "true");
  1027. });
  1028. };
  1029. BaseSelection.prototype._handleBlur = function(evt) {
  1030. var self = this;
  1031. window.setTimeout(function() {
  1032. if (document.activeElement == self.$selection[0] || $2.contains(self.$selection[0], document.activeElement)) {
  1033. return;
  1034. }
  1035. self.trigger("blur", evt);
  1036. }, 1);
  1037. };
  1038. BaseSelection.prototype._attachCloseHandler = function(container) {
  1039. $2(document.body).on("mousedown.select2." + container.id, function(e) {
  1040. var $target = $2(e.target);
  1041. var $select = $target.closest(".select2");
  1042. var $all = $2(".select2.select2-container--open");
  1043. $all.each(function() {
  1044. if (this == $select[0]) {
  1045. return;
  1046. }
  1047. var $element = Utils.GetData(this, "element");
  1048. $element.select2("close");
  1049. });
  1050. });
  1051. };
  1052. BaseSelection.prototype._detachCloseHandler = function(container) {
  1053. $2(document.body).off("mousedown.select2." + container.id);
  1054. };
  1055. BaseSelection.prototype.position = function($selection, $container) {
  1056. var $selectionContainer = $container.find(".selection");
  1057. $selectionContainer.append($selection);
  1058. };
  1059. BaseSelection.prototype.destroy = function() {
  1060. this._detachCloseHandler(this.container);
  1061. };
  1062. BaseSelection.prototype.update = function(data) {
  1063. throw new Error("The `update` method must be defined in child classes.");
  1064. };
  1065. BaseSelection.prototype.isEnabled = function() {
  1066. return !this.isDisabled();
  1067. };
  1068. BaseSelection.prototype.isDisabled = function() {
  1069. return this.options.get("disabled");
  1070. };
  1071. return BaseSelection;
  1072. });
  1073. S22.define("select2/selection/single", [
  1074. "jquery",
  1075. "./base",
  1076. "../utils",
  1077. "../keys"
  1078. ], function($2, BaseSelection, Utils, KEYS) {
  1079. function SingleSelection() {
  1080. SingleSelection.__super__.constructor.apply(this, arguments);
  1081. }
  1082. Utils.Extend(SingleSelection, BaseSelection);
  1083. SingleSelection.prototype.render = function() {
  1084. var $selection = SingleSelection.__super__.render.call(this);
  1085. $selection[0].classList.add("select2-selection--single");
  1086. $selection.html(
  1087. '<span class="select2-selection__rendered"></span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span>'
  1088. );
  1089. return $selection;
  1090. };
  1091. SingleSelection.prototype.bind = function(container, $container) {
  1092. var self = this;
  1093. SingleSelection.__super__.bind.apply(this, arguments);
  1094. var id = container.id + "-container";
  1095. this.$selection.find(".select2-selection__rendered").attr("id", id).attr("role", "textbox").attr("aria-readonly", "true");
  1096. this.$selection.attr("aria-labelledby", id);
  1097. this.$selection.attr("aria-controls", id);
  1098. this.$selection.on("mousedown", function(evt) {
  1099. if (evt.which !== 1) {
  1100. return;
  1101. }
  1102. self.trigger("toggle", {
  1103. originalEvent: evt
  1104. });
  1105. });
  1106. this.$selection.on("focus", function(evt) {
  1107. });
  1108. this.$selection.on("blur", function(evt) {
  1109. });
  1110. container.on("focus", function(evt) {
  1111. if (!container.isOpen()) {
  1112. self.$selection.trigger("focus");
  1113. }
  1114. });
  1115. };
  1116. SingleSelection.prototype.clear = function() {
  1117. var $rendered = this.$selection.find(".select2-selection__rendered");
  1118. $rendered.empty();
  1119. $rendered.removeAttr("title");
  1120. };
  1121. SingleSelection.prototype.display = function(data, container) {
  1122. var template = this.options.get("templateSelection");
  1123. var escapeMarkup = this.options.get("escapeMarkup");
  1124. return escapeMarkup(template(data, container));
  1125. };
  1126. SingleSelection.prototype.selectionContainer = function() {
  1127. return $2("<span></span>");
  1128. };
  1129. SingleSelection.prototype.update = function(data) {
  1130. if (data.length === 0) {
  1131. this.clear();
  1132. return;
  1133. }
  1134. var selection = data[0];
  1135. var $rendered = this.$selection.find(".select2-selection__rendered");
  1136. var formatted = this.display(selection, $rendered);
  1137. $rendered.empty().append(formatted);
  1138. var title = selection.title || selection.text;
  1139. if (title) {
  1140. $rendered.attr("title", title);
  1141. } else {
  1142. $rendered.removeAttr("title");
  1143. }
  1144. };
  1145. return SingleSelection;
  1146. });
  1147. S22.define("select2/selection/multiple", [
  1148. "jquery",
  1149. "./base",
  1150. "../utils"
  1151. ], function($2, BaseSelection, Utils) {
  1152. function MultipleSelection($element, options) {
  1153. MultipleSelection.__super__.constructor.apply(this, arguments);
  1154. }
  1155. Utils.Extend(MultipleSelection, BaseSelection);
  1156. MultipleSelection.prototype.render = function() {
  1157. var $selection = MultipleSelection.__super__.render.call(this);
  1158. $selection[0].classList.add("select2-selection--multiple");
  1159. $selection.html(
  1160. '<ul class="select2-selection__rendered"></ul>'
  1161. );
  1162. return $selection;
  1163. };
  1164. MultipleSelection.prototype.bind = function(container, $container) {
  1165. var self = this;
  1166. MultipleSelection.__super__.bind.apply(this, arguments);
  1167. var id = container.id + "-container";
  1168. this.$selection.find(".select2-selection__rendered").attr("id", id);
  1169. this.$selection.on("click", function(evt) {
  1170. self.trigger("toggle", {
  1171. originalEvent: evt
  1172. });
  1173. });
  1174. this.$selection.on(
  1175. "click",
  1176. ".select2-selection__choice__remove",
  1177. function(evt) {
  1178. if (self.isDisabled()) {
  1179. return;
  1180. }
  1181. var $remove = $2(this);
  1182. var $selection = $remove.parent();
  1183. var data = Utils.GetData($selection[0], "data");
  1184. self.trigger("unselect", {
  1185. originalEvent: evt,
  1186. data
  1187. });
  1188. }
  1189. );
  1190. this.$selection.on(
  1191. "keydown",
  1192. ".select2-selection__choice__remove",
  1193. function(evt) {
  1194. if (self.isDisabled()) {
  1195. return;
  1196. }
  1197. evt.stopPropagation();
  1198. }
  1199. );
  1200. };
  1201. MultipleSelection.prototype.clear = function() {
  1202. var $rendered = this.$selection.find(".select2-selection__rendered");
  1203. $rendered.empty();
  1204. $rendered.removeAttr("title");
  1205. };
  1206. MultipleSelection.prototype.display = function(data, container) {
  1207. var template = this.options.get("templateSelection");
  1208. var escapeMarkup = this.options.get("escapeMarkup");
  1209. return escapeMarkup(template(data, container));
  1210. };
  1211. MultipleSelection.prototype.selectionContainer = function() {
  1212. var $container = $2(
  1213. '<li class="select2-selection__choice"><button type="button" class="select2-selection__choice__remove" tabindex="-1"><span aria-hidden="true">&times;</span></button><span class="select2-selection__choice__display"></span></li>'
  1214. );
  1215. return $container;
  1216. };
  1217. MultipleSelection.prototype.update = function(data) {
  1218. this.clear();
  1219. if (data.length === 0) {
  1220. return;
  1221. }
  1222. var $selections = [];
  1223. var selectionIdPrefix = this.$selection.find(".select2-selection__rendered").attr("id") + "-choice-";
  1224. for (var d = 0; d < data.length; d++) {
  1225. var selection = data[d];
  1226. var $selection = this.selectionContainer();
  1227. var formatted = this.display(selection, $selection);
  1228. var selectionId = selectionIdPrefix + Utils.generateChars(4) + "-";
  1229. if (selection.id) {
  1230. selectionId += selection.id;
  1231. } else {
  1232. selectionId += Utils.generateChars(4);
  1233. }
  1234. $selection.find(".select2-selection__choice__display").append(formatted).attr("id", selectionId);
  1235. var title = selection.title || selection.text;
  1236. if (title) {
  1237. $selection.attr("title", title);
  1238. }
  1239. var removeItem = this.options.get("translations").get("removeItem");
  1240. var $remove = $selection.find(".select2-selection__choice__remove");
  1241. $remove.attr("title", removeItem());
  1242. $remove.attr("aria-label", removeItem());
  1243. $remove.attr("aria-describedby", selectionId);
  1244. Utils.StoreData($selection[0], "data", selection);
  1245. $selections.push($selection);
  1246. }
  1247. var $rendered = this.$selection.find(".select2-selection__rendered");
  1248. $rendered.append($selections);
  1249. };
  1250. return MultipleSelection;
  1251. });
  1252. S22.define("select2/selection/placeholder", [], function() {
  1253. function Placeholder(decorated, $element, options) {
  1254. this.placeholder = this.normalizePlaceholder(options.get("placeholder"));
  1255. decorated.call(this, $element, options);
  1256. }
  1257. Placeholder.prototype.normalizePlaceholder = function(_, placeholder) {
  1258. if (typeof placeholder === "string") {
  1259. placeholder = {
  1260. id: "",
  1261. text: placeholder
  1262. };
  1263. }
  1264. return placeholder;
  1265. };
  1266. Placeholder.prototype.createPlaceholder = function(decorated, placeholder) {
  1267. var $placeholder = this.selectionContainer();
  1268. $placeholder.html(this.display(placeholder));
  1269. $placeholder[0].classList.add("select2-selection__placeholder");
  1270. $placeholder[0].classList.remove("select2-selection__choice");
  1271. var placeholderTitle = placeholder.title || placeholder.text || $placeholder.text();
  1272. this.$selection.find(".select2-selection__rendered").attr(
  1273. "title",
  1274. placeholderTitle
  1275. );
  1276. return $placeholder;
  1277. };
  1278. Placeholder.prototype.update = function(decorated, data) {
  1279. var singlePlaceholder = data.length == 1 && data[0].id != this.placeholder.id;
  1280. var multipleSelections = data.length > 1;
  1281. if (multipleSelections || singlePlaceholder) {
  1282. return decorated.call(this, data);
  1283. }
  1284. this.clear();
  1285. var $placeholder = this.createPlaceholder(this.placeholder);
  1286. this.$selection.find(".select2-selection__rendered").append($placeholder);
  1287. };
  1288. return Placeholder;
  1289. });
  1290. S22.define("select2/selection/allowClear", [
  1291. "jquery",
  1292. "../keys",
  1293. "../utils"
  1294. ], function($2, KEYS, Utils) {
  1295. function AllowClear() {
  1296. }
  1297. AllowClear.prototype.bind = function(decorated, container, $container) {
  1298. var self = this;
  1299. decorated.call(this, container, $container);
  1300. if (this.placeholder == null) {
  1301. if (this.options.get("debug") && window.console && console.error) {
  1302. console.error(
  1303. "Select2: The `allowClear` option should be used in combination with the `placeholder` option."
  1304. );
  1305. }
  1306. }
  1307. this.$selection.on(
  1308. "mousedown",
  1309. ".select2-selection__clear",
  1310. function(evt) {
  1311. self._handleClear(evt);
  1312. }
  1313. );
  1314. container.on("keypress", function(evt) {
  1315. self._handleKeyboardClear(evt, container);
  1316. });
  1317. };
  1318. AllowClear.prototype._handleClear = function(_, evt) {
  1319. if (this.isDisabled()) {
  1320. return;
  1321. }
  1322. var $clear = this.$selection.find(".select2-selection__clear");
  1323. if ($clear.length === 0) {
  1324. return;
  1325. }
  1326. evt.stopPropagation();
  1327. var data = Utils.GetData($clear[0], "data");
  1328. var previousVal = this.$element.val();
  1329. this.$element.val(this.placeholder.id);
  1330. var unselectData = {
  1331. data
  1332. };
  1333. this.trigger("clear", unselectData);
  1334. if (unselectData.prevented) {
  1335. this.$element.val(previousVal);
  1336. return;
  1337. }
  1338. for (var d = 0; d < data.length; d++) {
  1339. unselectData = {
  1340. data: data[d]
  1341. };
  1342. this.trigger("unselect", unselectData);
  1343. if (unselectData.prevented) {
  1344. this.$element.val(previousVal);
  1345. return;
  1346. }
  1347. }
  1348. this.$element.trigger("input").trigger("change");
  1349. this.trigger("toggle", {});
  1350. };
  1351. AllowClear.prototype._handleKeyboardClear = function(_, evt, container) {
  1352. if (container.isOpen()) {
  1353. return;
  1354. }
  1355. if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) {
  1356. this._handleClear(evt);
  1357. }
  1358. };
  1359. AllowClear.prototype.update = function(decorated, data) {
  1360. decorated.call(this, data);
  1361. this.$selection.find(".select2-selection__clear").remove();
  1362. this.$selection[0].classList.remove("select2-selection--clearable");
  1363. if (this.$selection.find(".select2-selection__placeholder").length > 0 || data.length === 0) {
  1364. return;
  1365. }
  1366. var selectionId = this.$selection.find(".select2-selection__rendered").attr("id");
  1367. var removeAll = this.options.get("translations").get("removeAllItems");
  1368. var $remove = $2(
  1369. '<button type="button" class="select2-selection__clear" tabindex="-1"><span aria-hidden="true">&times;</span></button>'
  1370. );
  1371. $remove.attr("title", removeAll());
  1372. $remove.attr("aria-label", removeAll());
  1373. $remove.attr("aria-describedby", selectionId);
  1374. Utils.StoreData($remove[0], "data", data);
  1375. this.$selection.prepend($remove);
  1376. this.$selection[0].classList.add("select2-selection--clearable");
  1377. };
  1378. return AllowClear;
  1379. });
  1380. S22.define("select2/selection/search", [
  1381. "jquery",
  1382. "../utils",
  1383. "../keys"
  1384. ], function($2, Utils, KEYS) {
  1385. function Search(decorated, $element, options) {
  1386. decorated.call(this, $element, options);
  1387. }
  1388. Search.prototype.render = function(decorated) {
  1389. var searchLabel = this.options.get("translations").get("search");
  1390. var $search = $2(
  1391. '<span class="select2-search select2-search--inline"><textarea class="select2-search__field" type="search" tabindex="-1" autocorrect="off" autocapitalize="none" spellcheck="false" role="searchbox" aria-autocomplete="list" ></textarea></span>'
  1392. );
  1393. this.$searchContainer = $search;
  1394. this.$search = $search.find("textarea");
  1395. this.$search.prop("autocomplete", this.options.get("autocomplete"));
  1396. this.$search.attr("aria-label", searchLabel());
  1397. var $rendered = decorated.call(this);
  1398. this._transferTabIndex();
  1399. $rendered.append(this.$searchContainer);
  1400. return $rendered;
  1401. };
  1402. Search.prototype.bind = function(decorated, container, $container) {
  1403. var self = this;
  1404. var resultsId = container.id + "-results";
  1405. var selectionId = container.id + "-container";
  1406. decorated.call(this, container, $container);
  1407. self.$search.attr("aria-describedby", selectionId);
  1408. container.on("open", function() {
  1409. self.$search.attr("aria-controls", resultsId);
  1410. self.$search.trigger("focus");
  1411. });
  1412. container.on("close", function() {
  1413. self.$search.val("");
  1414. self.resizeSearch();
  1415. self.$search.removeAttr("aria-controls");
  1416. self.$search.removeAttr("aria-activedescendant");
  1417. self.$search.trigger("focus");
  1418. });
  1419. container.on("enable", function() {
  1420. self.$search.prop("disabled", false);
  1421. self._transferTabIndex();
  1422. });
  1423. container.on("disable", function() {
  1424. self.$search.prop("disabled", true);
  1425. });
  1426. container.on("focus", function(evt) {
  1427. self.$search.trigger("focus");
  1428. });
  1429. container.on("results:focus", function(params) {
  1430. if (params.data._resultId) {
  1431. self.$search.attr("aria-activedescendant", params.data._resultId);
  1432. } else {
  1433. self.$search.removeAttr("aria-activedescendant");
  1434. }
  1435. });
  1436. this.$selection.on("focusin", ".select2-search--inline", function(evt) {
  1437. self.trigger("focus", evt);
  1438. });
  1439. this.$selection.on("focusout", ".select2-search--inline", function(evt) {
  1440. self._handleBlur(evt);
  1441. });
  1442. this.$selection.on("keydown", ".select2-search--inline", function(evt) {
  1443. evt.stopPropagation();
  1444. self.trigger("keypress", evt);
  1445. self._keyUpPrevented = evt.isDefaultPrevented();
  1446. var key = evt.which;
  1447. if (key === KEYS.BACKSPACE && self.$search.val() === "") {
  1448. var $previousChoice = self.$selection.find(".select2-selection__choice").last();
  1449. if ($previousChoice.length > 0) {
  1450. var item = Utils.GetData($previousChoice[0], "data");
  1451. self.searchRemoveChoice(item);
  1452. evt.preventDefault();
  1453. }
  1454. }
  1455. });
  1456. this.$selection.on("click", ".select2-search--inline", function(evt) {
  1457. if (self.$search.val()) {
  1458. evt.stopPropagation();
  1459. }
  1460. });
  1461. var msie = document.documentMode;
  1462. var disableInputEvents = msie && msie <= 11;
  1463. this.$selection.on(
  1464. "input.searchcheck",
  1465. ".select2-search--inline",
  1466. function(evt) {
  1467. if (disableInputEvents) {
  1468. self.$selection.off("input.search input.searchcheck");
  1469. return;
  1470. }
  1471. self.$selection.off("keyup.search");
  1472. }
  1473. );
  1474. this.$selection.on(
  1475. "keyup.search input.search",
  1476. ".select2-search--inline",
  1477. function(evt) {
  1478. if (disableInputEvents && evt.type === "input") {
  1479. self.$selection.off("input.search input.searchcheck");
  1480. return;
  1481. }
  1482. var key = evt.which;
  1483. if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) {
  1484. return;
  1485. }
  1486. if (key == KEYS.TAB) {
  1487. return;
  1488. }
  1489. self.handleSearch(evt);
  1490. }
  1491. );
  1492. };
  1493. Search.prototype._transferTabIndex = function(decorated) {
  1494. this.$search.attr("tabindex", this.$selection.attr("tabindex"));
  1495. this.$selection.attr("tabindex", "-1");
  1496. };
  1497. Search.prototype.createPlaceholder = function(decorated, placeholder) {
  1498. this.$search.attr("placeholder", placeholder.text);
  1499. };
  1500. Search.prototype.update = function(decorated, data) {
  1501. var searchHadFocus = this.$search[0] == document.activeElement;
  1502. this.$search.attr("placeholder", "");
  1503. decorated.call(this, data);
  1504. this.resizeSearch();
  1505. if (searchHadFocus) {
  1506. this.$search.trigger("focus");
  1507. }
  1508. };
  1509. Search.prototype.handleSearch = function() {
  1510. this.resizeSearch();
  1511. if (!this._keyUpPrevented) {
  1512. var input = this.$search.val();
  1513. this.trigger("query", {
  1514. term: input
  1515. });
  1516. }
  1517. this._keyUpPrevented = false;
  1518. };
  1519. Search.prototype.searchRemoveChoice = function(decorated, item) {
  1520. this.trigger("unselect", {
  1521. data: item
  1522. });
  1523. this.$search.val(item.text);
  1524. this.handleSearch();
  1525. };
  1526. Search.prototype.resizeSearch = function() {
  1527. this.$search.css("width", "25px");
  1528. var width = "100%";
  1529. if (this.$search.attr("placeholder") === "") {
  1530. var minimumWidth = this.$search.val().length + 1;
  1531. width = minimumWidth * 0.75 + "em";
  1532. }
  1533. this.$search.css("width", width);
  1534. };
  1535. return Search;
  1536. });
  1537. S22.define("select2/selection/selectionCss", [
  1538. "../utils"
  1539. ], function(Utils) {
  1540. function SelectionCSS() {
  1541. }
  1542. SelectionCSS.prototype.render = function(decorated) {
  1543. var $selection = decorated.call(this);
  1544. var selectionCssClass = this.options.get("selectionCssClass") || "";
  1545. if (selectionCssClass.indexOf(":all:") !== -1) {
  1546. selectionCssClass = selectionCssClass.replace(":all:", "");
  1547. Utils.copyNonInternalCssClasses($selection[0], this.$element[0]);
  1548. }
  1549. $selection.addClass(selectionCssClass);
  1550. return $selection;
  1551. };
  1552. return SelectionCSS;
  1553. });
  1554. S22.define("select2/selection/eventRelay", [
  1555. "jquery"
  1556. ], function($2) {
  1557. function EventRelay() {
  1558. }
  1559. EventRelay.prototype.bind = function(decorated, container, $container) {
  1560. var self = this;
  1561. var relayEvents = [
  1562. "open",
  1563. "opening",
  1564. "close",
  1565. "closing",
  1566. "select",
  1567. "selecting",
  1568. "unselect",
  1569. "unselecting",
  1570. "clear",
  1571. "clearing"
  1572. ];
  1573. var preventableEvents = [
  1574. "opening",
  1575. "closing",
  1576. "selecting",
  1577. "unselecting",
  1578. "clearing"
  1579. ];
  1580. decorated.call(this, container, $container);
  1581. container.on("*", function(name, params) {
  1582. if (relayEvents.indexOf(name) === -1) {
  1583. return;
  1584. }
  1585. params = params || {};
  1586. var evt = $2.Event("select2:" + name, {
  1587. params
  1588. });
  1589. self.$element.trigger(evt);
  1590. if (preventableEvents.indexOf(name) === -1) {
  1591. return;
  1592. }
  1593. params.prevented = evt.isDefaultPrevented();
  1594. });
  1595. };
  1596. return EventRelay;
  1597. });
  1598. S22.define("select2/translation", [
  1599. "jquery",
  1600. "require"
  1601. ], function($2, require2) {
  1602. function Translation(dict) {
  1603. this.dict = dict || {};
  1604. }
  1605. Translation.prototype.all = function() {
  1606. return this.dict;
  1607. };
  1608. Translation.prototype.get = function(key) {
  1609. return this.dict[key];
  1610. };
  1611. Translation.prototype.extend = function(translation) {
  1612. this.dict = $2.extend({}, translation.all(), this.dict);
  1613. };
  1614. Translation._cache = {};
  1615. Translation.loadPath = function(path) {
  1616. if (!(path in Translation._cache)) {
  1617. var translations = require2(path);
  1618. Translation._cache[path] = translations;
  1619. }
  1620. return new Translation(Translation._cache[path]);
  1621. };
  1622. return Translation;
  1623. });
  1624. S22.define("select2/diacritics", [], function() {
  1625. var diacritics = {
  1626. "Ⓐ": "A",
  1627. "A": "A",
  1628. "À": "A",
  1629. "Á": "A",
  1630. "Â": "A",
  1631. "Ầ": "A",
  1632. "Ấ": "A",
  1633. "Ẫ": "A",
  1634. "Ẩ": "A",
  1635. "Ã": "A",
  1636. "Ā": "A",
  1637. "Ă": "A",
  1638. "Ằ": "A",
  1639. "Ắ": "A",
  1640. "Ẵ": "A",
  1641. "Ẳ": "A",
  1642. "Ȧ": "A",
  1643. "Ǡ": "A",
  1644. "Ä": "A",
  1645. "Ǟ": "A",
  1646. "Ả": "A",
  1647. "Å": "A",
  1648. "Ǻ": "A",
  1649. "Ǎ": "A",
  1650. "Ȁ": "A",
  1651. "Ȃ": "A",
  1652. "Ạ": "A",
  1653. "Ậ": "A",
  1654. "Ặ": "A",
  1655. "Ḁ": "A",
  1656. "Ą": "A",
  1657. "Ⱥ": "A",
  1658. "Ɐ": "A",
  1659. "Ꜳ": "AA",
  1660. "Æ": "AE",
  1661. "Ǽ": "AE",
  1662. "Ǣ": "AE",
  1663. "Ꜵ": "AO",
  1664. "Ꜷ": "AU",
  1665. "Ꜹ": "AV",
  1666. "Ꜻ": "AV",
  1667. "Ꜽ": "AY",
  1668. "Ⓑ": "B",
  1669. "B": "B",
  1670. "Ḃ": "B",
  1671. "Ḅ": "B",
  1672. "Ḇ": "B",
  1673. "Ƀ": "B",
  1674. "Ƃ": "B",
  1675. "Ɓ": "B",
  1676. "Ⓒ": "C",
  1677. "C": "C",
  1678. "Ć": "C",
  1679. "Ĉ": "C",
  1680. "Ċ": "C",
  1681. "Č": "C",
  1682. "Ç": "C",
  1683. "Ḉ": "C",
  1684. "Ƈ": "C",
  1685. "Ȼ": "C",
  1686. "Ꜿ": "C",
  1687. "Ⓓ": "D",
  1688. "D": "D",
  1689. "Ḋ": "D",
  1690. "Ď": "D",
  1691. "Ḍ": "D",
  1692. "Ḑ": "D",
  1693. "Ḓ": "D",
  1694. "Ḏ": "D",
  1695. "Đ": "D",
  1696. "Ƌ": "D",
  1697. "Ɗ": "D",
  1698. "Ɖ": "D",
  1699. "Ꝺ": "D",
  1700. "DZ": "DZ",
  1701. "DŽ": "DZ",
  1702. "Dz": "Dz",
  1703. "Dž": "Dz",
  1704. "Ⓔ": "E",
  1705. "E": "E",
  1706. "È": "E",
  1707. "É": "E",
  1708. "Ê": "E",
  1709. "Ề": "E",
  1710. "Ế": "E",
  1711. "Ễ": "E",
  1712. "Ể": "E",
  1713. "Ẽ": "E",
  1714. "Ē": "E",
  1715. "Ḕ": "E",
  1716. "Ḗ": "E",
  1717. "Ĕ": "E",
  1718. "Ė": "E",
  1719. "Ë": "E",
  1720. "Ẻ": "E",
  1721. "Ě": "E",
  1722. "Ȅ": "E",
  1723. "Ȇ": "E",
  1724. "Ẹ": "E",
  1725. "Ệ": "E",
  1726. "Ȩ": "E",
  1727. "Ḝ": "E",
  1728. "Ę": "E",
  1729. "Ḙ": "E",
  1730. "Ḛ": "E",
  1731. "Ɛ": "E",
  1732. "Ǝ": "E",
  1733. "Ⓕ": "F",
  1734. "F": "F",
  1735. "Ḟ": "F",
  1736. "Ƒ": "F",
  1737. "Ꝼ": "F",
  1738. "Ⓖ": "G",
  1739. "G": "G",
  1740. "Ǵ": "G",
  1741. "Ĝ": "G",
  1742. "Ḡ": "G",
  1743. "Ğ": "G",
  1744. "Ġ": "G",
  1745. "Ǧ": "G",
  1746. "Ģ": "G",
  1747. "Ǥ": "G",
  1748. "Ɠ": "G",
  1749. "Ꞡ": "G",
  1750. "Ᵹ": "G",
  1751. "Ꝿ": "G",
  1752. "Ⓗ": "H",
  1753. "H": "H",
  1754. "Ĥ": "H",
  1755. "Ḣ": "H",
  1756. "Ḧ": "H",
  1757. "Ȟ": "H",
  1758. "Ḥ": "H",
  1759. "Ḩ": "H",
  1760. "Ḫ": "H",
  1761. "Ħ": "H",
  1762. "Ⱨ": "H",
  1763. "Ⱶ": "H",
  1764. "Ɥ": "H",
  1765. "Ⓘ": "I",
  1766. "I": "I",
  1767. "Ì": "I",
  1768. "Í": "I",
  1769. "Î": "I",
  1770. "Ĩ": "I",
  1771. "Ī": "I",
  1772. "Ĭ": "I",
  1773. "İ": "I",
  1774. "Ï": "I",
  1775. "Ḯ": "I",
  1776. "Ỉ": "I",
  1777. "Ǐ": "I",
  1778. "Ȉ": "I",
  1779. "Ȋ": "I",
  1780. "Ị": "I",
  1781. "Į": "I",
  1782. "Ḭ": "I",
  1783. "Ɨ": "I",
  1784. "Ⓙ": "J",
  1785. "J": "J",
  1786. "Ĵ": "J",
  1787. "Ɉ": "J",
  1788. "Ⓚ": "K",
  1789. "K": "K",
  1790. "Ḱ": "K",
  1791. "Ǩ": "K",
  1792. "Ḳ": "K",
  1793. "Ķ": "K",
  1794. "Ḵ": "K",
  1795. "Ƙ": "K",
  1796. "Ⱪ": "K",
  1797. "Ꝁ": "K",
  1798. "Ꝃ": "K",
  1799. "Ꝅ": "K",
  1800. "Ꞣ": "K",
  1801. "Ⓛ": "L",
  1802. "L": "L",
  1803. "Ŀ": "L",
  1804. "Ĺ": "L",
  1805. "Ľ": "L",
  1806. "Ḷ": "L",
  1807. "Ḹ": "L",
  1808. "Ļ": "L",
  1809. "Ḽ": "L",
  1810. "Ḻ": "L",
  1811. "Ł": "L",
  1812. "Ƚ": "L",
  1813. "Ɫ": "L",
  1814. "Ⱡ": "L",
  1815. "Ꝉ": "L",
  1816. "Ꝇ": "L",
  1817. "Ꞁ": "L",
  1818. "LJ": "LJ",
  1819. "Lj": "Lj",
  1820. "Ⓜ": "M",
  1821. "M": "M",
  1822. "Ḿ": "M",
  1823. "Ṁ": "M",
  1824. "Ṃ": "M",
  1825. "Ɱ": "M",
  1826. "Ɯ": "M",
  1827. "Ⓝ": "N",
  1828. "N": "N",
  1829. "Ǹ": "N",
  1830. "Ń": "N",
  1831. "Ñ": "N",
  1832. "Ṅ": "N",
  1833. "Ň": "N",
  1834. "Ṇ": "N",
  1835. "Ņ": "N",
  1836. "Ṋ": "N",
  1837. "Ṉ": "N",
  1838. "Ƞ": "N",
  1839. "Ɲ": "N",
  1840. "Ꞑ": "N",
  1841. "Ꞥ": "N",
  1842. "NJ": "NJ",
  1843. "Nj": "Nj",
  1844. "Ⓞ": "O",
  1845. "O": "O",
  1846. "Ò": "O",
  1847. "Ó": "O",
  1848. "Ô": "O",
  1849. "Ồ": "O",
  1850. "Ố": "O",
  1851. "Ỗ": "O",
  1852. "Ổ": "O",
  1853. "Õ": "O",
  1854. "Ṍ": "O",
  1855. "Ȭ": "O",
  1856. "Ṏ": "O",
  1857. "Ō": "O",
  1858. "Ṑ": "O",
  1859. "Ṓ": "O",
  1860. "Ŏ": "O",
  1861. "Ȯ": "O",
  1862. "Ȱ": "O",
  1863. "Ö": "O",
  1864. "Ȫ": "O",
  1865. "Ỏ": "O",
  1866. "Ő": "O",
  1867. "Ǒ": "O",
  1868. "Ȍ": "O",
  1869. "Ȏ": "O",
  1870. "Ơ": "O",
  1871. "Ờ": "O",
  1872. "Ớ": "O",
  1873. "Ỡ": "O",
  1874. "Ở": "O",
  1875. "Ợ": "O",
  1876. "Ọ": "O",
  1877. "Ộ": "O",
  1878. "Ǫ": "O",
  1879. "Ǭ": "O",
  1880. "Ø": "O",
  1881. "Ǿ": "O",
  1882. "Ɔ": "O",
  1883. "Ɵ": "O",
  1884. "Ꝋ": "O",
  1885. "Ꝍ": "O",
  1886. "Œ": "OE",
  1887. "Ƣ": "OI",
  1888. "Ꝏ": "OO",
  1889. "Ȣ": "OU",
  1890. "Ⓟ": "P",
  1891. "P": "P",
  1892. "Ṕ": "P",
  1893. "Ṗ": "P",
  1894. "Ƥ": "P",
  1895. "Ᵽ": "P",
  1896. "Ꝑ": "P",
  1897. "Ꝓ": "P",
  1898. "Ꝕ": "P",
  1899. "Ⓠ": "Q",
  1900. "Q": "Q",
  1901. "Ꝗ": "Q",
  1902. "Ꝙ": "Q",
  1903. "Ɋ": "Q",
  1904. "Ⓡ": "R",
  1905. "R": "R",
  1906. "Ŕ": "R",
  1907. "Ṙ": "R",
  1908. "Ř": "R",
  1909. "Ȑ": "R",
  1910. "Ȓ": "R",
  1911. "Ṛ": "R",
  1912. "Ṝ": "R",
  1913. "Ŗ": "R",
  1914. "Ṟ": "R",
  1915. "Ɍ": "R",
  1916. "Ɽ": "R",
  1917. "Ꝛ": "R",
  1918. "Ꞧ": "R",
  1919. "Ꞃ": "R",
  1920. "Ⓢ": "S",
  1921. "S": "S",
  1922. "ẞ": "S",
  1923. "Ś": "S",
  1924. "Ṥ": "S",
  1925. "Ŝ": "S",
  1926. "Ṡ": "S",
  1927. "Š": "S",
  1928. "Ṧ": "S",
  1929. "Ṣ": "S",
  1930. "Ṩ": "S",
  1931. "Ș": "S",
  1932. "Ş": "S",
  1933. "Ȿ": "S",
  1934. "Ꞩ": "S",
  1935. "Ꞅ": "S",
  1936. "Ⓣ": "T",
  1937. "T": "T",
  1938. "Ṫ": "T",
  1939. "Ť": "T",
  1940. "Ṭ": "T",
  1941. "Ț": "T",
  1942. "Ţ": "T",
  1943. "Ṱ": "T",
  1944. "Ṯ": "T",
  1945. "Ŧ": "T",
  1946. "Ƭ": "T",
  1947. "Ʈ": "T",
  1948. "Ⱦ": "T",
  1949. "Ꞇ": "T",
  1950. "Ꜩ": "TZ",
  1951. "Ⓤ": "U",
  1952. "U": "U",
  1953. "Ù": "U",
  1954. "Ú": "U",
  1955. "Û": "U",
  1956. "Ũ": "U",
  1957. "Ṹ": "U",
  1958. "Ū": "U",
  1959. "Ṻ": "U",
  1960. "Ŭ": "U",
  1961. "Ü": "U",
  1962. "Ǜ": "U",
  1963. "Ǘ": "U",
  1964. "Ǖ": "U",
  1965. "Ǚ": "U",
  1966. "Ủ": "U",
  1967. "Ů": "U",
  1968. "Ű": "U",
  1969. "Ǔ": "U",
  1970. "Ȕ": "U",
  1971. "Ȗ": "U",
  1972. "Ư": "U",
  1973. "Ừ": "U",
  1974. "Ứ": "U",
  1975. "Ữ": "U",
  1976. "Ử": "U",
  1977. "Ự": "U",
  1978. "Ụ": "U",
  1979. "Ṳ": "U",
  1980. "Ų": "U",
  1981. "Ṷ": "U",
  1982. "Ṵ": "U",
  1983. "Ʉ": "U",
  1984. "Ⓥ": "V",
  1985. "V": "V",
  1986. "Ṽ": "V",
  1987. "Ṿ": "V",
  1988. "Ʋ": "V",
  1989. "Ꝟ": "V",
  1990. "Ʌ": "V",
  1991. "Ꝡ": "VY",
  1992. "Ⓦ": "W",
  1993. "W": "W",
  1994. "Ẁ": "W",
  1995. "Ẃ": "W",
  1996. "Ŵ": "W",
  1997. "Ẇ": "W",
  1998. "Ẅ": "W",
  1999. "Ẉ": "W",
  2000. "Ⱳ": "W",
  2001. "Ⓧ": "X",
  2002. "X": "X",
  2003. "Ẋ": "X",
  2004. "Ẍ": "X",
  2005. "Ⓨ": "Y",
  2006. "Y": "Y",
  2007. "Ỳ": "Y",
  2008. "Ý": "Y",
  2009. "Ŷ": "Y",
  2010. "Ỹ": "Y",
  2011. "Ȳ": "Y",
  2012. "Ẏ": "Y",
  2013. "Ÿ": "Y",
  2014. "Ỷ": "Y",
  2015. "Ỵ": "Y",
  2016. "Ƴ": "Y",
  2017. "Ɏ": "Y",
  2018. "Ỿ": "Y",
  2019. "Ⓩ": "Z",
  2020. "Z": "Z",
  2021. "Ź": "Z",
  2022. "Ẑ": "Z",
  2023. "Ż": "Z",
  2024. "Ž": "Z",
  2025. "Ẓ": "Z",
  2026. "Ẕ": "Z",
  2027. "Ƶ": "Z",
  2028. "Ȥ": "Z",
  2029. "Ɀ": "Z",
  2030. "Ⱬ": "Z",
  2031. "Ꝣ": "Z",
  2032. "ⓐ": "a",
  2033. "a": "a",
  2034. "ẚ": "a",
  2035. "à": "a",
  2036. "á": "a",
  2037. "â": "a",
  2038. "ầ": "a",
  2039. "ấ": "a",
  2040. "ẫ": "a",
  2041. "ẩ": "a",
  2042. "ã": "a",
  2043. "ā": "a",
  2044. "ă": "a",
  2045. "ằ": "a",
  2046. "ắ": "a",
  2047. "ẵ": "a",
  2048. "ẳ": "a",
  2049. "ȧ": "a",
  2050. "ǡ": "a",
  2051. "ä": "a",
  2052. "ǟ": "a",
  2053. "ả": "a",
  2054. "å": "a",
  2055. "ǻ": "a",
  2056. "ǎ": "a",
  2057. "ȁ": "a",
  2058. "ȃ": "a",
  2059. "ạ": "a",
  2060. "ậ": "a",
  2061. "ặ": "a",
  2062. "ḁ": "a",
  2063. "ą": "a",
  2064. "ⱥ": "a",
  2065. "ɐ": "a",
  2066. "ꜳ": "aa",
  2067. "æ": "ae",
  2068. "ǽ": "ae",
  2069. "ǣ": "ae",
  2070. "ꜵ": "ao",
  2071. "ꜷ": "au",
  2072. "ꜹ": "av",
  2073. "ꜻ": "av",
  2074. "ꜽ": "ay",
  2075. "ⓑ": "b",
  2076. "b": "b",
  2077. "ḃ": "b",
  2078. "ḅ": "b",
  2079. "ḇ": "b",
  2080. "ƀ": "b",
  2081. "ƃ": "b",
  2082. "ɓ": "b",
  2083. "ⓒ": "c",
  2084. "c": "c",
  2085. "ć": "c",
  2086. "ĉ": "c",
  2087. "ċ": "c",
  2088. "č": "c",
  2089. "ç": "c",
  2090. "ḉ": "c",
  2091. "ƈ": "c",
  2092. "ȼ": "c",
  2093. "ꜿ": "c",
  2094. "ↄ": "c",
  2095. "ⓓ": "d",
  2096. "d": "d",
  2097. "ḋ": "d",
  2098. "ď": "d",
  2099. "ḍ": "d",
  2100. "ḑ": "d",
  2101. "ḓ": "d",
  2102. "ḏ": "d",
  2103. "đ": "d",
  2104. "ƌ": "d",
  2105. "ɖ": "d",
  2106. "ɗ": "d",
  2107. "ꝺ": "d",
  2108. "dz": "dz",
  2109. "dž": "dz",
  2110. "ⓔ": "e",
  2111. "e": "e",
  2112. "è": "e",
  2113. "é": "e",
  2114. "ê": "e",
  2115. "ề": "e",
  2116. "ế": "e",
  2117. "ễ": "e",
  2118. "ể": "e",
  2119. "ẽ": "e",
  2120. "ē": "e",
  2121. "ḕ": "e",
  2122. "ḗ": "e",
  2123. "ĕ": "e",
  2124. "ė": "e",
  2125. "ë": "e",
  2126. "ẻ": "e",
  2127. "ě": "e",
  2128. "ȅ": "e",
  2129. "ȇ": "e",
  2130. "ẹ": "e",
  2131. "ệ": "e",
  2132. "ȩ": "e",
  2133. "ḝ": "e",
  2134. "ę": "e",
  2135. "ḙ": "e",
  2136. "ḛ": "e",
  2137. "ɇ": "e",
  2138. "ɛ": "e",
  2139. "ǝ": "e",
  2140. "ⓕ": "f",
  2141. "f": "f",
  2142. "ḟ": "f",
  2143. "ƒ": "f",
  2144. "ꝼ": "f",
  2145. "ⓖ": "g",
  2146. "g": "g",
  2147. "ǵ": "g",
  2148. "ĝ": "g",
  2149. "ḡ": "g",
  2150. "ğ": "g",
  2151. "ġ": "g",
  2152. "ǧ": "g",
  2153. "ģ": "g",
  2154. "ǥ": "g",
  2155. "ɠ": "g",
  2156. "ꞡ": "g",
  2157. "ᵹ": "g",
  2158. "ꝿ": "g",
  2159. "ⓗ": "h",
  2160. "h": "h",
  2161. "ĥ": "h",
  2162. "ḣ": "h",
  2163. "ḧ": "h",
  2164. "ȟ": "h",
  2165. "ḥ": "h",
  2166. "ḩ": "h",
  2167. "ḫ": "h",
  2168. "ẖ": "h",
  2169. "ħ": "h",
  2170. "ⱨ": "h",
  2171. "ⱶ": "h",
  2172. "ɥ": "h",
  2173. "ƕ": "hv",
  2174. "ⓘ": "i",
  2175. "i": "i",
  2176. "ì": "i",
  2177. "í": "i",
  2178. "î": "i",
  2179. "ĩ": "i",
  2180. "ī": "i",
  2181. "ĭ": "i",
  2182. "ï": "i",
  2183. "ḯ": "i",
  2184. "ỉ": "i",
  2185. "ǐ": "i",
  2186. "ȉ": "i",
  2187. "ȋ": "i",
  2188. "ị": "i",
  2189. "į": "i",
  2190. "ḭ": "i",
  2191. "ɨ": "i",
  2192. "ı": "i",
  2193. "ⓙ": "j",
  2194. "j": "j",
  2195. "ĵ": "j",
  2196. "ǰ": "j",
  2197. "ɉ": "j",
  2198. "ⓚ": "k",
  2199. "k": "k",
  2200. "ḱ": "k",
  2201. "ǩ": "k",
  2202. "ḳ": "k",
  2203. "ķ": "k",
  2204. "ḵ": "k",
  2205. "ƙ": "k",
  2206. "ⱪ": "k",
  2207. "ꝁ": "k",
  2208. "ꝃ": "k",
  2209. "ꝅ": "k",
  2210. "ꞣ": "k",
  2211. "ⓛ": "l",
  2212. "l": "l",
  2213. "ŀ": "l",
  2214. "ĺ": "l",
  2215. "ľ": "l",
  2216. "ḷ": "l",
  2217. "ḹ": "l",
  2218. "ļ": "l",
  2219. "ḽ": "l",
  2220. "ḻ": "l",
  2221. "ſ": "l",
  2222. "ł": "l",
  2223. "ƚ": "l",
  2224. "ɫ": "l",
  2225. "ⱡ": "l",
  2226. "ꝉ": "l",
  2227. "ꞁ": "l",
  2228. "ꝇ": "l",
  2229. "lj": "lj",
  2230. "ⓜ": "m",
  2231. "m": "m",
  2232. "ḿ": "m",
  2233. "ṁ": "m",
  2234. "ṃ": "m",
  2235. "ɱ": "m",
  2236. "ɯ": "m",
  2237. "ⓝ": "n",
  2238. "n": "n",
  2239. "ǹ": "n",
  2240. "ń": "n",
  2241. "ñ": "n",
  2242. "ṅ": "n",
  2243. "ň": "n",
  2244. "ṇ": "n",
  2245. "ņ": "n",
  2246. "ṋ": "n",
  2247. "ṉ": "n",
  2248. "ƞ": "n",
  2249. "ɲ": "n",
  2250. "ʼn": "n",
  2251. "ꞑ": "n",
  2252. "ꞥ": "n",
  2253. "nj": "nj",
  2254. "ⓞ": "o",
  2255. "o": "o",
  2256. "ò": "o",
  2257. "ó": "o",
  2258. "ô": "o",
  2259. "ồ": "o",
  2260. "ố": "o",
  2261. "ỗ": "o",
  2262. "ổ": "o",
  2263. "õ": "o",
  2264. "ṍ": "o",
  2265. "ȭ": "o",
  2266. "ṏ": "o",
  2267. "ō": "o",
  2268. "ṑ": "o",
  2269. "ṓ": "o",
  2270. "ŏ": "o",
  2271. "ȯ": "o",
  2272. "ȱ": "o",
  2273. "ö": "o",
  2274. "ȫ": "o",
  2275. "ỏ": "o",
  2276. "ő": "o",
  2277. "ǒ": "o",
  2278. "ȍ": "o",
  2279. "ȏ": "o",
  2280. "ơ": "o",
  2281. "ờ": "o",
  2282. "ớ": "o",
  2283. "ỡ": "o",
  2284. "ở": "o",
  2285. "ợ": "o",
  2286. "ọ": "o",
  2287. "ộ": "o",
  2288. "ǫ": "o",
  2289. "ǭ": "o",
  2290. "ø": "o",
  2291. "ǿ": "o",
  2292. "ɔ": "o",
  2293. "ꝋ": "o",
  2294. "ꝍ": "o",
  2295. "ɵ": "o",
  2296. "œ": "oe",
  2297. "ƣ": "oi",
  2298. "ȣ": "ou",
  2299. "ꝏ": "oo",
  2300. "ⓟ": "p",
  2301. "p": "p",
  2302. "ṕ": "p",
  2303. "ṗ": "p",
  2304. "ƥ": "p",
  2305. "ᵽ": "p",
  2306. "ꝑ": "p",
  2307. "ꝓ": "p",
  2308. "ꝕ": "p",
  2309. "ⓠ": "q",
  2310. "q": "q",
  2311. "ɋ": "q",
  2312. "ꝗ": "q",
  2313. "ꝙ": "q",
  2314. "ⓡ": "r",
  2315. "r": "r",
  2316. "ŕ": "r",
  2317. "ṙ": "r",
  2318. "ř": "r",
  2319. "ȑ": "r",
  2320. "ȓ": "r",
  2321. "ṛ": "r",
  2322. "ṝ": "r",
  2323. "ŗ": "r",
  2324. "ṟ": "r",
  2325. "ɍ": "r",
  2326. "ɽ": "r",
  2327. "ꝛ": "r",
  2328. "ꞧ": "r",
  2329. "ꞃ": "r",
  2330. "ⓢ": "s",
  2331. "s": "s",
  2332. "ß": "s",
  2333. "ś": "s",
  2334. "ṥ": "s",
  2335. "ŝ": "s",
  2336. "ṡ": "s",
  2337. "š": "s",
  2338. "ṧ": "s",
  2339. "ṣ": "s",
  2340. "ṩ": "s",
  2341. "ș": "s",
  2342. "ş": "s",
  2343. "ȿ": "s",
  2344. "ꞩ": "s",
  2345. "ꞅ": "s",
  2346. "ẛ": "s",
  2347. "ⓣ": "t",
  2348. "t": "t",
  2349. "ṫ": "t",
  2350. "ẗ": "t",
  2351. "ť": "t",
  2352. "ṭ": "t",
  2353. "ț": "t",
  2354. "ţ": "t",
  2355. "ṱ": "t",
  2356. "ṯ": "t",
  2357. "ŧ": "t",
  2358. "ƭ": "t",
  2359. "ʈ": "t",
  2360. "ⱦ": "t",
  2361. "ꞇ": "t",
  2362. "ꜩ": "tz",
  2363. "ⓤ": "u",
  2364. "u": "u",
  2365. "ù": "u",
  2366. "ú": "u",
  2367. "û": "u",
  2368. "ũ": "u",
  2369. "ṹ": "u",
  2370. "ū": "u",
  2371. "ṻ": "u",
  2372. "ŭ": "u",
  2373. "ü": "u",
  2374. "ǜ": "u",
  2375. "ǘ": "u",
  2376. "ǖ": "u",
  2377. "ǚ": "u",
  2378. "ủ": "u",
  2379. "ů": "u",
  2380. "ű": "u",
  2381. "ǔ": "u",
  2382. "ȕ": "u",
  2383. "ȗ": "u",
  2384. "ư": "u",
  2385. "ừ": "u",
  2386. "ứ": "u",
  2387. "ữ": "u",
  2388. "ử": "u",
  2389. "ự": "u",
  2390. "ụ": "u",
  2391. "ṳ": "u",
  2392. "ų": "u",
  2393. "ṷ": "u",
  2394. "ṵ": "u",
  2395. "ʉ": "u",
  2396. "ⓥ": "v",
  2397. "v": "v",
  2398. "ṽ": "v",
  2399. "ṿ": "v",
  2400. "ʋ": "v",
  2401. "ꝟ": "v",
  2402. "ʌ": "v",
  2403. "ꝡ": "vy",
  2404. "ⓦ": "w",
  2405. "w": "w",
  2406. "ẁ": "w",
  2407. "ẃ": "w",
  2408. "ŵ": "w",
  2409. "ẇ": "w",
  2410. "ẅ": "w",
  2411. "ẘ": "w",
  2412. "ẉ": "w",
  2413. "ⱳ": "w",
  2414. "ⓧ": "x",
  2415. "x": "x",
  2416. "ẋ": "x",
  2417. "ẍ": "x",
  2418. "ⓨ": "y",
  2419. "y": "y",
  2420. "ỳ": "y",
  2421. "ý": "y",
  2422. "ŷ": "y",
  2423. "ỹ": "y",
  2424. "ȳ": "y",
  2425. "ẏ": "y",
  2426. "ÿ": "y",
  2427. "ỷ": "y",
  2428. "ẙ": "y",
  2429. "ỵ": "y",
  2430. "ƴ": "y",
  2431. "ɏ": "y",
  2432. "ỿ": "y",
  2433. "ⓩ": "z",
  2434. "z": "z",
  2435. "ź": "z",
  2436. "ẑ": "z",
  2437. "ż": "z",
  2438. "ž": "z",
  2439. "ẓ": "z",
  2440. "ẕ": "z",
  2441. "ƶ": "z",
  2442. "ȥ": "z",
  2443. "ɀ": "z",
  2444. "ⱬ": "z",
  2445. "ꝣ": "z",
  2446. "Ά": "Α",
  2447. "Έ": "Ε",
  2448. "Ή": "Η",
  2449. "Ί": "Ι",
  2450. "Ϊ": "Ι",
  2451. "Ό": "Ο",
  2452. "Ύ": "Υ",
  2453. "Ϋ": "Υ",
  2454. "Ώ": "Ω",
  2455. "ά": "α",
  2456. "έ": "ε",
  2457. "ή": "η",
  2458. "ί": "ι",
  2459. "ϊ": "ι",
  2460. "ΐ": "ι",
  2461. "ό": "ο",
  2462. "ύ": "υ",
  2463. "ϋ": "υ",
  2464. "ΰ": "υ",
  2465. "ώ": "ω",
  2466. "ς": "σ",
  2467. "’": "'"
  2468. };
  2469. return diacritics;
  2470. });
  2471. S22.define("select2/data/base", [
  2472. "../utils"
  2473. ], function(Utils) {
  2474. function BaseAdapter($element, options) {
  2475. BaseAdapter.__super__.constructor.call(this);
  2476. }
  2477. Utils.Extend(BaseAdapter, Utils.Observable);
  2478. BaseAdapter.prototype.current = function(callback) {
  2479. throw new Error("The `current` method must be defined in child classes.");
  2480. };
  2481. BaseAdapter.prototype.query = function(params, callback) {
  2482. throw new Error("The `query` method must be defined in child classes.");
  2483. };
  2484. BaseAdapter.prototype.bind = function(container, $container) {
  2485. };
  2486. BaseAdapter.prototype.destroy = function() {
  2487. };
  2488. BaseAdapter.prototype.generateResultId = function(container, data) {
  2489. var id = container.id + "-result-";
  2490. id += Utils.generateChars(4);
  2491. if (data.id != null) {
  2492. id += "-" + data.id.toString();
  2493. } else {
  2494. id += "-" + Utils.generateChars(4);
  2495. }
  2496. return id;
  2497. };
  2498. return BaseAdapter;
  2499. });
  2500. S22.define("select2/data/select", [
  2501. "./base",
  2502. "../utils",
  2503. "jquery"
  2504. ], function(BaseAdapter, Utils, $2) {
  2505. function SelectAdapter($element, options) {
  2506. this.$element = $element;
  2507. this.options = options;
  2508. SelectAdapter.__super__.constructor.call(this);
  2509. }
  2510. Utils.Extend(SelectAdapter, BaseAdapter);
  2511. SelectAdapter.prototype.current = function(callback) {
  2512. var self = this;
  2513. var data = Array.prototype.map.call(
  2514. this.$element[0].querySelectorAll(":checked"),
  2515. function(selectedElement) {
  2516. return self.item($2(selectedElement));
  2517. }
  2518. );
  2519. callback(data);
  2520. };
  2521. SelectAdapter.prototype.select = function(data) {
  2522. var self = this;
  2523. data.selected = true;
  2524. if (data.element != null && data.element.tagName.toLowerCase() === "option") {
  2525. data.element.selected = true;
  2526. this.$element.trigger("input").trigger("change");
  2527. return;
  2528. }
  2529. if (this.$element.prop("multiple")) {
  2530. this.current(function(currentData) {
  2531. var val2 = [];
  2532. data = [data];
  2533. data.push.apply(data, currentData);
  2534. for (var d = 0; d < data.length; d++) {
  2535. var id = data[d].id;
  2536. if (val2.indexOf(id) === -1) {
  2537. val2.push(id);
  2538. }
  2539. }
  2540. self.$element.val(val2);
  2541. self.$element.trigger("input").trigger("change");
  2542. });
  2543. } else {
  2544. var val = data.id;
  2545. this.$element.val(val);
  2546. this.$element.trigger("input").trigger("change");
  2547. }
  2548. };
  2549. SelectAdapter.prototype.unselect = function(data) {
  2550. var self = this;
  2551. if (!this.$element.prop("multiple")) {
  2552. return;
  2553. }
  2554. data.selected = false;
  2555. if (data.element != null && data.element.tagName.toLowerCase() === "option") {
  2556. data.element.selected = false;
  2557. this.$element.trigger("input").trigger("change");
  2558. return;
  2559. }
  2560. this.current(function(currentData) {
  2561. var val = [];
  2562. for (var d = 0; d < currentData.length; d++) {
  2563. var id = currentData[d].id;
  2564. if (id !== data.id && val.indexOf(id) === -1) {
  2565. val.push(id);
  2566. }
  2567. }
  2568. self.$element.val(val);
  2569. self.$element.trigger("input").trigger("change");
  2570. });
  2571. };
  2572. SelectAdapter.prototype.bind = function(container, $container) {
  2573. var self = this;
  2574. this.container = container;
  2575. container.on("select", function(params) {
  2576. self.select(params.data);
  2577. });
  2578. container.on("unselect", function(params) {
  2579. self.unselect(params.data);
  2580. });
  2581. };
  2582. SelectAdapter.prototype.destroy = function() {
  2583. this.$element.find("*").each(function() {
  2584. Utils.RemoveData(this);
  2585. });
  2586. };
  2587. SelectAdapter.prototype.query = function(params, callback) {
  2588. var data = [];
  2589. var self = this;
  2590. var $options = this.$element.children();
  2591. $options.each(function() {
  2592. if (this.tagName.toLowerCase() !== "option" && this.tagName.toLowerCase() !== "optgroup") {
  2593. return;
  2594. }
  2595. var $option = $2(this);
  2596. var option = self.item($option);
  2597. var matches = self.matches(params, option);
  2598. if (matches !== null) {
  2599. data.push(matches);
  2600. }
  2601. });
  2602. callback({
  2603. results: data
  2604. });
  2605. };
  2606. SelectAdapter.prototype.addOptions = function($options) {
  2607. this.$element.append($options);
  2608. };
  2609. SelectAdapter.prototype.option = function(data) {
  2610. var option;
  2611. if (data.children) {
  2612. option = document.createElement("optgroup");
  2613. option.label = data.text;
  2614. } else {
  2615. option = document.createElement("option");
  2616. if (option.textContent !== void 0) {
  2617. option.textContent = data.text;
  2618. } else {
  2619. option.innerText = data.text;
  2620. }
  2621. }
  2622. if (data.id !== void 0) {
  2623. option.value = data.id;
  2624. }
  2625. if (data.disabled) {
  2626. option.disabled = true;
  2627. }
  2628. if (data.selected) {
  2629. option.selected = true;
  2630. }
  2631. if (data.title) {
  2632. option.title = data.title;
  2633. }
  2634. var normalizedData = this._normalizeItem(data);
  2635. normalizedData.element = option;
  2636. Utils.StoreData(option, "data", normalizedData);
  2637. return $2(option);
  2638. };
  2639. SelectAdapter.prototype.item = function($option) {
  2640. var data = {};
  2641. data = Utils.GetData($option[0], "data");
  2642. if (data != null) {
  2643. return data;
  2644. }
  2645. var option = $option[0];
  2646. if (option.tagName.toLowerCase() === "option") {
  2647. data = {
  2648. id: $option.val(),
  2649. text: $option.text(),
  2650. disabled: $option.prop("disabled"),
  2651. selected: $option.prop("selected"),
  2652. title: $option.prop("title")
  2653. };
  2654. } else if (option.tagName.toLowerCase() === "optgroup") {
  2655. data = {
  2656. text: $option.prop("label"),
  2657. children: [],
  2658. title: $option.prop("title")
  2659. };
  2660. var $children = $option.children("option");
  2661. var children = [];
  2662. for (var c = 0; c < $children.length; c++) {
  2663. var $child = $2($children[c]);
  2664. var child = this.item($child);
  2665. children.push(child);
  2666. }
  2667. data.children = children;
  2668. }
  2669. data = this._normalizeItem(data);
  2670. data.element = $option[0];
  2671. Utils.StoreData($option[0], "data", data);
  2672. return data;
  2673. };
  2674. SelectAdapter.prototype._normalizeItem = function(item) {
  2675. if (item !== Object(item)) {
  2676. item = {
  2677. id: item,
  2678. text: item
  2679. };
  2680. }
  2681. item = $2.extend({}, {
  2682. text: ""
  2683. }, item);
  2684. var defaults = {
  2685. selected: false,
  2686. disabled: false
  2687. };
  2688. if (item.id != null) {
  2689. item.id = item.id.toString();
  2690. }
  2691. if (item.text != null) {
  2692. item.text = item.text.toString();
  2693. }
  2694. if (item._resultId == null && item.id && this.container != null) {
  2695. item._resultId = this.generateResultId(this.container, item);
  2696. }
  2697. return $2.extend({}, defaults, item);
  2698. };
  2699. SelectAdapter.prototype.matches = function(params, data) {
  2700. var matcher = this.options.get("matcher");
  2701. return matcher(params, data);
  2702. };
  2703. return SelectAdapter;
  2704. });
  2705. S22.define("select2/data/array", [
  2706. "./select",
  2707. "../utils",
  2708. "jquery"
  2709. ], function(SelectAdapter, Utils, $2) {
  2710. function ArrayAdapter($element, options) {
  2711. this._dataToConvert = options.get("data") || [];
  2712. ArrayAdapter.__super__.constructor.call(this, $element, options);
  2713. }
  2714. Utils.Extend(ArrayAdapter, SelectAdapter);
  2715. ArrayAdapter.prototype.bind = function(container, $container) {
  2716. ArrayAdapter.__super__.bind.call(this, container, $container);
  2717. this.addOptions(this.convertToOptions(this._dataToConvert));
  2718. };
  2719. ArrayAdapter.prototype.select = function(data) {
  2720. var $option = this.$element.find("option").filter(function(i, elm) {
  2721. return elm.value == data.id.toString();
  2722. });
  2723. if ($option.length === 0) {
  2724. $option = this.option(data);
  2725. this.addOptions($option);
  2726. }
  2727. ArrayAdapter.__super__.select.call(this, data);
  2728. };
  2729. ArrayAdapter.prototype.convertToOptions = function(data) {
  2730. var self = this;
  2731. var $existing = this.$element.find("option");
  2732. var existingIds = $existing.map(function() {
  2733. return self.item($2(this)).id;
  2734. }).get();
  2735. var $options = [];
  2736. function onlyItem(item2) {
  2737. return function() {
  2738. return $2(this).val() == item2.id;
  2739. };
  2740. }
  2741. for (var d = 0; d < data.length; d++) {
  2742. var item = this._normalizeItem(data[d]);
  2743. if (existingIds.indexOf(item.id) >= 0) {
  2744. var $existingOption = $existing.filter(onlyItem(item));
  2745. var existingData = this.item($existingOption);
  2746. var newData = $2.extend(true, {}, item, existingData);
  2747. var $newOption = this.option(newData);
  2748. $existingOption.replaceWith($newOption);
  2749. continue;
  2750. }
  2751. var $option = this.option(item);
  2752. if (item.children) {
  2753. var $children = this.convertToOptions(item.children);
  2754. $option.append($children);
  2755. }
  2756. $options.push($option);
  2757. }
  2758. return $options;
  2759. };
  2760. return ArrayAdapter;
  2761. });
  2762. S22.define("select2/data/ajax", [
  2763. "./array",
  2764. "../utils",
  2765. "jquery"
  2766. ], function(ArrayAdapter, Utils, $2) {
  2767. function AjaxAdapter($element, options) {
  2768. this.ajaxOptions = this._applyDefaults(options.get("ajax"));
  2769. if (this.ajaxOptions.processResults != null) {
  2770. this.processResults = this.ajaxOptions.processResults;
  2771. }
  2772. AjaxAdapter.__super__.constructor.call(this, $element, options);
  2773. }
  2774. Utils.Extend(AjaxAdapter, ArrayAdapter);
  2775. AjaxAdapter.prototype._applyDefaults = function(options) {
  2776. var defaults = {
  2777. data: function(params) {
  2778. return $2.extend({}, params, {
  2779. q: params.term
  2780. });
  2781. },
  2782. transport: function(params, success, failure) {
  2783. var $request = $2.ajax(params);
  2784. $request.then(success);
  2785. $request.fail(failure);
  2786. return $request;
  2787. }
  2788. };
  2789. return $2.extend({}, defaults, options, true);
  2790. };
  2791. AjaxAdapter.prototype.processResults = function(results) {
  2792. return results;
  2793. };
  2794. AjaxAdapter.prototype.query = function(params, callback) {
  2795. var matches = [];
  2796. var self = this;
  2797. if (this._request != null) {
  2798. if (typeof this._request.abort === "function") {
  2799. this._request.abort();
  2800. }
  2801. this._request = null;
  2802. }
  2803. var options = $2.extend({
  2804. type: "GET"
  2805. }, this.ajaxOptions);
  2806. if (typeof options.url === "function") {
  2807. options.url = options.url.call(this.$element, params);
  2808. }
  2809. if (typeof options.data === "function") {
  2810. options.data = options.data.call(this.$element, params);
  2811. }
  2812. function request() {
  2813. var $request = options.transport(options, function(data) {
  2814. var results = self.processResults(data, params);
  2815. if (self.options.get("debug") && window.console && console.error) {
  2816. if (!results || !results.results || !Array.isArray(results.results)) {
  2817. console.error(
  2818. "Select2: The AJAX results did not return an array in the `results` key of the response."
  2819. );
  2820. }
  2821. }
  2822. callback(results);
  2823. }, function() {
  2824. if ("status" in $request && ($request.status === 0 || $request.status === "0")) {
  2825. return;
  2826. }
  2827. self.trigger("results:message", {
  2828. message: "errorLoading"
  2829. });
  2830. });
  2831. self._request = $request;
  2832. }
  2833. if (this.ajaxOptions.delay && params.term != null) {
  2834. if (this._queryTimeout) {
  2835. window.clearTimeout(this._queryTimeout);
  2836. }
  2837. this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay);
  2838. } else {
  2839. request();
  2840. }
  2841. };
  2842. return AjaxAdapter;
  2843. });
  2844. S22.define("select2/data/tags", [
  2845. "jquery"
  2846. ], function($2) {
  2847. function Tags(decorated, $element, options) {
  2848. var tags = options.get("tags");
  2849. var createTag = options.get("createTag");
  2850. if (createTag !== void 0) {
  2851. this.createTag = createTag;
  2852. }
  2853. var insertTag = options.get("insertTag");
  2854. if (insertTag !== void 0) {
  2855. this.insertTag = insertTag;
  2856. }
  2857. decorated.call(this, $element, options);
  2858. if (Array.isArray(tags)) {
  2859. for (var t = 0; t < tags.length; t++) {
  2860. var tag = tags[t];
  2861. var item = this._normalizeItem(tag);
  2862. var $option = this.option(item);
  2863. this.$element.append($option);
  2864. }
  2865. }
  2866. }
  2867. Tags.prototype.query = function(decorated, params, callback) {
  2868. var self = this;
  2869. this._removeOldTags();
  2870. if (params.term == null || params.page != null) {
  2871. decorated.call(this, params, callback);
  2872. return;
  2873. }
  2874. function wrapper(obj, child) {
  2875. var data = obj.results;
  2876. for (var i = 0; i < data.length; i++) {
  2877. var option = data[i];
  2878. var checkChildren = option.children != null && !wrapper({
  2879. results: option.children
  2880. }, true);
  2881. var optionText = (option.text || "").toUpperCase();
  2882. var paramsTerm = (params.term || "").toUpperCase();
  2883. var checkText = optionText === paramsTerm;
  2884. if (checkText || checkChildren) {
  2885. if (child) {
  2886. return false;
  2887. }
  2888. obj.data = data;
  2889. callback(obj);
  2890. return;
  2891. }
  2892. }
  2893. if (child) {
  2894. return true;
  2895. }
  2896. var tag = self.createTag(params);
  2897. if (tag != null) {
  2898. var $option = self.option(tag);
  2899. $option.attr("data-select2-tag", "true");
  2900. self.addOptions([$option]);
  2901. self.insertTag(data, tag);
  2902. }
  2903. obj.results = data;
  2904. callback(obj);
  2905. }
  2906. decorated.call(this, params, wrapper);
  2907. };
  2908. Tags.prototype.createTag = function(decorated, params) {
  2909. if (params.term == null) {
  2910. return null;
  2911. }
  2912. var term = params.term.trim();
  2913. if (term === "") {
  2914. return null;
  2915. }
  2916. return {
  2917. id: term,
  2918. text: term
  2919. };
  2920. };
  2921. Tags.prototype.insertTag = function(_, data, tag) {
  2922. data.unshift(tag);
  2923. };
  2924. Tags.prototype._removeOldTags = function(_) {
  2925. var $options = this.$element.find("option[data-select2-tag]");
  2926. $options.each(function() {
  2927. if (this.selected) {
  2928. return;
  2929. }
  2930. $2(this).remove();
  2931. });
  2932. };
  2933. return Tags;
  2934. });
  2935. S22.define("select2/data/tokenizer", [
  2936. "jquery"
  2937. ], function($2) {
  2938. function Tokenizer(decorated, $element, options) {
  2939. var tokenizer = options.get("tokenizer");
  2940. if (tokenizer !== void 0) {
  2941. this.tokenizer = tokenizer;
  2942. }
  2943. decorated.call(this, $element, options);
  2944. }
  2945. Tokenizer.prototype.bind = function(decorated, container, $container) {
  2946. decorated.call(this, container, $container);
  2947. this.$search = container.dropdown.$search || container.selection.$search || $container.find(".select2-search__field");
  2948. };
  2949. Tokenizer.prototype.query = function(decorated, params, callback) {
  2950. var self = this;
  2951. function createAndSelect(data) {
  2952. var item = self._normalizeItem(data);
  2953. var $existingOptions = self.$element.find("option").filter(function() {
  2954. return $2(this).val() === item.id;
  2955. });
  2956. if (!$existingOptions.length) {
  2957. var $option = self.option(item);
  2958. $option.attr("data-select2-tag", true);
  2959. self._removeOldTags();
  2960. self.addOptions([$option]);
  2961. }
  2962. select(item);
  2963. }
  2964. function select(data) {
  2965. self.trigger("select", {
  2966. data
  2967. });
  2968. }
  2969. params.term = params.term || "";
  2970. var tokenData = this.tokenizer(params, this.options, createAndSelect);
  2971. if (tokenData.term !== params.term) {
  2972. if (this.$search.length) {
  2973. this.$search.val(tokenData.term);
  2974. this.$search.trigger("focus");
  2975. }
  2976. params.term = tokenData.term;
  2977. }
  2978. decorated.call(this, params, callback);
  2979. };
  2980. Tokenizer.prototype.tokenizer = function(_, params, options, callback) {
  2981. var separators = options.get("tokenSeparators") || [];
  2982. var term = params.term;
  2983. var i = 0;
  2984. var createTag = this.createTag || function(params2) {
  2985. return {
  2986. id: params2.term,
  2987. text: params2.term
  2988. };
  2989. };
  2990. while (i < term.length) {
  2991. var termChar = term[i];
  2992. if (separators.indexOf(termChar) === -1) {
  2993. i++;
  2994. continue;
  2995. }
  2996. var part = term.substr(0, i);
  2997. var partParams = $2.extend({}, params, {
  2998. term: part
  2999. });
  3000. var data = createTag(partParams);
  3001. if (data == null) {
  3002. i++;
  3003. continue;
  3004. }
  3005. callback(data);
  3006. term = term.substr(i + 1) || "";
  3007. i = 0;
  3008. }
  3009. return {
  3010. term
  3011. };
  3012. };
  3013. return Tokenizer;
  3014. });
  3015. S22.define("select2/data/minimumInputLength", [], function() {
  3016. function MinimumInputLength(decorated, $e, options) {
  3017. this.minimumInputLength = options.get("minimumInputLength");
  3018. decorated.call(this, $e, options);
  3019. }
  3020. MinimumInputLength.prototype.query = function(decorated, params, callback) {
  3021. params.term = params.term || "";
  3022. if (params.term.length < this.minimumInputLength) {
  3023. this.trigger("results:message", {
  3024. message: "inputTooShort",
  3025. args: {
  3026. minimum: this.minimumInputLength,
  3027. input: params.term,
  3028. params
  3029. }
  3030. });
  3031. return;
  3032. }
  3033. decorated.call(this, params, callback);
  3034. };
  3035. return MinimumInputLength;
  3036. });
  3037. S22.define("select2/data/maximumInputLength", [], function() {
  3038. function MaximumInputLength(decorated, $e, options) {
  3039. this.maximumInputLength = options.get("maximumInputLength");
  3040. decorated.call(this, $e, options);
  3041. }
  3042. MaximumInputLength.prototype.query = function(decorated, params, callback) {
  3043. params.term = params.term || "";
  3044. if (this.maximumInputLength > 0 && params.term.length > this.maximumInputLength) {
  3045. this.trigger("results:message", {
  3046. message: "inputTooLong",
  3047. args: {
  3048. maximum: this.maximumInputLength,
  3049. input: params.term,
  3050. params
  3051. }
  3052. });
  3053. return;
  3054. }
  3055. decorated.call(this, params, callback);
  3056. };
  3057. return MaximumInputLength;
  3058. });
  3059. S22.define("select2/data/maximumSelectionLength", [], function() {
  3060. function MaximumSelectionLength(decorated, $e, options) {
  3061. this.maximumSelectionLength = options.get("maximumSelectionLength");
  3062. decorated.call(this, $e, options);
  3063. }
  3064. MaximumSelectionLength.prototype.bind = function(decorated, container, $container) {
  3065. var self = this;
  3066. decorated.call(this, container, $container);
  3067. container.on("select", function() {
  3068. self._checkIfMaximumSelected();
  3069. });
  3070. };
  3071. MaximumSelectionLength.prototype.query = function(decorated, params, callback) {
  3072. var self = this;
  3073. this._checkIfMaximumSelected(function() {
  3074. decorated.call(self, params, callback);
  3075. });
  3076. };
  3077. MaximumSelectionLength.prototype._checkIfMaximumSelected = function(_, successCallback) {
  3078. var self = this;
  3079. this.current(function(currentData) {
  3080. var count = currentData != null ? currentData.length : 0;
  3081. if (self.maximumSelectionLength > 0 && count >= self.maximumSelectionLength) {
  3082. self.trigger("results:message", {
  3083. message: "maximumSelected",
  3084. args: {
  3085. maximum: self.maximumSelectionLength
  3086. }
  3087. });
  3088. return;
  3089. }
  3090. if (successCallback) {
  3091. successCallback();
  3092. }
  3093. });
  3094. };
  3095. return MaximumSelectionLength;
  3096. });
  3097. S22.define("select2/dropdown", [
  3098. "jquery",
  3099. "./utils"
  3100. ], function($2, Utils) {
  3101. function Dropdown($element, options) {
  3102. this.$element = $element;
  3103. this.options = options;
  3104. Dropdown.__super__.constructor.call(this);
  3105. }
  3106. Utils.Extend(Dropdown, Utils.Observable);
  3107. Dropdown.prototype.render = function() {
  3108. var $dropdown = $2(
  3109. '<span class="select2-dropdown"><span class="select2-results"></span></span>'
  3110. );
  3111. $dropdown.attr("dir", this.options.get("dir"));
  3112. this.$dropdown = $dropdown;
  3113. return $dropdown;
  3114. };
  3115. Dropdown.prototype.bind = function() {
  3116. };
  3117. Dropdown.prototype.position = function($dropdown, $container) {
  3118. };
  3119. Dropdown.prototype.destroy = function() {
  3120. this.$dropdown.remove();
  3121. };
  3122. return Dropdown;
  3123. });
  3124. S22.define("select2/dropdown/search", [
  3125. "jquery"
  3126. ], function($2) {
  3127. function Search() {
  3128. }
  3129. Search.prototype.render = function(decorated) {
  3130. var $rendered = decorated.call(this);
  3131. var searchLabel = this.options.get("translations").get("search");
  3132. var $search = $2(
  3133. '<span class="select2-search select2-search--dropdown"><input class="select2-search__field" type="search" tabindex="-1" autocorrect="off" autocapitalize="none" spellcheck="false" role="searchbox" aria-autocomplete="list" /></span>'
  3134. );
  3135. this.$searchContainer = $search;
  3136. this.$search = $search.find("input");
  3137. this.$search.prop("autocomplete", this.options.get("autocomplete"));
  3138. this.$search.attr("aria-label", searchLabel());
  3139. $rendered.prepend($search);
  3140. return $rendered;
  3141. };
  3142. Search.prototype.bind = function(decorated, container, $container) {
  3143. var self = this;
  3144. var resultsId = container.id + "-results";
  3145. decorated.call(this, container, $container);
  3146. this.$search.on("keydown", function(evt) {
  3147. self.trigger("keypress", evt);
  3148. self._keyUpPrevented = evt.isDefaultPrevented();
  3149. });
  3150. this.$search.on("input", function(evt) {
  3151. $2(this).off("keyup");
  3152. });
  3153. this.$search.on("keyup input", function(evt) {
  3154. self.handleSearch(evt);
  3155. });
  3156. container.on("open", function() {
  3157. self.$search.attr("tabindex", 0);
  3158. self.$search.attr("aria-controls", resultsId);
  3159. self.$search.trigger("focus");
  3160. window.setTimeout(function() {
  3161. self.$search.trigger("focus");
  3162. }, 0);
  3163. });
  3164. container.on("close", function() {
  3165. self.$search.attr("tabindex", -1);
  3166. self.$search.removeAttr("aria-controls");
  3167. self.$search.removeAttr("aria-activedescendant");
  3168. self.$search.val("");
  3169. self.$search.trigger("blur");
  3170. });
  3171. container.on("focus", function() {
  3172. if (!container.isOpen()) {
  3173. self.$search.trigger("focus");
  3174. }
  3175. });
  3176. container.on("results:all", function(params) {
  3177. if (params.query.term == null || params.query.term === "") {
  3178. var showSearch = self.showSearch(params);
  3179. if (showSearch) {
  3180. self.$searchContainer[0].classList.remove("select2-search--hide");
  3181. } else {
  3182. self.$searchContainer[0].classList.add("select2-search--hide");
  3183. }
  3184. }
  3185. });
  3186. container.on("results:focus", function(params) {
  3187. if (params.data._resultId) {
  3188. self.$search.attr("aria-activedescendant", params.data._resultId);
  3189. } else {
  3190. self.$search.removeAttr("aria-activedescendant");
  3191. }
  3192. });
  3193. };
  3194. Search.prototype.handleSearch = function(evt) {
  3195. if (!this._keyUpPrevented) {
  3196. var input = this.$search.val();
  3197. this.trigger("query", {
  3198. term: input
  3199. });
  3200. }
  3201. this._keyUpPrevented = false;
  3202. };
  3203. Search.prototype.showSearch = function(_, params) {
  3204. return true;
  3205. };
  3206. return Search;
  3207. });
  3208. S22.define("select2/dropdown/hidePlaceholder", [], function() {
  3209. function HidePlaceholder(decorated, $element, options, dataAdapter) {
  3210. this.placeholder = this.normalizePlaceholder(options.get("placeholder"));
  3211. decorated.call(this, $element, options, dataAdapter);
  3212. }
  3213. HidePlaceholder.prototype.append = function(decorated, data) {
  3214. data.results = this.removePlaceholder(data.results);
  3215. decorated.call(this, data);
  3216. };
  3217. HidePlaceholder.prototype.normalizePlaceholder = function(_, placeholder) {
  3218. if (typeof placeholder === "string") {
  3219. placeholder = {
  3220. id: "",
  3221. text: placeholder
  3222. };
  3223. }
  3224. return placeholder;
  3225. };
  3226. HidePlaceholder.prototype.removePlaceholder = function(_, data) {
  3227. var modifiedData = data.slice(0);
  3228. for (var d = data.length - 1; d >= 0; d--) {
  3229. var item = data[d];
  3230. if (this.placeholder.id === item.id) {
  3231. modifiedData.splice(d, 1);
  3232. }
  3233. }
  3234. return modifiedData;
  3235. };
  3236. return HidePlaceholder;
  3237. });
  3238. S22.define("select2/dropdown/infiniteScroll", [
  3239. "jquery"
  3240. ], function($2) {
  3241. function InfiniteScroll(decorated, $element, options, dataAdapter) {
  3242. this.lastParams = {};
  3243. decorated.call(this, $element, options, dataAdapter);
  3244. this.$loadingMore = this.createLoadingMore();
  3245. this.loading = false;
  3246. }
  3247. InfiniteScroll.prototype.append = function(decorated, data) {
  3248. this.$loadingMore.remove();
  3249. this.loading = false;
  3250. decorated.call(this, data);
  3251. if (this.showLoadingMore(data)) {
  3252. this.$results.append(this.$loadingMore);
  3253. this.loadMoreIfNeeded();
  3254. }
  3255. };
  3256. InfiniteScroll.prototype.bind = function(decorated, container, $container) {
  3257. var self = this;
  3258. decorated.call(this, container, $container);
  3259. container.on("query", function(params) {
  3260. self.lastParams = params;
  3261. self.loading = true;
  3262. });
  3263. container.on("query:append", function(params) {
  3264. self.lastParams = params;
  3265. self.loading = true;
  3266. });
  3267. this.$results.on("scroll", this.loadMoreIfNeeded.bind(this));
  3268. };
  3269. InfiniteScroll.prototype.loadMoreIfNeeded = function() {
  3270. var isLoadMoreVisible = $2.contains(
  3271. document.documentElement,
  3272. this.$loadingMore[0]
  3273. );
  3274. if (this.loading || !isLoadMoreVisible) {
  3275. return;
  3276. }
  3277. var currentOffset = this.$results.offset().top + this.$results.outerHeight(false);
  3278. var loadingMoreOffset = this.$loadingMore.offset().top + this.$loadingMore.outerHeight(false);
  3279. if (currentOffset + 50 >= loadingMoreOffset) {
  3280. this.loadMore();
  3281. }
  3282. };
  3283. InfiniteScroll.prototype.loadMore = function() {
  3284. this.loading = true;
  3285. var params = $2.extend({}, { page: 1 }, this.lastParams);
  3286. params.page++;
  3287. this.trigger("query:append", params);
  3288. };
  3289. InfiniteScroll.prototype.showLoadingMore = function(_, data) {
  3290. return data.pagination && data.pagination.more;
  3291. };
  3292. InfiniteScroll.prototype.createLoadingMore = function() {
  3293. var $option = $2(
  3294. '<li class="select2-results__option select2-results__option--load-more"role="option" aria-disabled="true"></li>'
  3295. );
  3296. var message = this.options.get("translations").get("loadingMore");
  3297. $option.html(message(this.lastParams));
  3298. return $option;
  3299. };
  3300. return InfiniteScroll;
  3301. });
  3302. S22.define("select2/dropdown/attachBody", [
  3303. "jquery",
  3304. "../utils"
  3305. ], function($2, Utils) {
  3306. function AttachBody(decorated, $element, options) {
  3307. this.$dropdownParent = $2(options.get("dropdownParent") || document.body);
  3308. decorated.call(this, $element, options);
  3309. }
  3310. AttachBody.prototype.bind = function(decorated, container, $container) {
  3311. var self = this;
  3312. decorated.call(this, container, $container);
  3313. container.on("open", function() {
  3314. self._showDropdown();
  3315. self._attachPositioningHandler(container);
  3316. self._bindContainerResultHandlers(container);
  3317. });
  3318. container.on("close", function() {
  3319. self._hideDropdown();
  3320. self._detachPositioningHandler(container);
  3321. });
  3322. this.$dropdownContainer.on("mousedown", function(evt) {
  3323. evt.stopPropagation();
  3324. });
  3325. };
  3326. AttachBody.prototype.destroy = function(decorated) {
  3327. decorated.call(this);
  3328. this.$dropdownContainer.remove();
  3329. };
  3330. AttachBody.prototype.position = function(decorated, $dropdown, $container) {
  3331. $dropdown.attr("class", $container.attr("class"));
  3332. $dropdown[0].classList.remove("select2");
  3333. $dropdown[0].classList.add("select2-container--open");
  3334. $dropdown.css({
  3335. position: "absolute",
  3336. top: -999999
  3337. });
  3338. this.$container = $container;
  3339. };
  3340. AttachBody.prototype.render = function(decorated) {
  3341. var $container = $2("<span></span>");
  3342. var $dropdown = decorated.call(this);
  3343. $container.append($dropdown);
  3344. this.$dropdownContainer = $container;
  3345. return $container;
  3346. };
  3347. AttachBody.prototype._hideDropdown = function(decorated) {
  3348. this.$dropdownContainer.detach();
  3349. };
  3350. AttachBody.prototype._bindContainerResultHandlers = function(decorated, container) {
  3351. if (this._containerResultsHandlersBound) {
  3352. return;
  3353. }
  3354. var self = this;
  3355. container.on("results:all", function() {
  3356. self._positionDropdown();
  3357. self._resizeDropdown();
  3358. });
  3359. container.on("results:append", function() {
  3360. self._positionDropdown();
  3361. self._resizeDropdown();
  3362. });
  3363. container.on("results:message", function() {
  3364. self._positionDropdown();
  3365. self._resizeDropdown();
  3366. });
  3367. container.on("select", function() {
  3368. self._positionDropdown();
  3369. self._resizeDropdown();
  3370. });
  3371. container.on("unselect", function() {
  3372. self._positionDropdown();
  3373. self._resizeDropdown();
  3374. });
  3375. this._containerResultsHandlersBound = true;
  3376. };
  3377. AttachBody.prototype._attachPositioningHandler = function(decorated, container) {
  3378. var self = this;
  3379. var scrollEvent = "scroll.select2." + container.id;
  3380. var resizeEvent = "resize.select2." + container.id;
  3381. var orientationEvent = "orientationchange.select2." + container.id;
  3382. var $watchers = this.$container.parents().filter(Utils.hasScroll);
  3383. $watchers.each(function() {
  3384. Utils.StoreData(this, "select2-scroll-position", {
  3385. x: $2(this).scrollLeft(),
  3386. y: $2(this).scrollTop()
  3387. });
  3388. });
  3389. $watchers.on(scrollEvent, function(ev) {
  3390. var position = Utils.GetData(this, "select2-scroll-position");
  3391. $2(this).scrollTop(position.y);
  3392. });
  3393. $2(window).on(
  3394. scrollEvent + " " + resizeEvent + " " + orientationEvent,
  3395. function(e) {
  3396. self._positionDropdown();
  3397. self._resizeDropdown();
  3398. }
  3399. );
  3400. };
  3401. AttachBody.prototype._detachPositioningHandler = function(decorated, container) {
  3402. var scrollEvent = "scroll.select2." + container.id;
  3403. var resizeEvent = "resize.select2." + container.id;
  3404. var orientationEvent = "orientationchange.select2." + container.id;
  3405. var $watchers = this.$container.parents().filter(Utils.hasScroll);
  3406. $watchers.off(scrollEvent);
  3407. $2(window).off(scrollEvent + " " + resizeEvent + " " + orientationEvent);
  3408. };
  3409. AttachBody.prototype._positionDropdown = function() {
  3410. var $window = $2(window);
  3411. var isCurrentlyAbove = this.$dropdown[0].classList.contains("select2-dropdown--above");
  3412. var isCurrentlyBelow = this.$dropdown[0].classList.contains("select2-dropdown--below");
  3413. var newDirection = null;
  3414. var offset = this.$container.offset();
  3415. offset.bottom = offset.top + this.$container.outerHeight(false);
  3416. var container = {
  3417. height: this.$container.outerHeight(false)
  3418. };
  3419. container.top = offset.top;
  3420. container.bottom = offset.top + container.height;
  3421. var dropdown = {
  3422. height: this.$dropdown.outerHeight(false)
  3423. };
  3424. var viewport = {
  3425. top: $window.scrollTop(),
  3426. bottom: $window.scrollTop() + $window.height()
  3427. };
  3428. var enoughRoomAbove = viewport.top < offset.top - dropdown.height;
  3429. var enoughRoomBelow = viewport.bottom > offset.bottom + dropdown.height;
  3430. var css = {
  3431. left: offset.left,
  3432. top: container.bottom
  3433. };
  3434. var $offsetParent = this.$dropdownParent;
  3435. if ($offsetParent.css("position") === "static") {
  3436. $offsetParent = $offsetParent.offsetParent();
  3437. }
  3438. var parentOffset = {
  3439. top: 0,
  3440. left: 0
  3441. };
  3442. if ($2.contains(document.body, $offsetParent[0]) || $offsetParent[0].isConnected) {
  3443. parentOffset = $offsetParent.offset();
  3444. }
  3445. css.top -= parentOffset.top;
  3446. css.left -= parentOffset.left;
  3447. if (!isCurrentlyAbove && !isCurrentlyBelow) {
  3448. newDirection = "below";
  3449. }
  3450. if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) {
  3451. newDirection = "above";
  3452. } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) {
  3453. newDirection = "below";
  3454. }
  3455. if (newDirection == "above" || isCurrentlyAbove && newDirection !== "below") {
  3456. css.top = container.top - parentOffset.top - dropdown.height;
  3457. }
  3458. if (newDirection != null) {
  3459. this.$dropdown[0].classList.remove("select2-dropdown--below");
  3460. this.$dropdown[0].classList.remove("select2-dropdown--above");
  3461. this.$dropdown[0].classList.add("select2-dropdown--" + newDirection);
  3462. this.$container[0].classList.remove("select2-container--below");
  3463. this.$container[0].classList.remove("select2-container--above");
  3464. this.$container[0].classList.add("select2-container--" + newDirection);
  3465. }
  3466. this.$dropdownContainer.css(css);
  3467. };
  3468. AttachBody.prototype._resizeDropdown = function() {
  3469. var css = {
  3470. width: this.$container.outerWidth(false) + "px"
  3471. };
  3472. if (this.options.get("dropdownAutoWidth")) {
  3473. css.minWidth = css.width;
  3474. css.position = "relative";
  3475. css.width = "auto";
  3476. }
  3477. this.$dropdown.css(css);
  3478. };
  3479. AttachBody.prototype._showDropdown = function(decorated) {
  3480. this.$dropdownContainer.appendTo(this.$dropdownParent);
  3481. this._positionDropdown();
  3482. this._resizeDropdown();
  3483. };
  3484. return AttachBody;
  3485. });
  3486. S22.define("select2/dropdown/minimumResultsForSearch", [], function() {
  3487. function countResults(data) {
  3488. var count = 0;
  3489. for (var d = 0; d < data.length; d++) {
  3490. var item = data[d];
  3491. if (item.children) {
  3492. count += countResults(item.children);
  3493. } else {
  3494. count++;
  3495. }
  3496. }
  3497. return count;
  3498. }
  3499. function MinimumResultsForSearch(decorated, $element, options, dataAdapter) {
  3500. this.minimumResultsForSearch = options.get("minimumResultsForSearch");
  3501. if (this.minimumResultsForSearch < 0) {
  3502. this.minimumResultsForSearch = Infinity;
  3503. }
  3504. decorated.call(this, $element, options, dataAdapter);
  3505. }
  3506. MinimumResultsForSearch.prototype.showSearch = function(decorated, params) {
  3507. if (countResults(params.data.results) < this.minimumResultsForSearch) {
  3508. return false;
  3509. }
  3510. return decorated.call(this, params);
  3511. };
  3512. return MinimumResultsForSearch;
  3513. });
  3514. S22.define("select2/dropdown/selectOnClose", [
  3515. "../utils"
  3516. ], function(Utils) {
  3517. function SelectOnClose() {
  3518. }
  3519. SelectOnClose.prototype.bind = function(decorated, container, $container) {
  3520. var self = this;
  3521. decorated.call(this, container, $container);
  3522. container.on("close", function(params) {
  3523. self._handleSelectOnClose(params);
  3524. });
  3525. };
  3526. SelectOnClose.prototype._handleSelectOnClose = function(_, params) {
  3527. if (params && params.originalSelect2Event != null) {
  3528. var event = params.originalSelect2Event;
  3529. if (event._type === "select" || event._type === "unselect") {
  3530. return;
  3531. }
  3532. }
  3533. var $highlightedResults = this.getHighlightedResults();
  3534. if ($highlightedResults.length < 1) {
  3535. return;
  3536. }
  3537. var data = Utils.GetData($highlightedResults[0], "data");
  3538. if (data.element != null && data.element.selected || data.element == null && data.selected) {
  3539. return;
  3540. }
  3541. this.trigger("select", {
  3542. data
  3543. });
  3544. };
  3545. return SelectOnClose;
  3546. });
  3547. S22.define("select2/dropdown/closeOnSelect", [], function() {
  3548. function CloseOnSelect() {
  3549. }
  3550. CloseOnSelect.prototype.bind = function(decorated, container, $container) {
  3551. var self = this;
  3552. decorated.call(this, container, $container);
  3553. container.on("select", function(evt) {
  3554. self._selectTriggered(evt);
  3555. });
  3556. container.on("unselect", function(evt) {
  3557. self._selectTriggered(evt);
  3558. });
  3559. };
  3560. CloseOnSelect.prototype._selectTriggered = function(_, evt) {
  3561. var originalEvent = evt.originalEvent;
  3562. if (originalEvent && (originalEvent.ctrlKey || originalEvent.metaKey)) {
  3563. return;
  3564. }
  3565. this.trigger("close", {
  3566. originalEvent,
  3567. originalSelect2Event: evt
  3568. });
  3569. };
  3570. return CloseOnSelect;
  3571. });
  3572. S22.define("select2/dropdown/dropdownCss", [
  3573. "../utils"
  3574. ], function(Utils) {
  3575. function DropdownCSS() {
  3576. }
  3577. DropdownCSS.prototype.render = function(decorated) {
  3578. var $dropdown = decorated.call(this);
  3579. var dropdownCssClass = this.options.get("dropdownCssClass") || "";
  3580. if (dropdownCssClass.indexOf(":all:") !== -1) {
  3581. dropdownCssClass = dropdownCssClass.replace(":all:", "");
  3582. Utils.copyNonInternalCssClasses($dropdown[0], this.$element[0]);
  3583. }
  3584. $dropdown.addClass(dropdownCssClass);
  3585. return $dropdown;
  3586. };
  3587. return DropdownCSS;
  3588. });
  3589. S22.define("select2/dropdown/tagsSearchHighlight", [
  3590. "../utils"
  3591. ], function(Utils) {
  3592. function TagsSearchHighlight() {
  3593. }
  3594. TagsSearchHighlight.prototype.highlightFirstItem = function(decorated) {
  3595. var $options = this.$results.find(
  3596. ".select2-results__option--selectable:not(.select2-results__option--selected)"
  3597. );
  3598. if ($options.length > 0) {
  3599. var $firstOption = $options.first();
  3600. var data = Utils.GetData($firstOption[0], "data");
  3601. var firstElement = data.element;
  3602. if (firstElement && firstElement.getAttribute) {
  3603. if (firstElement.getAttribute("data-select2-tag") === "true") {
  3604. $firstOption.trigger("mouseenter");
  3605. return;
  3606. }
  3607. }
  3608. }
  3609. decorated.call(this);
  3610. };
  3611. return TagsSearchHighlight;
  3612. });
  3613. S22.define("select2/i18n/en", [], function() {
  3614. return {
  3615. errorLoading: function() {
  3616. return "The results could not be loaded.";
  3617. },
  3618. inputTooLong: function(args) {
  3619. var overChars = args.input.length - args.maximum;
  3620. var message = "Please delete " + overChars + " character";
  3621. if (overChars != 1) {
  3622. message += "s";
  3623. }
  3624. return message;
  3625. },
  3626. inputTooShort: function(args) {
  3627. var remainingChars = args.minimum - args.input.length;
  3628. var message = "Please enter " + remainingChars + " or more characters";
  3629. return message;
  3630. },
  3631. loadingMore: function() {
  3632. return "Loading more results…";
  3633. },
  3634. maximumSelected: function(args) {
  3635. var message = "You can only select " + args.maximum + " item";
  3636. if (args.maximum != 1) {
  3637. message += "s";
  3638. }
  3639. return message;
  3640. },
  3641. noResults: function() {
  3642. return "No results found";
  3643. },
  3644. searching: function() {
  3645. return "Searching…";
  3646. },
  3647. removeAllItems: function() {
  3648. return "Remove all items";
  3649. },
  3650. removeItem: function() {
  3651. return "Remove item";
  3652. },
  3653. search: function() {
  3654. return "Search";
  3655. }
  3656. };
  3657. });
  3658. S22.define("select2/defaults", [
  3659. "jquery",
  3660. "./results",
  3661. "./selection/single",
  3662. "./selection/multiple",
  3663. "./selection/placeholder",
  3664. "./selection/allowClear",
  3665. "./selection/search",
  3666. "./selection/selectionCss",
  3667. "./selection/eventRelay",
  3668. "./utils",
  3669. "./translation",
  3670. "./diacritics",
  3671. "./data/select",
  3672. "./data/array",
  3673. "./data/ajax",
  3674. "./data/tags",
  3675. "./data/tokenizer",
  3676. "./data/minimumInputLength",
  3677. "./data/maximumInputLength",
  3678. "./data/maximumSelectionLength",
  3679. "./dropdown",
  3680. "./dropdown/search",
  3681. "./dropdown/hidePlaceholder",
  3682. "./dropdown/infiniteScroll",
  3683. "./dropdown/attachBody",
  3684. "./dropdown/minimumResultsForSearch",
  3685. "./dropdown/selectOnClose",
  3686. "./dropdown/closeOnSelect",
  3687. "./dropdown/dropdownCss",
  3688. "./dropdown/tagsSearchHighlight",
  3689. "./i18n/en"
  3690. ], function($2, ResultsList, SingleSelection, MultipleSelection, Placeholder, AllowClear, SelectionSearch, SelectionCSS, EventRelay, Utils, Translation, DIACRITICS, SelectData, ArrayData, AjaxData, Tags, Tokenizer, MinimumInputLength, MaximumInputLength, MaximumSelectionLength, Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll, AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect, DropdownCSS, TagsSearchHighlight, EnglishTranslation) {
  3691. function Defaults() {
  3692. this.reset();
  3693. }
  3694. Defaults.prototype.apply = function(options) {
  3695. options = $2.extend(true, {}, this.defaults, options);
  3696. if (options.dataAdapter == null) {
  3697. if (options.ajax != null) {
  3698. options.dataAdapter = AjaxData;
  3699. } else if (options.data != null) {
  3700. options.dataAdapter = ArrayData;
  3701. } else {
  3702. options.dataAdapter = SelectData;
  3703. }
  3704. if (options.minimumInputLength > 0) {
  3705. options.dataAdapter = Utils.Decorate(
  3706. options.dataAdapter,
  3707. MinimumInputLength
  3708. );
  3709. }
  3710. if (options.maximumInputLength > 0) {
  3711. options.dataAdapter = Utils.Decorate(
  3712. options.dataAdapter,
  3713. MaximumInputLength
  3714. );
  3715. }
  3716. if (options.maximumSelectionLength > 0) {
  3717. options.dataAdapter = Utils.Decorate(
  3718. options.dataAdapter,
  3719. MaximumSelectionLength
  3720. );
  3721. }
  3722. if (options.tags) {
  3723. options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags);
  3724. }
  3725. if (options.tokenSeparators != null || options.tokenizer != null) {
  3726. options.dataAdapter = Utils.Decorate(
  3727. options.dataAdapter,
  3728. Tokenizer
  3729. );
  3730. }
  3731. }
  3732. if (options.resultsAdapter == null) {
  3733. options.resultsAdapter = ResultsList;
  3734. if (options.ajax != null) {
  3735. options.resultsAdapter = Utils.Decorate(
  3736. options.resultsAdapter,
  3737. InfiniteScroll
  3738. );
  3739. }
  3740. if (options.placeholder != null) {
  3741. options.resultsAdapter = Utils.Decorate(
  3742. options.resultsAdapter,
  3743. HidePlaceholder
  3744. );
  3745. }
  3746. if (options.selectOnClose) {
  3747. options.resultsAdapter = Utils.Decorate(
  3748. options.resultsAdapter,
  3749. SelectOnClose
  3750. );
  3751. }
  3752. if (options.tags) {
  3753. options.resultsAdapter = Utils.Decorate(
  3754. options.resultsAdapter,
  3755. TagsSearchHighlight
  3756. );
  3757. }
  3758. }
  3759. if (options.dropdownAdapter == null) {
  3760. if (options.multiple) {
  3761. options.dropdownAdapter = Dropdown;
  3762. } else {
  3763. var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch);
  3764. options.dropdownAdapter = SearchableDropdown;
  3765. }
  3766. if (options.minimumResultsForSearch !== 0) {
  3767. options.dropdownAdapter = Utils.Decorate(
  3768. options.dropdownAdapter,
  3769. MinimumResultsForSearch
  3770. );
  3771. }
  3772. if (options.closeOnSelect) {
  3773. options.dropdownAdapter = Utils.Decorate(
  3774. options.dropdownAdapter,
  3775. CloseOnSelect
  3776. );
  3777. }
  3778. if (options.dropdownCssClass != null) {
  3779. options.dropdownAdapter = Utils.Decorate(
  3780. options.dropdownAdapter,
  3781. DropdownCSS
  3782. );
  3783. }
  3784. options.dropdownAdapter = Utils.Decorate(
  3785. options.dropdownAdapter,
  3786. AttachBody
  3787. );
  3788. }
  3789. if (options.selectionAdapter == null) {
  3790. if (options.multiple) {
  3791. options.selectionAdapter = MultipleSelection;
  3792. } else {
  3793. options.selectionAdapter = SingleSelection;
  3794. }
  3795. if (options.placeholder != null) {
  3796. options.selectionAdapter = Utils.Decorate(
  3797. options.selectionAdapter,
  3798. Placeholder
  3799. );
  3800. }
  3801. if (options.allowClear) {
  3802. options.selectionAdapter = Utils.Decorate(
  3803. options.selectionAdapter,
  3804. AllowClear
  3805. );
  3806. }
  3807. if (options.multiple) {
  3808. options.selectionAdapter = Utils.Decorate(
  3809. options.selectionAdapter,
  3810. SelectionSearch
  3811. );
  3812. }
  3813. if (options.selectionCssClass != null) {
  3814. options.selectionAdapter = Utils.Decorate(
  3815. options.selectionAdapter,
  3816. SelectionCSS
  3817. );
  3818. }
  3819. options.selectionAdapter = Utils.Decorate(
  3820. options.selectionAdapter,
  3821. EventRelay
  3822. );
  3823. }
  3824. options.language = this._resolveLanguage(options.language);
  3825. options.language.push("en");
  3826. var uniqueLanguages = [];
  3827. for (var l = 0; l < options.language.length; l++) {
  3828. var language = options.language[l];
  3829. if (uniqueLanguages.indexOf(language) === -1) {
  3830. uniqueLanguages.push(language);
  3831. }
  3832. }
  3833. options.language = uniqueLanguages;
  3834. options.translations = this._processTranslations(
  3835. options.language,
  3836. options.debug
  3837. );
  3838. return options;
  3839. };
  3840. Defaults.prototype.reset = function() {
  3841. function stripDiacritics(text) {
  3842. function match(a) {
  3843. return DIACRITICS[a] || a;
  3844. }
  3845. return text.replace(/[^\u0000-\u007E]/g, match);
  3846. }
  3847. function matcher(params, data) {
  3848. if (params.term == null || params.term.trim() === "") {
  3849. return data;
  3850. }
  3851. if (data.children && data.children.length > 0) {
  3852. var match = $2.extend(true, {}, data);
  3853. for (var c = data.children.length - 1; c >= 0; c--) {
  3854. var child = data.children[c];
  3855. var matches = matcher(params, child);
  3856. if (matches == null) {
  3857. match.children.splice(c, 1);
  3858. }
  3859. }
  3860. if (match.children.length > 0) {
  3861. return match;
  3862. }
  3863. return matcher(params, match);
  3864. }
  3865. var original = stripDiacritics(data.text).toUpperCase();
  3866. var term = stripDiacritics(params.term).toUpperCase();
  3867. if (original.indexOf(term) > -1) {
  3868. return data;
  3869. }
  3870. return null;
  3871. }
  3872. this.defaults = {
  3873. amdLanguageBase: "./i18n/",
  3874. autocomplete: "off",
  3875. closeOnSelect: true,
  3876. debug: false,
  3877. dropdownAutoWidth: false,
  3878. escapeMarkup: Utils.escapeMarkup,
  3879. language: {},
  3880. matcher,
  3881. minimumInputLength: 0,
  3882. maximumInputLength: 0,
  3883. maximumSelectionLength: 0,
  3884. minimumResultsForSearch: 0,
  3885. selectOnClose: false,
  3886. scrollAfterSelect: false,
  3887. sorter: function(data) {
  3888. return data;
  3889. },
  3890. templateResult: function(result) {
  3891. return result.text;
  3892. },
  3893. templateSelection: function(selection) {
  3894. return selection.text;
  3895. },
  3896. theme: "default",
  3897. width: "resolve"
  3898. };
  3899. };
  3900. Defaults.prototype.applyFromElement = function(options, $element) {
  3901. var optionLanguage = options.language;
  3902. var defaultLanguage = this.defaults.language;
  3903. var elementLanguage = $element.prop("lang");
  3904. var parentLanguage = $element.closest("[lang]").prop("lang");
  3905. var languages = Array.prototype.concat.call(
  3906. this._resolveLanguage(elementLanguage),
  3907. this._resolveLanguage(optionLanguage),
  3908. this._resolveLanguage(defaultLanguage),
  3909. this._resolveLanguage(parentLanguage)
  3910. );
  3911. options.language = languages;
  3912. return options;
  3913. };
  3914. Defaults.prototype._resolveLanguage = function(language) {
  3915. if (!language) {
  3916. return [];
  3917. }
  3918. if ($2.isEmptyObject(language)) {
  3919. return [];
  3920. }
  3921. if ($2.isPlainObject(language)) {
  3922. return [language];
  3923. }
  3924. var languages;
  3925. if (!Array.isArray(language)) {
  3926. languages = [language];
  3927. } else {
  3928. languages = language;
  3929. }
  3930. var resolvedLanguages = [];
  3931. for (var l = 0; l < languages.length; l++) {
  3932. resolvedLanguages.push(languages[l]);
  3933. if (typeof languages[l] === "string" && languages[l].indexOf("-") > 0) {
  3934. var languageParts = languages[l].split("-");
  3935. var baseLanguage = languageParts[0];
  3936. resolvedLanguages.push(baseLanguage);
  3937. }
  3938. }
  3939. return resolvedLanguages;
  3940. };
  3941. Defaults.prototype._processTranslations = function(languages, debug) {
  3942. var translations = new Translation();
  3943. for (var l = 0; l < languages.length; l++) {
  3944. var languageData = new Translation();
  3945. var language = languages[l];
  3946. if (typeof language === "string") {
  3947. try {
  3948. languageData = Translation.loadPath(language);
  3949. } catch (e) {
  3950. try {
  3951. language = this.defaults.amdLanguageBase + language;
  3952. languageData = Translation.loadPath(language);
  3953. } catch (ex) {
  3954. if (debug && window.console && console.warn) {
  3955. console.warn(
  3956. 'Select2: The language file for "' + language + '" could not be automatically loaded. A fallback will be used instead.'
  3957. );
  3958. }
  3959. }
  3960. }
  3961. } else if ($2.isPlainObject(language)) {
  3962. languageData = new Translation(language);
  3963. } else {
  3964. languageData = language;
  3965. }
  3966. translations.extend(languageData);
  3967. }
  3968. return translations;
  3969. };
  3970. Defaults.prototype.set = function(key, value) {
  3971. var camelKey = $2.camelCase(key);
  3972. var data = {};
  3973. data[camelKey] = value;
  3974. var convertedData = Utils._convertData(data);
  3975. $2.extend(true, this.defaults, convertedData);
  3976. };
  3977. var defaults = new Defaults();
  3978. return defaults;
  3979. });
  3980. S22.define("select2/options", [
  3981. "jquery",
  3982. "./defaults",
  3983. "./utils"
  3984. ], function($2, Defaults, Utils) {
  3985. function Options(options, $element) {
  3986. this.options = options;
  3987. if ($element != null) {
  3988. this.fromElement($element);
  3989. }
  3990. if ($element != null) {
  3991. this.options = Defaults.applyFromElement(this.options, $element);
  3992. }
  3993. this.options = Defaults.apply(this.options);
  3994. }
  3995. Options.prototype.fromElement = function($e) {
  3996. var excludedData = ["select2"];
  3997. if (this.options.multiple == null) {
  3998. this.options.multiple = $e.prop("multiple");
  3999. }
  4000. if (this.options.disabled == null) {
  4001. this.options.disabled = $e.prop("disabled");
  4002. }
  4003. if (this.options.autocomplete == null && $e.prop("autocomplete")) {
  4004. this.options.autocomplete = $e.prop("autocomplete");
  4005. }
  4006. if (this.options.dir == null) {
  4007. if ($e.prop("dir")) {
  4008. this.options.dir = $e.prop("dir");
  4009. } else if ($e.closest("[dir]").prop("dir")) {
  4010. this.options.dir = $e.closest("[dir]").prop("dir");
  4011. } else {
  4012. this.options.dir = "ltr";
  4013. }
  4014. }
  4015. $e.prop("disabled", this.options.disabled);
  4016. $e.prop("multiple", this.options.multiple);
  4017. if (Utils.GetData($e[0], "select2Tags")) {
  4018. if (this.options.debug && window.console && console.warn) {
  4019. console.warn(
  4020. 'Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'
  4021. );
  4022. }
  4023. Utils.StoreData($e[0], "data", Utils.GetData($e[0], "select2Tags"));
  4024. Utils.StoreData($e[0], "tags", true);
  4025. }
  4026. if (Utils.GetData($e[0], "ajaxUrl")) {
  4027. if (this.options.debug && window.console && console.warn) {
  4028. console.warn(
  4029. "Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."
  4030. );
  4031. }
  4032. $e.attr("ajax--url", Utils.GetData($e[0], "ajaxUrl"));
  4033. Utils.StoreData($e[0], "ajax-Url", Utils.GetData($e[0], "ajaxUrl"));
  4034. }
  4035. var dataset = {};
  4036. function upperCaseLetter(_, letter) {
  4037. return letter.toUpperCase();
  4038. }
  4039. for (var attr = 0; attr < $e[0].attributes.length; attr++) {
  4040. var attributeName = $e[0].attributes[attr].name;
  4041. var prefix = "data-";
  4042. if (attributeName.substr(0, prefix.length) == prefix) {
  4043. var dataName = attributeName.substring(prefix.length);
  4044. var dataValue = Utils.GetData($e[0], dataName);
  4045. var camelDataName = dataName.replace(/-([a-z])/g, upperCaseLetter);
  4046. dataset[camelDataName] = dataValue;
  4047. }
  4048. }
  4049. if ($2.fn.jquery && $2.fn.jquery.substr(0, 2) == "1." && $e[0].dataset) {
  4050. dataset = $2.extend(true, {}, $e[0].dataset, dataset);
  4051. }
  4052. var data = $2.extend(true, {}, Utils.GetData($e[0]), dataset);
  4053. data = Utils._convertData(data);
  4054. for (var key in data) {
  4055. if (excludedData.indexOf(key) > -1) {
  4056. continue;
  4057. }
  4058. if ($2.isPlainObject(this.options[key])) {
  4059. $2.extend(this.options[key], data[key]);
  4060. } else {
  4061. this.options[key] = data[key];
  4062. }
  4063. }
  4064. return this;
  4065. };
  4066. Options.prototype.get = function(key) {
  4067. return this.options[key];
  4068. };
  4069. Options.prototype.set = function(key, val) {
  4070. this.options[key] = val;
  4071. };
  4072. return Options;
  4073. });
  4074. S22.define("select2/core", [
  4075. "jquery",
  4076. "./options",
  4077. "./utils",
  4078. "./keys"
  4079. ], function($2, Options, Utils, KEYS) {
  4080. var Select2 = function($element, options) {
  4081. if (Utils.GetData($element[0], "select2") != null) {
  4082. Utils.GetData($element[0], "select2").destroy();
  4083. }
  4084. this.$element = $element;
  4085. this.id = this._generateId($element);
  4086. options = options || {};
  4087. this.options = new Options(options, $element);
  4088. Select2.__super__.constructor.call(this);
  4089. var tabindex = $element.attr("tabindex") || 0;
  4090. Utils.StoreData($element[0], "old-tabindex", tabindex);
  4091. $element.attr("tabindex", "-1");
  4092. var DataAdapter = this.options.get("dataAdapter");
  4093. this.dataAdapter = new DataAdapter($element, this.options);
  4094. var $container = this.render();
  4095. this._placeContainer($container);
  4096. var SelectionAdapter = this.options.get("selectionAdapter");
  4097. this.selection = new SelectionAdapter($element, this.options);
  4098. this.$selection = this.selection.render();
  4099. this.selection.position(this.$selection, $container);
  4100. var DropdownAdapter = this.options.get("dropdownAdapter");
  4101. this.dropdown = new DropdownAdapter($element, this.options);
  4102. this.$dropdown = this.dropdown.render();
  4103. this.dropdown.position(this.$dropdown, $container);
  4104. var ResultsAdapter = this.options.get("resultsAdapter");
  4105. this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
  4106. this.$results = this.results.render();
  4107. this.results.position(this.$results, this.$dropdown);
  4108. var self = this;
  4109. this._bindAdapters();
  4110. this._registerDomEvents();
  4111. this._registerDataEvents();
  4112. this._registerSelectionEvents();
  4113. this._registerDropdownEvents();
  4114. this._registerResultsEvents();
  4115. this._registerEvents();
  4116. this.dataAdapter.current(function(initialData) {
  4117. self.trigger("selection:update", {
  4118. data: initialData
  4119. });
  4120. });
  4121. $element[0].classList.add("select2-hidden-accessible");
  4122. $element.attr("aria-hidden", "true");
  4123. this._syncAttributes();
  4124. Utils.StoreData($element[0], "select2", this);
  4125. $element.data("select2", this);
  4126. };
  4127. Utils.Extend(Select2, Utils.Observable);
  4128. Select2.prototype._generateId = function($element) {
  4129. var id = "";
  4130. if ($element.attr("id") != null) {
  4131. id = $element.attr("id");
  4132. } else if ($element.attr("name") != null) {
  4133. id = $element.attr("name") + "-" + Utils.generateChars(2);
  4134. } else {
  4135. id = Utils.generateChars(4);
  4136. }
  4137. id = id.replace(/(:|\.|\[|\]|,)/g, "");
  4138. id = "select2-" + id;
  4139. return id;
  4140. };
  4141. Select2.prototype._placeContainer = function($container) {
  4142. $container.insertAfter(this.$element);
  4143. var width = this._resolveWidth(this.$element, this.options.get("width"));
  4144. if (width != null) {
  4145. $container.css("width", width);
  4146. }
  4147. };
  4148. Select2.prototype._resolveWidth = function($element, method) {
  4149. var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;
  4150. if (method == "resolve") {
  4151. var styleWidth = this._resolveWidth($element, "style");
  4152. if (styleWidth != null) {
  4153. return styleWidth;
  4154. }
  4155. return this._resolveWidth($element, "element");
  4156. }
  4157. if (method == "element") {
  4158. var elementWidth = $element.outerWidth(false);
  4159. if (elementWidth <= 0) {
  4160. return "auto";
  4161. }
  4162. return elementWidth + "px";
  4163. }
  4164. if (method == "style") {
  4165. var style = $element.attr("style");
  4166. if (typeof style !== "string") {
  4167. return null;
  4168. }
  4169. var attrs = style.split(";");
  4170. for (var i = 0, l = attrs.length; i < l; i = i + 1) {
  4171. var attr = attrs[i].replace(/\s/g, "");
  4172. var matches = attr.match(WIDTH);
  4173. if (matches !== null && matches.length >= 1) {
  4174. return matches[1];
  4175. }
  4176. }
  4177. return null;
  4178. }
  4179. if (method == "computedstyle") {
  4180. var computedStyle = window.getComputedStyle($element[0]);
  4181. return computedStyle.width;
  4182. }
  4183. return method;
  4184. };
  4185. Select2.prototype._bindAdapters = function() {
  4186. this.dataAdapter.bind(this, this.$container);
  4187. this.selection.bind(this, this.$container);
  4188. this.dropdown.bind(this, this.$container);
  4189. this.results.bind(this, this.$container);
  4190. };
  4191. Select2.prototype._registerDomEvents = function() {
  4192. var self = this;
  4193. this.$element.on("change.select2", function() {
  4194. self.dataAdapter.current(function(data) {
  4195. self.trigger("selection:update", {
  4196. data
  4197. });
  4198. });
  4199. });
  4200. this.$element.on("focus.select2", function(evt) {
  4201. self.trigger("focus", evt);
  4202. });
  4203. this._syncA = Utils.bind(this._syncAttributes, this);
  4204. this._syncS = Utils.bind(this._syncSubtree, this);
  4205. this._observer = new window.MutationObserver(function(mutations) {
  4206. self._syncA();
  4207. self._syncS(mutations);
  4208. });
  4209. this._observer.observe(this.$element[0], {
  4210. attributes: true,
  4211. childList: true,
  4212. subtree: false
  4213. });
  4214. };
  4215. Select2.prototype._registerDataEvents = function() {
  4216. var self = this;
  4217. this.dataAdapter.on("*", function(name, params) {
  4218. self.trigger(name, params);
  4219. });
  4220. };
  4221. Select2.prototype._registerSelectionEvents = function() {
  4222. var self = this;
  4223. var nonRelayEvents = ["toggle", "focus"];
  4224. this.selection.on("toggle", function() {
  4225. self.toggleDropdown();
  4226. });
  4227. this.selection.on("focus", function(params) {
  4228. self.focus(params);
  4229. });
  4230. this.selection.on("*", function(name, params) {
  4231. if (nonRelayEvents.indexOf(name) !== -1) {
  4232. return;
  4233. }
  4234. self.trigger(name, params);
  4235. });
  4236. };
  4237. Select2.prototype._registerDropdownEvents = function() {
  4238. var self = this;
  4239. this.dropdown.on("*", function(name, params) {
  4240. self.trigger(name, params);
  4241. });
  4242. };
  4243. Select2.prototype._registerResultsEvents = function() {
  4244. var self = this;
  4245. this.results.on("*", function(name, params) {
  4246. self.trigger(name, params);
  4247. });
  4248. };
  4249. Select2.prototype._registerEvents = function() {
  4250. var self = this;
  4251. this.on("open", function() {
  4252. self.$container[0].classList.add("select2-container--open");
  4253. });
  4254. this.on("close", function() {
  4255. self.$container[0].classList.remove("select2-container--open");
  4256. });
  4257. this.on("enable", function() {
  4258. self.$container[0].classList.remove("select2-container--disabled");
  4259. });
  4260. this.on("disable", function() {
  4261. self.$container[0].classList.add("select2-container--disabled");
  4262. });
  4263. this.on("blur", function() {
  4264. self.$container[0].classList.remove("select2-container--focus");
  4265. });
  4266. this.on("query", function(params) {
  4267. if (!self.isOpen()) {
  4268. self.trigger("open", {});
  4269. }
  4270. this.dataAdapter.query(params, function(data) {
  4271. self.trigger("results:all", {
  4272. data,
  4273. query: params
  4274. });
  4275. });
  4276. });
  4277. this.on("query:append", function(params) {
  4278. this.dataAdapter.query(params, function(data) {
  4279. self.trigger("results:append", {
  4280. data,
  4281. query: params
  4282. });
  4283. });
  4284. });
  4285. this.on("keypress", function(evt) {
  4286. var key = evt.which;
  4287. if (self.isOpen()) {
  4288. if (key === KEYS.ESC || key === KEYS.UP && evt.altKey) {
  4289. self.close(evt);
  4290. evt.preventDefault();
  4291. } else if (key === KEYS.ENTER || key === KEYS.TAB) {
  4292. self.trigger("results:select", {});
  4293. evt.preventDefault();
  4294. } else if (key === KEYS.SPACE && evt.ctrlKey) {
  4295. self.trigger("results:toggle", {});
  4296. evt.preventDefault();
  4297. } else if (key === KEYS.UP) {
  4298. self.trigger("results:previous", {});
  4299. evt.preventDefault();
  4300. } else if (key === KEYS.DOWN) {
  4301. self.trigger("results:next", {});
  4302. evt.preventDefault();
  4303. }
  4304. } else {
  4305. if (key === KEYS.ENTER || key === KEYS.SPACE || key === KEYS.DOWN && evt.altKey) {
  4306. self.open();
  4307. evt.preventDefault();
  4308. }
  4309. }
  4310. });
  4311. };
  4312. Select2.prototype._syncAttributes = function() {
  4313. this.options.set("disabled", this.$element.prop("disabled"));
  4314. if (this.isDisabled()) {
  4315. if (this.isOpen()) {
  4316. this.close();
  4317. }
  4318. this.trigger("disable", {});
  4319. } else {
  4320. this.trigger("enable", {});
  4321. }
  4322. };
  4323. Select2.prototype._isChangeMutation = function(mutations) {
  4324. var self = this;
  4325. if (mutations.addedNodes && mutations.addedNodes.length > 0) {
  4326. for (var n = 0; n < mutations.addedNodes.length; n++) {
  4327. var node = mutations.addedNodes[n];
  4328. if (node.selected) {
  4329. return true;
  4330. }
  4331. }
  4332. } else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
  4333. return true;
  4334. } else if (Array.isArray(mutations)) {
  4335. return mutations.some(function(mutation) {
  4336. return self._isChangeMutation(mutation);
  4337. });
  4338. }
  4339. return false;
  4340. };
  4341. Select2.prototype._syncSubtree = function(mutations) {
  4342. var changed = this._isChangeMutation(mutations);
  4343. var self = this;
  4344. if (changed) {
  4345. this.dataAdapter.current(function(currentData) {
  4346. self.trigger("selection:update", {
  4347. data: currentData
  4348. });
  4349. });
  4350. }
  4351. };
  4352. Select2.prototype.trigger = function(name, args) {
  4353. var actualTrigger = Select2.__super__.trigger;
  4354. var preTriggerMap = {
  4355. "open": "opening",
  4356. "close": "closing",
  4357. "select": "selecting",
  4358. "unselect": "unselecting",
  4359. "clear": "clearing"
  4360. };
  4361. if (args === void 0) {
  4362. args = {};
  4363. }
  4364. if (name in preTriggerMap) {
  4365. var preTriggerName = preTriggerMap[name];
  4366. var preTriggerArgs = {
  4367. prevented: false,
  4368. name,
  4369. args
  4370. };
  4371. actualTrigger.call(this, preTriggerName, preTriggerArgs);
  4372. if (preTriggerArgs.prevented) {
  4373. args.prevented = true;
  4374. return;
  4375. }
  4376. }
  4377. actualTrigger.call(this, name, args);
  4378. };
  4379. Select2.prototype.toggleDropdown = function() {
  4380. if (this.isDisabled()) {
  4381. return;
  4382. }
  4383. if (this.isOpen()) {
  4384. this.close();
  4385. } else {
  4386. this.open();
  4387. }
  4388. };
  4389. Select2.prototype.open = function() {
  4390. if (this.isOpen()) {
  4391. return;
  4392. }
  4393. if (this.isDisabled()) {
  4394. return;
  4395. }
  4396. this.trigger("query", {});
  4397. };
  4398. Select2.prototype.close = function(evt) {
  4399. if (!this.isOpen()) {
  4400. return;
  4401. }
  4402. this.trigger("close", { originalEvent: evt });
  4403. };
  4404. Select2.prototype.isEnabled = function() {
  4405. return !this.isDisabled();
  4406. };
  4407. Select2.prototype.isDisabled = function() {
  4408. return this.options.get("disabled");
  4409. };
  4410. Select2.prototype.isOpen = function() {
  4411. return this.$container[0].classList.contains("select2-container--open");
  4412. };
  4413. Select2.prototype.hasFocus = function() {
  4414. return this.$container[0].classList.contains("select2-container--focus");
  4415. };
  4416. Select2.prototype.focus = function(data) {
  4417. if (this.hasFocus()) {
  4418. return;
  4419. }
  4420. this.$container[0].classList.add("select2-container--focus");
  4421. this.trigger("focus", {});
  4422. };
  4423. Select2.prototype.enable = function(args) {
  4424. if (this.options.get("debug") && window.console && console.warn) {
  4425. console.warn(
  4426. 'Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'
  4427. );
  4428. }
  4429. if (args == null || args.length === 0) {
  4430. args = [true];
  4431. }
  4432. var disabled = !args[0];
  4433. this.$element.prop("disabled", disabled);
  4434. };
  4435. Select2.prototype.data = function() {
  4436. if (this.options.get("debug") && arguments.length > 0 && window.console && console.warn) {
  4437. console.warn(
  4438. 'Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.'
  4439. );
  4440. }
  4441. var data = [];
  4442. this.dataAdapter.current(function(currentData) {
  4443. data = currentData;
  4444. });
  4445. return data;
  4446. };
  4447. Select2.prototype.val = function(args) {
  4448. if (this.options.get("debug") && window.console && console.warn) {
  4449. console.warn(
  4450. 'Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'
  4451. );
  4452. }
  4453. if (args == null || args.length === 0) {
  4454. return this.$element.val();
  4455. }
  4456. var newVal = args[0];
  4457. if (Array.isArray(newVal)) {
  4458. newVal = newVal.map(function(obj) {
  4459. return obj.toString();
  4460. });
  4461. }
  4462. this.$element.val(newVal).trigger("input").trigger("change");
  4463. };
  4464. Select2.prototype.destroy = function() {
  4465. Utils.RemoveData(this.$container[0]);
  4466. this.$container.remove();
  4467. this._observer.disconnect();
  4468. this._observer = null;
  4469. this._syncA = null;
  4470. this._syncS = null;
  4471. this.$element.off(".select2");
  4472. this.$element.attr(
  4473. "tabindex",
  4474. Utils.GetData(this.$element[0], "old-tabindex")
  4475. );
  4476. this.$element[0].classList.remove("select2-hidden-accessible");
  4477. this.$element.attr("aria-hidden", "false");
  4478. Utils.RemoveData(this.$element[0]);
  4479. this.$element.removeData("select2");
  4480. this.dataAdapter.destroy();
  4481. this.selection.destroy();
  4482. this.dropdown.destroy();
  4483. this.results.destroy();
  4484. this.dataAdapter = null;
  4485. this.selection = null;
  4486. this.dropdown = null;
  4487. this.results = null;
  4488. };
  4489. Select2.prototype.render = function() {
  4490. var $container = $2(
  4491. '<span class="select2 select2-container"><span class="selection"></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>'
  4492. );
  4493. $container.attr("dir", this.options.get("dir"));
  4494. this.$container = $container;
  4495. this.$container[0].classList.add("select2-container--" + this.options.get("theme"));
  4496. Utils.StoreData($container[0], "element", this.$element);
  4497. return $container;
  4498. };
  4499. return Select2;
  4500. });
  4501. S22.define("jquery-mousewheel", [
  4502. "jquery"
  4503. ], function($2) {
  4504. return $2;
  4505. });
  4506. S22.define("jquery.select2", [
  4507. "jquery",
  4508. "jquery-mousewheel",
  4509. "./select2/core",
  4510. "./select2/defaults",
  4511. "./select2/utils"
  4512. ], function($2, _, Select2, Defaults, Utils) {
  4513. if ($2.fn.select2 == null) {
  4514. var thisMethods = ["open", "close", "destroy"];
  4515. $2.fn.select2 = function(options) {
  4516. options = options || {};
  4517. if (typeof options === "object") {
  4518. this.each(function() {
  4519. var instanceOptions = $2.extend(true, {}, options);
  4520. var instance = new Select2($2(this), instanceOptions);
  4521. });
  4522. return this;
  4523. } else if (typeof options === "string") {
  4524. var ret;
  4525. var args = Array.prototype.slice.call(arguments, 1);
  4526. this.each(function() {
  4527. var instance = Utils.GetData(this, "select2");
  4528. if (instance == null && window.console && console.error) {
  4529. console.error(
  4530. "The select2('" + options + "') method was called on an element that is not using Select2."
  4531. );
  4532. }
  4533. ret = instance[options].apply(instance, args);
  4534. });
  4535. if (thisMethods.indexOf(options) > -1) {
  4536. return this;
  4537. }
  4538. return ret;
  4539. } else {
  4540. throw new Error("Invalid arguments for Select2: " + options);
  4541. }
  4542. };
  4543. }
  4544. if ($2.fn.select2.defaults == null) {
  4545. $2.fn.select2.defaults = Defaults;
  4546. }
  4547. return Select2;
  4548. });
  4549. return {
  4550. define: S22.define,
  4551. require: S22.require
  4552. };
  4553. }();
  4554. var select2 = S2.require("jquery.select2");
  4555. jQuery2.fn.select2.amd = S2;
  4556. return select2;
  4557. });
  4558. }
  4559. });
  4560. export default require_select2();
  4561. /*! Bundled license information:
  4562. select2/dist/js/select2.js:
  4563. (*!
  4564. * Select2 4.1.0-rc.0
  4565. * https://select2.github.io
  4566. *
  4567. * Released under the MIT license
  4568. * https://github.com/select2/select2/blob/master/LICENSE.md
  4569. *)
  4570. (**
  4571. * @license almond 0.3.3 Copyright jQuery Foundation and other contributors.
  4572. * Released under MIT license, http://github.com/requirejs/almond/LICENSE
  4573. *)
  4574. */
  4575. //# sourceMappingURL=select2.js.map