select2.js 86 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701
  1. window.$ = window.$ || {};(function() { if ($ && $.fn && $.fn.select2 && $.fn.select2.amd) { define = $.fn.select2.amd.define; require = $.fn.select2.amd.require; }/**
  2. * @license almond 0.2.9 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved.
  3. * Available via the MIT or new BSD license.
  4. * see: http://github.com/jrburke/almond for details
  5. */
  6. //Going sloppy to avoid 'use strict' string cost, but strict practices should
  7. //be followed.
  8. /*jslint sloppy: true */
  9. /*global setTimeout: false */
  10. var requirejs, require, define;
  11. (function (undef) {
  12. var main, req, makeMap, handlers,
  13. defined = {},
  14. waiting = {},
  15. config = {},
  16. defining = {},
  17. hasOwn = Object.prototype.hasOwnProperty,
  18. aps = [].slice,
  19. jsSuffixRegExp = /\.js$/;
  20. function hasProp(obj, prop) {
  21. return hasOwn.call(obj, prop);
  22. }
  23. /**
  24. * Given a relative module name, like ./something, normalize it to
  25. * a real name that can be mapped to a path.
  26. * @param {String} name the relative name
  27. * @param {String} baseName a real name that the name arg is relative
  28. * to.
  29. * @returns {String} normalized name
  30. */
  31. function normalize(name, baseName) {
  32. var nameParts, nameSegment, mapValue, foundMap, lastIndex,
  33. foundI, foundStarMap, starI, i, j, part,
  34. baseParts = baseName && baseName.split("/"),
  35. map = config.map,
  36. starMap = (map && map['*']) || {};
  37. //Adjust any relative paths.
  38. if (name && name.charAt(0) === ".") {
  39. //If have a base name, try to normalize against it,
  40. //otherwise, assume it is a top-level require that will
  41. //be relative to baseUrl in the end.
  42. if (baseName) {
  43. //Convert baseName to array, and lop off the last part,
  44. //so that . matches that "directory" and not name of the baseName's
  45. //module. For instance, baseName of "one/two/three", maps to
  46. //"one/two/three.js", but we want the directory, "one/two" for
  47. //this normalization.
  48. baseParts = baseParts.slice(0, baseParts.length - 1);
  49. name = name.split('/');
  50. lastIndex = name.length - 1;
  51. // Node .js allowance:
  52. if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
  53. name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
  54. }
  55. name = baseParts.concat(name);
  56. //start trimDots
  57. for (i = 0; i < name.length; i += 1) {
  58. part = name[i];
  59. if (part === ".") {
  60. name.splice(i, 1);
  61. i -= 1;
  62. } else if (part === "..") {
  63. if (i === 1 && (name[2] === '..' || name[0] === '..')) {
  64. //End of the line. Keep at least one non-dot
  65. //path segment at the front so it can be mapped
  66. //correctly to disk. Otherwise, there is likely
  67. //no path mapping for a path starting with '..'.
  68. //This can still fail, but catches the most reasonable
  69. //uses of ..
  70. break;
  71. } else if (i > 0) {
  72. name.splice(i - 1, 2);
  73. i -= 2;
  74. }
  75. }
  76. }
  77. //end trimDots
  78. name = name.join("/");
  79. } else if (name.indexOf('./') === 0) {
  80. // No baseName, so this is ID is resolved relative
  81. // to baseUrl, pull off the leading dot.
  82. name = name.substring(2);
  83. }
  84. }
  85. //Apply map config if available.
  86. if ((baseParts || starMap) && map) {
  87. nameParts = name.split('/');
  88. for (i = nameParts.length; i > 0; i -= 1) {
  89. nameSegment = nameParts.slice(0, i).join("/");
  90. if (baseParts) {
  91. //Find the longest baseName segment match in the config.
  92. //So, do joins on the biggest to smallest lengths of baseParts.
  93. for (j = baseParts.length; j > 0; j -= 1) {
  94. mapValue = map[baseParts.slice(0, j).join('/')];
  95. //baseName segment has config, find if it has one for
  96. //this name.
  97. if (mapValue) {
  98. mapValue = mapValue[nameSegment];
  99. if (mapValue) {
  100. //Match, update name to the new value.
  101. foundMap = mapValue;
  102. foundI = i;
  103. break;
  104. }
  105. }
  106. }
  107. }
  108. if (foundMap) {
  109. break;
  110. }
  111. //Check for a star map match, but just hold on to it,
  112. //if there is a shorter segment match later in a matching
  113. //config, then favor over this star map.
  114. if (!foundStarMap && starMap && starMap[nameSegment]) {
  115. foundStarMap = starMap[nameSegment];
  116. starI = i;
  117. }
  118. }
  119. if (!foundMap && foundStarMap) {
  120. foundMap = foundStarMap;
  121. foundI = starI;
  122. }
  123. if (foundMap) {
  124. nameParts.splice(0, foundI, foundMap);
  125. name = nameParts.join('/');
  126. }
  127. }
  128. return name;
  129. }
  130. function makeRequire(relName, forceSync) {
  131. return function () {
  132. //A version of a require function that passes a moduleName
  133. //value for items that may need to
  134. //look up paths relative to the moduleName
  135. return req.apply(undef, aps.call(arguments, 0).concat([relName, forceSync]));
  136. };
  137. }
  138. function makeNormalize(relName) {
  139. return function (name) {
  140. return normalize(name, relName);
  141. };
  142. }
  143. function makeLoad(depName) {
  144. return function (value) {
  145. defined[depName] = value;
  146. };
  147. }
  148. function callDep(name) {
  149. if (hasProp(waiting, name)) {
  150. var args = waiting[name];
  151. delete waiting[name];
  152. defining[name] = true;
  153. main.apply(undef, args);
  154. }
  155. if (!hasProp(defined, name) && !hasProp(defining, name)) {
  156. throw new Error('No ' + name);
  157. }
  158. return defined[name];
  159. }
  160. //Turns a plugin!resource to [plugin, resource]
  161. //with the plugin being undefined if the name
  162. //did not have a plugin prefix.
  163. function splitPrefix(name) {
  164. var prefix,
  165. index = name ? name.indexOf('!') : -1;
  166. if (index > -1) {
  167. prefix = name.substring(0, index);
  168. name = name.substring(index + 1, name.length);
  169. }
  170. return [prefix, name];
  171. }
  172. /**
  173. * Makes a name map, normalizing the name, and using a plugin
  174. * for normalization if necessary. Grabs a ref to plugin
  175. * too, as an optimization.
  176. */
  177. makeMap = function (name, relName) {
  178. var plugin,
  179. parts = splitPrefix(name),
  180. prefix = parts[0];
  181. name = parts[1];
  182. if (prefix) {
  183. prefix = normalize(prefix, relName);
  184. plugin = callDep(prefix);
  185. }
  186. //Normalize according
  187. if (prefix) {
  188. if (plugin && plugin.normalize) {
  189. name = plugin.normalize(name, makeNormalize(relName));
  190. } else {
  191. name = normalize(name, relName);
  192. }
  193. } else {
  194. name = normalize(name, relName);
  195. parts = splitPrefix(name);
  196. prefix = parts[0];
  197. name = parts[1];
  198. if (prefix) {
  199. plugin = callDep(prefix);
  200. }
  201. }
  202. //Using ridiculous property names for space reasons
  203. return {
  204. f: prefix ? prefix + '!' + name : name, //fullName
  205. n: name,
  206. pr: prefix,
  207. p: plugin
  208. };
  209. };
  210. function makeConfig(name) {
  211. return function () {
  212. return (config && config.config && config.config[name]) || {};
  213. };
  214. }
  215. handlers = {
  216. require: function (name) {
  217. return makeRequire(name);
  218. },
  219. exports: function (name) {
  220. var e = defined[name];
  221. if (typeof e !== 'undefined') {
  222. return e;
  223. } else {
  224. return (defined[name] = {});
  225. }
  226. },
  227. module: function (name) {
  228. return {
  229. id: name,
  230. uri: '',
  231. exports: defined[name],
  232. config: makeConfig(name)
  233. };
  234. }
  235. };
  236. main = function (name, deps, callback, relName) {
  237. var cjsModule, depName, ret, map, i,
  238. args = [],
  239. callbackType = typeof callback,
  240. usingExports;
  241. //Use name if no relName
  242. relName = relName || name;
  243. //Call the callback to define the module, if necessary.
  244. if (callbackType === 'undefined' || callbackType === 'function') {
  245. //Pull out the defined dependencies and pass the ordered
  246. //values to the callback.
  247. //Default to [require, exports, module] if no deps
  248. deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
  249. for (i = 0; i < deps.length; i += 1) {
  250. map = makeMap(deps[i], relName);
  251. depName = map.f;
  252. //Fast path CommonJS standard dependencies.
  253. if (depName === "require") {
  254. args[i] = handlers.require(name);
  255. } else if (depName === "exports") {
  256. //CommonJS module spec 1.1
  257. args[i] = handlers.exports(name);
  258. usingExports = true;
  259. } else if (depName === "module") {
  260. //CommonJS module spec 1.1
  261. cjsModule = args[i] = handlers.module(name);
  262. } else if (hasProp(defined, depName) ||
  263. hasProp(waiting, depName) ||
  264. hasProp(defining, depName)) {
  265. args[i] = callDep(depName);
  266. } else if (map.p) {
  267. map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
  268. args[i] = defined[depName];
  269. } else {
  270. throw new Error(name + ' missing ' + depName);
  271. }
  272. }
  273. ret = callback ? callback.apply(defined[name], args) : undefined;
  274. if (name) {
  275. //If setting exports via "module" is in play,
  276. //favor that over return value and exports. After that,
  277. //favor a non-undefined return value over exports use.
  278. if (cjsModule && cjsModule.exports !== undef &&
  279. cjsModule.exports !== defined[name]) {
  280. defined[name] = cjsModule.exports;
  281. } else if (ret !== undef || !usingExports) {
  282. //Use the return value from the function.
  283. defined[name] = ret;
  284. }
  285. }
  286. } else if (name) {
  287. //May just be an object definition for the module. Only
  288. //worry about defining if have a module name.
  289. defined[name] = callback;
  290. }
  291. };
  292. requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
  293. if (typeof deps === "string") {
  294. if (handlers[deps]) {
  295. //callback in this case is really relName
  296. return handlers[deps](callback);
  297. }
  298. //Just return the module wanted. In this scenario, the
  299. //deps arg is the module name, and second arg (if passed)
  300. //is just the relName.
  301. //Normalize module name, if it contains . or ..
  302. return callDep(makeMap(deps, callback).f);
  303. } else if (!deps.splice) {
  304. //deps is a config object, not an array.
  305. config = deps;
  306. if (config.deps) {
  307. req(config.deps, config.callback);
  308. }
  309. if (!callback) {
  310. return;
  311. }
  312. if (callback.splice) {
  313. //callback is an array, which means it is a dependency list.
  314. //Adjust args if there are dependencies
  315. deps = callback;
  316. callback = relName;
  317. relName = null;
  318. } else {
  319. deps = undef;
  320. }
  321. }
  322. //Support require(['a'])
  323. callback = callback || function () {};
  324. //If relName is a function, it is an errback handler,
  325. //so remove it.
  326. if (typeof relName === 'function') {
  327. relName = forceSync;
  328. forceSync = alt;
  329. }
  330. //Simulate async callback;
  331. if (forceSync) {
  332. main(undef, deps, callback, relName);
  333. } else {
  334. //Using a non-zero value because of concern for what old browsers
  335. //do, and latest browsers "upgrade" to 4 if lower value is used:
  336. //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
  337. //If want a value immediately, use require('id') instead -- something
  338. //that works in almond on the global level, but not guaranteed and
  339. //unlikely to work in other AMD implementations.
  340. setTimeout(function () {
  341. main(undef, deps, callback, relName);
  342. }, 4);
  343. }
  344. return req;
  345. };
  346. /**
  347. * Just drops the config on the floor, but returns req in case
  348. * the config return value is used.
  349. */
  350. req.config = function (cfg) {
  351. return req(cfg);
  352. };
  353. /**
  354. * Expose module registry for debugging and tooling
  355. */
  356. requirejs._defined = defined;
  357. define = function (name, deps, callback) {
  358. //This module may not have dependencies
  359. if (!deps.splice) {
  360. //deps is not an array, so probably means
  361. //an object literal or factory function for
  362. //the value. Adjust args.
  363. callback = deps;
  364. deps = [];
  365. }
  366. if (!hasProp(defined, name) && !hasProp(waiting, name)) {
  367. waiting[name] = [name, deps, callback];
  368. }
  369. };
  370. define.amd = {
  371. jQuery: true
  372. };
  373. }());
  374. define("almond", function(){});
  375. define('jquery',[],function () {
  376. return jQuery;
  377. });
  378. define('select2/utils',[], function () {
  379. var Utils = {};
  380. Utils.Extend = function (ChildClass, SuperClass) {
  381. var __hasProp = {}.hasOwnProperty;
  382. function BaseConstructor () {
  383. this.constructor = ChildClass;
  384. }
  385. for (var key in SuperClass) {
  386. if (__hasProp.call(SuperClass, key)) {
  387. ChildClass[key] = SuperClass[key];
  388. }
  389. }
  390. BaseConstructor.prototype = SuperClass.prototype;
  391. ChildClass.prototype = new BaseConstructor();
  392. ChildClass.__super__ = SuperClass.prototype;
  393. return ChildClass;
  394. };
  395. function getMethods (theClass) {
  396. var proto = theClass.prototype;
  397. var methods = [];
  398. for (var methodName in proto) {
  399. var m = proto[methodName];
  400. if (typeof m !== 'function') {
  401. continue;
  402. }
  403. methods.push(methodName);
  404. }
  405. return methods;
  406. }
  407. Utils.Decorate = function (SuperClass, DecoratorClass) {
  408. var decoratedMethods = getMethods(DecoratorClass);
  409. var superMethods = getMethods(SuperClass);
  410. function DecoratedClass () {
  411. var unshift = Array.prototype.unshift;
  412. var argCount = DecoratorClass.prototype.constructor.length;
  413. var calledConstructor = SuperClass.prototype.constructor;
  414. if (argCount > 0) {
  415. unshift.call(arguments, SuperClass.prototype.constructor);
  416. calledConstructor = DecoratorClass.prototype.constructor;
  417. }
  418. calledConstructor.apply(this, arguments);
  419. }
  420. DecoratorClass.displayName = SuperClass.displayName;
  421. function ctr () {
  422. this.constructor = DecoratedClass;
  423. }
  424. DecoratedClass.prototype = new ctr();
  425. for (var m = 0; m < superMethods.length; m++) {
  426. var superMethod = superMethods[m];
  427. DecoratedClass.prototype[superMethod] =
  428. SuperClass.prototype[superMethod];
  429. }
  430. var calledMethod = function (methodName) {
  431. // Stub out the original method if it's not decorating an actual method
  432. var originalMethod = function () {};
  433. if (methodName in DecoratedClass.prototype) {
  434. originalMethod = DecoratedClass.prototype[methodName];
  435. }
  436. var decoratedMethod = DecoratorClass.prototype[methodName];
  437. return function () {
  438. var unshift = Array.prototype.unshift;
  439. unshift.call(arguments, originalMethod);
  440. return decoratedMethod.apply(this, arguments);
  441. };
  442. };
  443. for (var d = 0; d < decoratedMethods.length; d++) {
  444. var decoratedMethod = decoratedMethods[d];
  445. DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
  446. }
  447. return DecoratedClass;
  448. };
  449. var Observable = function () {
  450. this.listeners = {};
  451. };
  452. Observable.prototype.on = function (event, callback) {
  453. this.listeners = this.listeners || {};
  454. if (event in this.listeners) {
  455. this.listeners[event].push(callback);
  456. } else {
  457. this.listeners[event] = [callback];
  458. }
  459. };
  460. Observable.prototype.trigger = function (event) {
  461. var slice = Array.prototype.slice;
  462. this.listeners = this.listeners || {};
  463. if (event in this.listeners) {
  464. this.invoke(this.listeners[event], slice.call(arguments, 1));
  465. }
  466. if ('*' in this.listeners) {
  467. this.invoke(this.listeners['*'], arguments);
  468. }
  469. };
  470. Observable.prototype.invoke = function (listeners, params) {
  471. for (var i = 0, len = listeners.length; i < len; i++) {
  472. listeners[i].apply(this, params);
  473. }
  474. };
  475. Utils.Observable = Observable;
  476. Utils.generateChars = function (length) {
  477. var chars = '';
  478. for (var i = 0; i < length; i++) {
  479. var randomChar = Math.floor(Math.random() * 36);
  480. chars += randomChar.toString(36);
  481. }
  482. return chars;
  483. };
  484. return Utils;
  485. });
  486. define('select2/results',[
  487. './utils'
  488. ], function (Utils) {
  489. function Results ($element, options, dataAdapter) {
  490. this.$element = $element;
  491. this.data = dataAdapter;
  492. this.options = options;
  493. Results.__super__.constructor.call(this);
  494. }
  495. Utils.Extend(Results, Utils.Observable);
  496. Results.prototype.render = function () {
  497. var $results = $(
  498. '<ul class="options" role="tree"></ul>'
  499. );
  500. if (this.options.get('multiple')) {
  501. $results.attr('aria-multiselectable', 'true');
  502. }
  503. this.$results = $results;
  504. return $results;
  505. };
  506. Results.prototype.clear = function () {
  507. this.$results.empty();
  508. };
  509. Results.prototype.displayMessage = function (params) {
  510. this.clear();
  511. this.hideLoading();
  512. var $message = $('<li role="treeitem" class="option"></li>');
  513. var message = this.options.get('translations').get(params.message);
  514. $message.text(message(params.args));
  515. this.$results.append($message);
  516. };
  517. Results.prototype.append = function (data) {
  518. this.hideLoading();
  519. var $options = [];
  520. if (data.length === 0) {
  521. if (this.$results.children().length === 0) {
  522. this.trigger('results:message', {
  523. message: 'noResults'
  524. });
  525. }
  526. return;
  527. }
  528. data = this.sort(data);
  529. for (var d = 0; d < data.length; d++) {
  530. var item = data[d];
  531. var $option = this.option(item);
  532. $options.push($option);
  533. }
  534. this.$results.append($options);
  535. };
  536. Results.prototype.sort = function (data) {
  537. return data;
  538. };
  539. Results.prototype.setClasses = function () {
  540. var self = this;
  541. this.data.current(function (selected) {
  542. var selectedIds = $.map(selected, function (s) {
  543. return s.id.toString();
  544. });
  545. var $options = self.$results.find('.option[aria-selected]');
  546. $options.each(function () {
  547. var $option = $(this);
  548. var item = $.data(this, 'data');
  549. if (item.id != null && selectedIds.indexOf(item.id.toString()) > -1) {
  550. $option.attr('aria-selected', 'true');
  551. } else {
  552. $option.attr('aria-selected', 'false');
  553. }
  554. });
  555. var $selected = $options.filter('[aria-selected=true]');
  556. // Check if there are any selected options
  557. if ($selected.length > 0) {
  558. // If there are selected options, highlight the first
  559. $selected.first().trigger('mouseenter');
  560. } else {
  561. // If there are no selected options, highlight the first option
  562. // in the dropdown
  563. $options.first().trigger('mouseenter');
  564. }
  565. });
  566. };
  567. Results.prototype.showLoading = function (params) {
  568. this.hideLoading();
  569. var loadingMore = this.options.get('translations').get('searching');
  570. var loading = {
  571. disabled: true,
  572. loading: true,
  573. text: loadingMore(params)
  574. };
  575. var $loading = this.option(loading);
  576. $loading.className += ' loading-results';
  577. this.$results.prepend($loading);
  578. };
  579. Results.prototype.hideLoading = function () {
  580. this.$results.find('.loading-results').remove();
  581. };
  582. Results.prototype.option = function (data) {
  583. var option = document.createElement('li');
  584. option.className = 'option';
  585. var attrs = {
  586. 'role': 'treeitem',
  587. 'aria-selected': 'false'
  588. };
  589. if (data.disabled) {
  590. delete attrs['aria-selected'];
  591. attrs['aria-disabled'] = 'true';
  592. }
  593. if (data.id == null) {
  594. delete attrs['aria-selected'];
  595. }
  596. if (data._resultId != null) {
  597. option.id = data._resultId;
  598. }
  599. if (data.children) {
  600. attrs.role = 'group';
  601. attrs['aria-label'] = data.text;
  602. delete attrs['aria-selected'];
  603. }
  604. for (var attr in attrs) {
  605. var val = attrs[attr];
  606. option.setAttribute(attr, val);
  607. }
  608. if (data.children) {
  609. var $option = $(option);
  610. var label = document.createElement('strong');
  611. label.className = 'group-label';
  612. var $label = $(label);
  613. this.template(data, label);
  614. var $children = [];
  615. for (var c = 0; c < data.children.length; c++) {
  616. var child = data.children[c];
  617. var $child = this.option(child);
  618. $children.push($child);
  619. }
  620. var $childrenContainer = $('<ul class="options nested-options"></ul>');
  621. $childrenContainer.append($children);
  622. $option.append(label);
  623. $option.append($childrenContainer);
  624. } else {
  625. this.template(data, option);
  626. }
  627. $.data(option, 'data', data);
  628. return option;
  629. };
  630. Results.prototype.bind = function (container, $container) {
  631. var self = this;
  632. var id = container.id + '-results';
  633. this.$results.attr('id', id);
  634. container.on('results:all', function (params) {
  635. self.clear();
  636. self.append(params.data);
  637. if (container.isOpen()) {
  638. self.setClasses();
  639. }
  640. });
  641. container.on('results:append', function (params) {
  642. self.append(params.data);
  643. if (container.isOpen()) {
  644. self.setClasses();
  645. }
  646. });
  647. container.on('query', function (params) {
  648. self.showLoading(params);
  649. });
  650. container.on('select', function () {
  651. if (!container.isOpen()) {
  652. return;
  653. }
  654. self.setClasses();
  655. });
  656. container.on('unselect', function () {
  657. if (!container.isOpen()) {
  658. return;
  659. }
  660. self.setClasses();
  661. });
  662. container.on('open', function () {
  663. // When the dropdown is open, aria-expended="true"
  664. self.$results.attr('aria-expanded', 'true');
  665. self.$results.attr('aria-hidden', 'false');
  666. self.setClasses();
  667. self.ensureHighlightVisible();
  668. });
  669. container.on('close', function () {
  670. // When the dropdown is closed, aria-expended="false"
  671. self.$results.attr('aria-expanded', 'false');
  672. self.$results.attr('aria-hidden', 'true');
  673. self.$results.removeAttr('aria-activedescendant');
  674. });
  675. container.on('results:select', function () {
  676. var $highlighted = self.$results.find('.highlighted');
  677. if ($highlighted.length === 0) {
  678. return;
  679. }
  680. var data = $highlighted.data('data');
  681. if ($highlighted.attr('aria-selected') == 'true') {
  682. self.trigger('unselected', {
  683. data: data
  684. });
  685. } else {
  686. self.trigger('selected', {
  687. data: data
  688. });
  689. }
  690. });
  691. container.on('results:previous', function () {
  692. var $highlighted = self.$results.find('.highlighted');
  693. var $options = self.$results.find('[aria-selected]');
  694. var currentIndex = $options.index($highlighted);
  695. // If we are already at te top, don't move further
  696. if (currentIndex === 0) {
  697. return;
  698. }
  699. var nextIndex = currentIndex - 1;
  700. // If none are highlighted, highlight the first
  701. if ($highlighted.length === 0) {
  702. nextIndex = 0;
  703. }
  704. var $next = $options.eq(nextIndex);
  705. $next.trigger('mouseenter');
  706. var currentOffset = self.$results.offset().top;
  707. var nextTop = $next.offset().top;
  708. var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset);
  709. if (nextIndex === 0) {
  710. self.$results.scrollTop(0);
  711. } else if (nextTop - currentOffset < 0) {
  712. self.$results.scrollTop(nextOffset);
  713. }
  714. });
  715. container.on('results:next', function () {
  716. var $highlighted = self.$results.find('.highlighted');
  717. var $options = self.$results.find('[aria-selected]');
  718. var currentIndex = $options.index($highlighted);
  719. var nextIndex = currentIndex + 1;
  720. // If we are at the last option, stay there
  721. if (nextIndex >= $options.length) {
  722. return;
  723. }
  724. var $next = $options.eq(nextIndex);
  725. $next.trigger('mouseenter');
  726. var currentOffset = self.$results.offset().top +
  727. self.$results.outerHeight(false);
  728. var nextBottom = $next.offset().top + $next.outerHeight(false);
  729. var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset;
  730. if (nextIndex === 0) {
  731. self.$results.scrollTop(0);
  732. } else if (nextBottom > currentOffset) {
  733. self.$results.scrollTop(nextOffset);
  734. }
  735. });
  736. container.on('results:focus', function (params) {
  737. params.element.addClass('highlighted');
  738. });
  739. container.on('results:message', function (params) {
  740. self.trigger('results:message', params);
  741. });
  742. this.on('results:message', function (params) {
  743. self.displayMessage(params);
  744. });
  745. this.$results.on('mouseup', '.option[aria-selected]', function (evt) {
  746. var $this = $(this);
  747. var data = $this.data('data');
  748. if ($this.attr('aria-selected') === 'true') {
  749. self.trigger('unselected', {
  750. originalEvent: evt,
  751. data: data
  752. });
  753. return;
  754. }
  755. self.trigger('selected', {
  756. originalEvent: evt,
  757. data: data
  758. });
  759. });
  760. this.$results.on('mouseenter', '.option[aria-selected]', function (evt) {
  761. var data = $(this).data('data');
  762. self.$results.find('.option.highlighted').removeClass('highlighted');
  763. self.trigger('results:focus', {
  764. data: data,
  765. element: $(this)
  766. });
  767. });
  768. };
  769. Results.prototype.destroy = function () {
  770. this.$results.remove();
  771. };
  772. Results.prototype.ensureHighlightVisible = function () {
  773. var $highlighted = this.$results.find('.highlighted');
  774. if ($highlighted.length === 0) {
  775. return;
  776. }
  777. var $options = this.$results.find('[aria-selected]');
  778. var currentIndex = $options.index($highlighted);
  779. var currentOffset = this.$results.offset().top;
  780. var nextTop = $highlighted.offset().top;
  781. var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset);
  782. var offsetDelta = nextTop - currentOffset;
  783. nextOffset -= $highlighted.outerHeight(false) * 2;
  784. if (currentIndex <= 2) {
  785. this.$results.scrollTop(0);
  786. } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) {
  787. this.$results.scrollTop(nextOffset);
  788. }
  789. };
  790. Results.prototype.template = function (result, container) {
  791. var template = this.options.get('templateResult');
  792. container.innerHTML = template(result);
  793. };
  794. return Results;
  795. });
  796. define('select2/keys',[
  797. ], function () {
  798. var KEYS = {
  799. BACKSPACE: 8,
  800. TAB: 9,
  801. ENTER: 13,
  802. SHIFT: 16,
  803. CTRL: 17,
  804. ALT: 18,
  805. ESC: 27,
  806. SPACE: 32,
  807. PAGE_UP: 33,
  808. PAGE_DOWN: 34,
  809. END: 35,
  810. HOME: 36,
  811. LEFT: 37,
  812. UP: 38,
  813. RIGHT: 39,
  814. DOWN: 40,
  815. DELETE: 46,
  816. isArrow: function (k) {
  817. k = k.which ? k.which : k;
  818. switch (k) {
  819. case KEY.LEFT:
  820. case KEY.RIGHT:
  821. case KEY.UP:
  822. case KEY.DOWN:
  823. return true;
  824. }
  825. return false;
  826. }
  827. };
  828. return KEYS;
  829. });
  830. define('select2/selection/base',[
  831. '../utils',
  832. '../keys'
  833. ], function (Utils, KEYS) {
  834. function BaseSelection ($element, options) {
  835. this.$element = $element;
  836. this.options = options;
  837. BaseSelection.__super__.constructor.call(this);
  838. }
  839. Utils.Extend(BaseSelection, Utils.Observable);
  840. BaseSelection.prototype.render = function () {
  841. throw new Error('The `render` method must be defined in child classes.');
  842. };
  843. BaseSelection.prototype.bind = function (container, $container) {
  844. var self = this;
  845. var id = container.id + '-container';
  846. var resultsId = container.id + '-results';
  847. this.$selection.attr('aria-owns', resultsId);
  848. this.$selection.on('keydown', function (evt) {
  849. self.trigger('keypress', evt);
  850. if (evt.which === KEYS.SPACE) {
  851. evt.preventDefault();
  852. }
  853. });
  854. container.on('results:focus', function (params) {
  855. self.$selection.attr('aria-activedescendant', params.data._resultId);
  856. });
  857. container.on('selection:update', function (params) {
  858. self.update(params.data);
  859. });
  860. container.on('open', function () {
  861. // When the dropdown is open, aria-expanded="true"
  862. self.$selection.attr('aria-expanded', 'true');
  863. $(document.body).on('mousedown.select2.' + container.id, function (e) {
  864. var $target = $(e.target);
  865. var $select = $target.closest('.select2');
  866. var $all = $('.select2.open');
  867. $all.each(function () {
  868. var $this = $(this);
  869. if (this == $select[0]) {
  870. return;
  871. }
  872. var $element = $this.data('element');
  873. $element.select2('close');
  874. });
  875. });
  876. });
  877. container.on('close', function () {
  878. // When the dropdown is closed, aria-expanded="false"
  879. self.$selection.attr('aria-expanded', 'false');
  880. self.$selection.removeAttr('aria-activedescendant');
  881. self.$selection.focus();
  882. $(document.body).off('mousedown.select2.' + container.id);
  883. });
  884. };
  885. BaseSelection.prototype.destroy = function () {
  886. // Unbind the dropdown click handler if it exists
  887. $(document.body).off('.select2.' + container.id);
  888. };
  889. BaseSelection.prototype.update = function (data) {
  890. throw new Error('The `update` method must be defined in child classes.');
  891. };
  892. return BaseSelection;
  893. });
  894. define('select2/selection/single',[
  895. './base',
  896. '../utils',
  897. '../keys'
  898. ], function (BaseSelection, Utils, KEYS) {
  899. function SingleSelection () {
  900. SingleSelection.__super__.constructor.apply(this, arguments);
  901. }
  902. Utils.Extend(SingleSelection, BaseSelection);
  903. SingleSelection.prototype.render = function () {
  904. var $selection = $(
  905. '<span class="single-select" tabindex="0" role="combobox" ' +
  906. 'aria-autocomplete="list" aria-haspopup="true" aria-expanded="false">' +
  907. '<span class="rendered-selection"></span>' +
  908. '</span>'
  909. );
  910. $selection.attr('title', this.$element.attr('title'));
  911. this.$selection = $selection;
  912. return $selection;
  913. };
  914. SingleSelection.prototype.bind = function (container, $container) {
  915. var self = this;
  916. SingleSelection.__super__.bind.apply(this, arguments);
  917. var id = container.id + '-container';
  918. this.$selection.find('.rendered-selection').attr('id', id);
  919. this.$selection.attr('aria-labelledby', id);
  920. this.$selection.on('mousedown', function (evt) {
  921. // Only respond to left clicks
  922. if (evt.which !== 1) {
  923. return;
  924. }
  925. self.trigger('toggle', {
  926. originalEvent: evt
  927. });
  928. });
  929. this.$selection.on('focus', function (evt) {
  930. // User focuses on the container
  931. });
  932. this.$selection.on('blur', function (evt) {
  933. // User exits the container
  934. });
  935. container.on('selection:update', function (params) {
  936. self.update(params.data);
  937. });
  938. };
  939. SingleSelection.prototype.clear = function () {
  940. this.$selection.find('.rendered-selection').empty();
  941. };
  942. SingleSelection.prototype.display = function (data) {
  943. var template = this.options.get('templateSelection');
  944. return template(data);
  945. };
  946. SingleSelection.prototype.selectionContainer = function () {
  947. return $('<span></span>');
  948. };
  949. SingleSelection.prototype.update = function (data) {
  950. if (data.length === 0) {
  951. this.clear();
  952. return;
  953. }
  954. var selection = data[0];
  955. var formatted = this.display(selection);
  956. this.$selection.find('.rendered-selection').html(formatted);
  957. };
  958. return SingleSelection;
  959. });
  960. define('select2/selection/multiple',[
  961. './base',
  962. '../utils'
  963. ], function (BaseSelection, Utils) {
  964. function MultipleSelection ($element, options) {
  965. MultipleSelection.__super__.constructor.apply(this, arguments);
  966. }
  967. Utils.Extend(MultipleSelection, BaseSelection);
  968. MultipleSelection.prototype.render = function () {
  969. var $selection = $(
  970. '<span class="multiple-select" tabindex="0" role="combobox" ' +
  971. 'aria-autocomplete="list" aria-haspopup="true" aria-expanded="false">' +
  972. '<ul class="rendered-selection"></ul>' +
  973. '</span>'
  974. );
  975. $selection.attr('title', this.$element.attr('title'));
  976. this.$selection = $selection;
  977. return $selection;
  978. };
  979. MultipleSelection.prototype.bind = function (container, $container) {
  980. var self = this;
  981. MultipleSelection.__super__.bind.apply(this, arguments);
  982. this.$selection.on('click', function (evt) {
  983. self.trigger('toggle', {
  984. originalEvent: evt
  985. });
  986. });
  987. this.$selection.on('click', '.remove', function (evt) {
  988. var $remove = $(this);
  989. var $selection = $remove.parent();
  990. var data = $selection.data('data');
  991. self.trigger('unselected', {
  992. originalEvent: evt,
  993. data: data
  994. });
  995. });
  996. };
  997. MultipleSelection.prototype.clear = function () {
  998. this.$selection.find('.rendered-selection').empty();
  999. };
  1000. MultipleSelection.prototype.display = function (data) {
  1001. var template = this.options.get('templateSelection');
  1002. return template(data);
  1003. };
  1004. MultipleSelection.prototype.selectionContainer = function () {
  1005. var $container = $(
  1006. '<li class="choice">' +
  1007. '<span class="remove" role="presentation">&times;</span>' +
  1008. '</li>'
  1009. );
  1010. return $container;
  1011. };
  1012. MultipleSelection.prototype.update = function (data) {
  1013. this.clear();
  1014. if (data.length === 0) {
  1015. return;
  1016. }
  1017. var $selections = [];
  1018. for (var d = 0; d < data.length; d++) {
  1019. var selection = data[d];
  1020. var formatted = this.display(selection);
  1021. var $selection = this.selectionContainer();
  1022. $selection.append(formatted);
  1023. $selection.data('data', selection);
  1024. $selections.push($selection);
  1025. }
  1026. this.$selection.find('.rendered-selection').append($selections);
  1027. };
  1028. return MultipleSelection;
  1029. });
  1030. define('select2/selection/placeholder',[
  1031. '../utils'
  1032. ], function (Utils) {
  1033. function Placeholder (decorated, $element, options) {
  1034. this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
  1035. decorated.call(this, $element, options);
  1036. }
  1037. Placeholder.prototype.normalizePlaceholder = function (_, placeholder) {
  1038. if (typeof placeholder === 'string') {
  1039. placeholder = {
  1040. id: '',
  1041. text: placeholder
  1042. };
  1043. }
  1044. return placeholder;
  1045. };
  1046. Placeholder.prototype.update = function (decorated, data) {
  1047. var singlePlaceholder = (
  1048. data.length == 1 && data[0].id != this.placeholder.id
  1049. );
  1050. var multipleSelections = data.length > 1;
  1051. if (multipleSelections || singlePlaceholder) {
  1052. return decorated.call(this, data);
  1053. }
  1054. this.clear();
  1055. var $placeholder = this.selectionContainer();
  1056. $placeholder.html(this.display(this.placeholder));
  1057. $placeholder.addClass('placeholder').removeClass('choice');
  1058. this.$selection.find('.rendered-selection').append($placeholder);
  1059. };
  1060. return Placeholder;
  1061. });
  1062. define('select2/translation',[
  1063. ], function () {
  1064. function Translation (dict) {
  1065. this.dict = dict || {};
  1066. }
  1067. Translation.prototype.all = function () {
  1068. return this.dict;
  1069. };
  1070. Translation.prototype.get = function (key) {
  1071. return this.dict[key];
  1072. };
  1073. Translation.prototype.extend = function (translation) {
  1074. this.dict = $.extend({}, translation.all(), this.dict);
  1075. };
  1076. // Static functions
  1077. Translation._cache = {};
  1078. Translation.loadPath = function (path) {
  1079. if (!(path in Translation._cache)) {
  1080. var translations = require(path);
  1081. Translation._cache[path] = translations;
  1082. }
  1083. return new Translation(Translation._cache[path]);
  1084. };
  1085. return Translation;
  1086. });
  1087. define('select2/diacritics',[
  1088. ], function () {
  1089. var diacritics = {
  1090. '\u24B6': 'A',
  1091. '\uFF21': 'A',
  1092. '\u00C0': 'A',
  1093. '\u00C1': 'A',
  1094. '\u00C2': 'A',
  1095. '\u1EA6': 'A',
  1096. '\u1EA4': 'A',
  1097. '\u1EAA': 'A',
  1098. '\u1EA8': 'A',
  1099. '\u00C3': 'A',
  1100. '\u0100': 'A',
  1101. '\u0102': 'A',
  1102. '\u1EB0': 'A',
  1103. '\u1EAE': 'A',
  1104. '\u1EB4': 'A',
  1105. '\u1EB2': 'A',
  1106. '\u0226': 'A',
  1107. '\u01E0': 'A',
  1108. '\u00C4': 'A',
  1109. '\u01DE': 'A',
  1110. '\u1EA2': 'A',
  1111. '\u00C5': 'A',
  1112. '\u01FA': 'A',
  1113. '\u01CD': 'A',
  1114. '\u0200': 'A',
  1115. '\u0202': 'A',
  1116. '\u1EA0': 'A',
  1117. '\u1EAC': 'A',
  1118. '\u1EB6': 'A',
  1119. '\u1E00': 'A',
  1120. '\u0104': 'A',
  1121. '\u023A': 'A',
  1122. '\u2C6F': 'A',
  1123. '\uA732': 'AA',
  1124. '\u00C6': 'AE',
  1125. '\u01FC': 'AE',
  1126. '\u01E2': 'AE',
  1127. '\uA734': 'AO',
  1128. '\uA736': 'AU',
  1129. '\uA738': 'AV',
  1130. '\uA73A': 'AV',
  1131. '\uA73C': 'AY',
  1132. '\u24B7': 'B',
  1133. '\uFF22': 'B',
  1134. '\u1E02': 'B',
  1135. '\u1E04': 'B',
  1136. '\u1E06': 'B',
  1137. '\u0243': 'B',
  1138. '\u0182': 'B',
  1139. '\u0181': 'B',
  1140. '\u24B8': 'C',
  1141. '\uFF23': 'C',
  1142. '\u0106': 'C',
  1143. '\u0108': 'C',
  1144. '\u010A': 'C',
  1145. '\u010C': 'C',
  1146. '\u00C7': 'C',
  1147. '\u1E08': 'C',
  1148. '\u0187': 'C',
  1149. '\u023B': 'C',
  1150. '\uA73E': 'C',
  1151. '\u24B9': 'D',
  1152. '\uFF24': 'D',
  1153. '\u1E0A': 'D',
  1154. '\u010E': 'D',
  1155. '\u1E0C': 'D',
  1156. '\u1E10': 'D',
  1157. '\u1E12': 'D',
  1158. '\u1E0E': 'D',
  1159. '\u0110': 'D',
  1160. '\u018B': 'D',
  1161. '\u018A': 'D',
  1162. '\u0189': 'D',
  1163. '\uA779': 'D',
  1164. '\u01F1': 'DZ',
  1165. '\u01C4': 'DZ',
  1166. '\u01F2': 'Dz',
  1167. '\u01C5': 'Dz',
  1168. '\u24BA': 'E',
  1169. '\uFF25': 'E',
  1170. '\u00C8': 'E',
  1171. '\u00C9': 'E',
  1172. '\u00CA': 'E',
  1173. '\u1EC0': 'E',
  1174. '\u1EBE': 'E',
  1175. '\u1EC4': 'E',
  1176. '\u1EC2': 'E',
  1177. '\u1EBC': 'E',
  1178. '\u0112': 'E',
  1179. '\u1E14': 'E',
  1180. '\u1E16': 'E',
  1181. '\u0114': 'E',
  1182. '\u0116': 'E',
  1183. '\u00CB': 'E',
  1184. '\u1EBA': 'E',
  1185. '\u011A': 'E',
  1186. '\u0204': 'E',
  1187. '\u0206': 'E',
  1188. '\u1EB8': 'E',
  1189. '\u1EC6': 'E',
  1190. '\u0228': 'E',
  1191. '\u1E1C': 'E',
  1192. '\u0118': 'E',
  1193. '\u1E18': 'E',
  1194. '\u1E1A': 'E',
  1195. '\u0190': 'E',
  1196. '\u018E': 'E',
  1197. '\u24BB': 'F',
  1198. '\uFF26': 'F',
  1199. '\u1E1E': 'F',
  1200. '\u0191': 'F',
  1201. '\uA77B': 'F',
  1202. '\u24BC': 'G',
  1203. '\uFF27': 'G',
  1204. '\u01F4': 'G',
  1205. '\u011C': 'G',
  1206. '\u1E20': 'G',
  1207. '\u011E': 'G',
  1208. '\u0120': 'G',
  1209. '\u01E6': 'G',
  1210. '\u0122': 'G',
  1211. '\u01E4': 'G',
  1212. '\u0193': 'G',
  1213. '\uA7A0': 'G',
  1214. '\uA77D': 'G',
  1215. '\uA77E': 'G',
  1216. '\u24BD': 'H',
  1217. '\uFF28': 'H',
  1218. '\u0124': 'H',
  1219. '\u1E22': 'H',
  1220. '\u1E26': 'H',
  1221. '\u021E': 'H',
  1222. '\u1E24': 'H',
  1223. '\u1E28': 'H',
  1224. '\u1E2A': 'H',
  1225. '\u0126': 'H',
  1226. '\u2C67': 'H',
  1227. '\u2C75': 'H',
  1228. '\uA78D': 'H',
  1229. '\u24BE': 'I',
  1230. '\uFF29': 'I',
  1231. '\u00CC': 'I',
  1232. '\u00CD': 'I',
  1233. '\u00CE': 'I',
  1234. '\u0128': 'I',
  1235. '\u012A': 'I',
  1236. '\u012C': 'I',
  1237. '\u0130': 'I',
  1238. '\u00CF': 'I',
  1239. '\u1E2E': 'I',
  1240. '\u1EC8': 'I',
  1241. '\u01CF': 'I',
  1242. '\u0208': 'I',
  1243. '\u020A': 'I',
  1244. '\u1ECA': 'I',
  1245. '\u012E': 'I',
  1246. '\u1E2C': 'I',
  1247. '\u0197': 'I',
  1248. '\u24BF': 'J',
  1249. '\uFF2A': 'J',
  1250. '\u0134': 'J',
  1251. '\u0248': 'J',
  1252. '\u24C0': 'K',
  1253. '\uFF2B': 'K',
  1254. '\u1E30': 'K',
  1255. '\u01E8': 'K',
  1256. '\u1E32': 'K',
  1257. '\u0136': 'K',
  1258. '\u1E34': 'K',
  1259. '\u0198': 'K',
  1260. '\u2C69': 'K',
  1261. '\uA740': 'K',
  1262. '\uA742': 'K',
  1263. '\uA744': 'K',
  1264. '\uA7A2': 'K',
  1265. '\u24C1': 'L',
  1266. '\uFF2C': 'L',
  1267. '\u013F': 'L',
  1268. '\u0139': 'L',
  1269. '\u013D': 'L',
  1270. '\u1E36': 'L',
  1271. '\u1E38': 'L',
  1272. '\u013B': 'L',
  1273. '\u1E3C': 'L',
  1274. '\u1E3A': 'L',
  1275. '\u0141': 'L',
  1276. '\u023D': 'L',
  1277. '\u2C62': 'L',
  1278. '\u2C60': 'L',
  1279. '\uA748': 'L',
  1280. '\uA746': 'L',
  1281. '\uA780': 'L',
  1282. '\u01C7': 'LJ',
  1283. '\u01C8': 'Lj',
  1284. '\u24C2': 'M',
  1285. '\uFF2D': 'M',
  1286. '\u1E3E': 'M',
  1287. '\u1E40': 'M',
  1288. '\u1E42': 'M',
  1289. '\u2C6E': 'M',
  1290. '\u019C': 'M',
  1291. '\u24C3': 'N',
  1292. '\uFF2E': 'N',
  1293. '\u01F8': 'N',
  1294. '\u0143': 'N',
  1295. '\u00D1': 'N',
  1296. '\u1E44': 'N',
  1297. '\u0147': 'N',
  1298. '\u1E46': 'N',
  1299. '\u0145': 'N',
  1300. '\u1E4A': 'N',
  1301. '\u1E48': 'N',
  1302. '\u0220': 'N',
  1303. '\u019D': 'N',
  1304. '\uA790': 'N',
  1305. '\uA7A4': 'N',
  1306. '\u01CA': 'NJ',
  1307. '\u01CB': 'Nj',
  1308. '\u24C4': 'O',
  1309. '\uFF2F': 'O',
  1310. '\u00D2': 'O',
  1311. '\u00D3': 'O',
  1312. '\u00D4': 'O',
  1313. '\u1ED2': 'O',
  1314. '\u1ED0': 'O',
  1315. '\u1ED6': 'O',
  1316. '\u1ED4': 'O',
  1317. '\u00D5': 'O',
  1318. '\u1E4C': 'O',
  1319. '\u022C': 'O',
  1320. '\u1E4E': 'O',
  1321. '\u014C': 'O',
  1322. '\u1E50': 'O',
  1323. '\u1E52': 'O',
  1324. '\u014E': 'O',
  1325. '\u022E': 'O',
  1326. '\u0230': 'O',
  1327. '\u00D6': 'O',
  1328. '\u022A': 'O',
  1329. '\u1ECE': 'O',
  1330. '\u0150': 'O',
  1331. '\u01D1': 'O',
  1332. '\u020C': 'O',
  1333. '\u020E': 'O',
  1334. '\u01A0': 'O',
  1335. '\u1EDC': 'O',
  1336. '\u1EDA': 'O',
  1337. '\u1EE0': 'O',
  1338. '\u1EDE': 'O',
  1339. '\u1EE2': 'O',
  1340. '\u1ECC': 'O',
  1341. '\u1ED8': 'O',
  1342. '\u01EA': 'O',
  1343. '\u01EC': 'O',
  1344. '\u00D8': 'O',
  1345. '\u01FE': 'O',
  1346. '\u0186': 'O',
  1347. '\u019F': 'O',
  1348. '\uA74A': 'O',
  1349. '\uA74C': 'O',
  1350. '\u01A2': 'OI',
  1351. '\uA74E': 'OO',
  1352. '\u0222': 'OU',
  1353. '\u24C5': 'P',
  1354. '\uFF30': 'P',
  1355. '\u1E54': 'P',
  1356. '\u1E56': 'P',
  1357. '\u01A4': 'P',
  1358. '\u2C63': 'P',
  1359. '\uA750': 'P',
  1360. '\uA752': 'P',
  1361. '\uA754': 'P',
  1362. '\u24C6': 'Q',
  1363. '\uFF31': 'Q',
  1364. '\uA756': 'Q',
  1365. '\uA758': 'Q',
  1366. '\u024A': 'Q',
  1367. '\u24C7': 'R',
  1368. '\uFF32': 'R',
  1369. '\u0154': 'R',
  1370. '\u1E58': 'R',
  1371. '\u0158': 'R',
  1372. '\u0210': 'R',
  1373. '\u0212': 'R',
  1374. '\u1E5A': 'R',
  1375. '\u1E5C': 'R',
  1376. '\u0156': 'R',
  1377. '\u1E5E': 'R',
  1378. '\u024C': 'R',
  1379. '\u2C64': 'R',
  1380. '\uA75A': 'R',
  1381. '\uA7A6': 'R',
  1382. '\uA782': 'R',
  1383. '\u24C8': 'S',
  1384. '\uFF33': 'S',
  1385. '\u1E9E': 'S',
  1386. '\u015A': 'S',
  1387. '\u1E64': 'S',
  1388. '\u015C': 'S',
  1389. '\u1E60': 'S',
  1390. '\u0160': 'S',
  1391. '\u1E66': 'S',
  1392. '\u1E62': 'S',
  1393. '\u1E68': 'S',
  1394. '\u0218': 'S',
  1395. '\u015E': 'S',
  1396. '\u2C7E': 'S',
  1397. '\uA7A8': 'S',
  1398. '\uA784': 'S',
  1399. '\u24C9': 'T',
  1400. '\uFF34': 'T',
  1401. '\u1E6A': 'T',
  1402. '\u0164': 'T',
  1403. '\u1E6C': 'T',
  1404. '\u021A': 'T',
  1405. '\u0162': 'T',
  1406. '\u1E70': 'T',
  1407. '\u1E6E': 'T',
  1408. '\u0166': 'T',
  1409. '\u01AC': 'T',
  1410. '\u01AE': 'T',
  1411. '\u023E': 'T',
  1412. '\uA786': 'T',
  1413. '\uA728': 'TZ',
  1414. '\u24CA': 'U',
  1415. '\uFF35': 'U',
  1416. '\u00D9': 'U',
  1417. '\u00DA': 'U',
  1418. '\u00DB': 'U',
  1419. '\u0168': 'U',
  1420. '\u1E78': 'U',
  1421. '\u016A': 'U',
  1422. '\u1E7A': 'U',
  1423. '\u016C': 'U',
  1424. '\u00DC': 'U',
  1425. '\u01DB': 'U',
  1426. '\u01D7': 'U',
  1427. '\u01D5': 'U',
  1428. '\u01D9': 'U',
  1429. '\u1EE6': 'U',
  1430. '\u016E': 'U',
  1431. '\u0170': 'U',
  1432. '\u01D3': 'U',
  1433. '\u0214': 'U',
  1434. '\u0216': 'U',
  1435. '\u01AF': 'U',
  1436. '\u1EEA': 'U',
  1437. '\u1EE8': 'U',
  1438. '\u1EEE': 'U',
  1439. '\u1EEC': 'U',
  1440. '\u1EF0': 'U',
  1441. '\u1EE4': 'U',
  1442. '\u1E72': 'U',
  1443. '\u0172': 'U',
  1444. '\u1E76': 'U',
  1445. '\u1E74': 'U',
  1446. '\u0244': 'U',
  1447. '\u24CB': 'V',
  1448. '\uFF36': 'V',
  1449. '\u1E7C': 'V',
  1450. '\u1E7E': 'V',
  1451. '\u01B2': 'V',
  1452. '\uA75E': 'V',
  1453. '\u0245': 'V',
  1454. '\uA760': 'VY',
  1455. '\u24CC': 'W',
  1456. '\uFF37': 'W',
  1457. '\u1E80': 'W',
  1458. '\u1E82': 'W',
  1459. '\u0174': 'W',
  1460. '\u1E86': 'W',
  1461. '\u1E84': 'W',
  1462. '\u1E88': 'W',
  1463. '\u2C72': 'W',
  1464. '\u24CD': 'X',
  1465. '\uFF38': 'X',
  1466. '\u1E8A': 'X',
  1467. '\u1E8C': 'X',
  1468. '\u24CE': 'Y',
  1469. '\uFF39': 'Y',
  1470. '\u1EF2': 'Y',
  1471. '\u00DD': 'Y',
  1472. '\u0176': 'Y',
  1473. '\u1EF8': 'Y',
  1474. '\u0232': 'Y',
  1475. '\u1E8E': 'Y',
  1476. '\u0178': 'Y',
  1477. '\u1EF6': 'Y',
  1478. '\u1EF4': 'Y',
  1479. '\u01B3': 'Y',
  1480. '\u024E': 'Y',
  1481. '\u1EFE': 'Y',
  1482. '\u24CF': 'Z',
  1483. '\uFF3A': 'Z',
  1484. '\u0179': 'Z',
  1485. '\u1E90': 'Z',
  1486. '\u017B': 'Z',
  1487. '\u017D': 'Z',
  1488. '\u1E92': 'Z',
  1489. '\u1E94': 'Z',
  1490. '\u01B5': 'Z',
  1491. '\u0224': 'Z',
  1492. '\u2C7F': 'Z',
  1493. '\u2C6B': 'Z',
  1494. '\uA762': 'Z',
  1495. '\u24D0': 'a',
  1496. '\uFF41': 'a',
  1497. '\u1E9A': 'a',
  1498. '\u00E0': 'a',
  1499. '\u00E1': 'a',
  1500. '\u00E2': 'a',
  1501. '\u1EA7': 'a',
  1502. '\u1EA5': 'a',
  1503. '\u1EAB': 'a',
  1504. '\u1EA9': 'a',
  1505. '\u00E3': 'a',
  1506. '\u0101': 'a',
  1507. '\u0103': 'a',
  1508. '\u1EB1': 'a',
  1509. '\u1EAF': 'a',
  1510. '\u1EB5': 'a',
  1511. '\u1EB3': 'a',
  1512. '\u0227': 'a',
  1513. '\u01E1': 'a',
  1514. '\u00E4': 'a',
  1515. '\u01DF': 'a',
  1516. '\u1EA3': 'a',
  1517. '\u00E5': 'a',
  1518. '\u01FB': 'a',
  1519. '\u01CE': 'a',
  1520. '\u0201': 'a',
  1521. '\u0203': 'a',
  1522. '\u1EA1': 'a',
  1523. '\u1EAD': 'a',
  1524. '\u1EB7': 'a',
  1525. '\u1E01': 'a',
  1526. '\u0105': 'a',
  1527. '\u2C65': 'a',
  1528. '\u0250': 'a',
  1529. '\uA733': 'aa',
  1530. '\u00E6': 'ae',
  1531. '\u01FD': 'ae',
  1532. '\u01E3': 'ae',
  1533. '\uA735': 'ao',
  1534. '\uA737': 'au',
  1535. '\uA739': 'av',
  1536. '\uA73B': 'av',
  1537. '\uA73D': 'ay',
  1538. '\u24D1': 'b',
  1539. '\uFF42': 'b',
  1540. '\u1E03': 'b',
  1541. '\u1E05': 'b',
  1542. '\u1E07': 'b',
  1543. '\u0180': 'b',
  1544. '\u0183': 'b',
  1545. '\u0253': 'b',
  1546. '\u24D2': 'c',
  1547. '\uFF43': 'c',
  1548. '\u0107': 'c',
  1549. '\u0109': 'c',
  1550. '\u010B': 'c',
  1551. '\u010D': 'c',
  1552. '\u00E7': 'c',
  1553. '\u1E09': 'c',
  1554. '\u0188': 'c',
  1555. '\u023C': 'c',
  1556. '\uA73F': 'c',
  1557. '\u2184': 'c',
  1558. '\u24D3': 'd',
  1559. '\uFF44': 'd',
  1560. '\u1E0B': 'd',
  1561. '\u010F': 'd',
  1562. '\u1E0D': 'd',
  1563. '\u1E11': 'd',
  1564. '\u1E13': 'd',
  1565. '\u1E0F': 'd',
  1566. '\u0111': 'd',
  1567. '\u018C': 'd',
  1568. '\u0256': 'd',
  1569. '\u0257': 'd',
  1570. '\uA77A': 'd',
  1571. '\u01F3': 'dz',
  1572. '\u01C6': 'dz',
  1573. '\u24D4': 'e',
  1574. '\uFF45': 'e',
  1575. '\u00E8': 'e',
  1576. '\u00E9': 'e',
  1577. '\u00EA': 'e',
  1578. '\u1EC1': 'e',
  1579. '\u1EBF': 'e',
  1580. '\u1EC5': 'e',
  1581. '\u1EC3': 'e',
  1582. '\u1EBD': 'e',
  1583. '\u0113': 'e',
  1584. '\u1E15': 'e',
  1585. '\u1E17': 'e',
  1586. '\u0115': 'e',
  1587. '\u0117': 'e',
  1588. '\u00EB': 'e',
  1589. '\u1EBB': 'e',
  1590. '\u011B': 'e',
  1591. '\u0205': 'e',
  1592. '\u0207': 'e',
  1593. '\u1EB9': 'e',
  1594. '\u1EC7': 'e',
  1595. '\u0229': 'e',
  1596. '\u1E1D': 'e',
  1597. '\u0119': 'e',
  1598. '\u1E19': 'e',
  1599. '\u1E1B': 'e',
  1600. '\u0247': 'e',
  1601. '\u025B': 'e',
  1602. '\u01DD': 'e',
  1603. '\u24D5': 'f',
  1604. '\uFF46': 'f',
  1605. '\u1E1F': 'f',
  1606. '\u0192': 'f',
  1607. '\uA77C': 'f',
  1608. '\u24D6': 'g',
  1609. '\uFF47': 'g',
  1610. '\u01F5': 'g',
  1611. '\u011D': 'g',
  1612. '\u1E21': 'g',
  1613. '\u011F': 'g',
  1614. '\u0121': 'g',
  1615. '\u01E7': 'g',
  1616. '\u0123': 'g',
  1617. '\u01E5': 'g',
  1618. '\u0260': 'g',
  1619. '\uA7A1': 'g',
  1620. '\u1D79': 'g',
  1621. '\uA77F': 'g',
  1622. '\u24D7': 'h',
  1623. '\uFF48': 'h',
  1624. '\u0125': 'h',
  1625. '\u1E23': 'h',
  1626. '\u1E27': 'h',
  1627. '\u021F': 'h',
  1628. '\u1E25': 'h',
  1629. '\u1E29': 'h',
  1630. '\u1E2B': 'h',
  1631. '\u1E96': 'h',
  1632. '\u0127': 'h',
  1633. '\u2C68': 'h',
  1634. '\u2C76': 'h',
  1635. '\u0265': 'h',
  1636. '\u0195': 'hv',
  1637. '\u24D8': 'i',
  1638. '\uFF49': 'i',
  1639. '\u00EC': 'i',
  1640. '\u00ED': 'i',
  1641. '\u00EE': 'i',
  1642. '\u0129': 'i',
  1643. '\u012B': 'i',
  1644. '\u012D': 'i',
  1645. '\u00EF': 'i',
  1646. '\u1E2F': 'i',
  1647. '\u1EC9': 'i',
  1648. '\u01D0': 'i',
  1649. '\u0209': 'i',
  1650. '\u020B': 'i',
  1651. '\u1ECB': 'i',
  1652. '\u012F': 'i',
  1653. '\u1E2D': 'i',
  1654. '\u0268': 'i',
  1655. '\u0131': 'i',
  1656. '\u24D9': 'j',
  1657. '\uFF4A': 'j',
  1658. '\u0135': 'j',
  1659. '\u01F0': 'j',
  1660. '\u0249': 'j',
  1661. '\u24DA': 'k',
  1662. '\uFF4B': 'k',
  1663. '\u1E31': 'k',
  1664. '\u01E9': 'k',
  1665. '\u1E33': 'k',
  1666. '\u0137': 'k',
  1667. '\u1E35': 'k',
  1668. '\u0199': 'k',
  1669. '\u2C6A': 'k',
  1670. '\uA741': 'k',
  1671. '\uA743': 'k',
  1672. '\uA745': 'k',
  1673. '\uA7A3': 'k',
  1674. '\u24DB': 'l',
  1675. '\uFF4C': 'l',
  1676. '\u0140': 'l',
  1677. '\u013A': 'l',
  1678. '\u013E': 'l',
  1679. '\u1E37': 'l',
  1680. '\u1E39': 'l',
  1681. '\u013C': 'l',
  1682. '\u1E3D': 'l',
  1683. '\u1E3B': 'l',
  1684. '\u017F': 'l',
  1685. '\u0142': 'l',
  1686. '\u019A': 'l',
  1687. '\u026B': 'l',
  1688. '\u2C61': 'l',
  1689. '\uA749': 'l',
  1690. '\uA781': 'l',
  1691. '\uA747': 'l',
  1692. '\u01C9': 'lj',
  1693. '\u24DC': 'm',
  1694. '\uFF4D': 'm',
  1695. '\u1E3F': 'm',
  1696. '\u1E41': 'm',
  1697. '\u1E43': 'm',
  1698. '\u0271': 'm',
  1699. '\u026F': 'm',
  1700. '\u24DD': 'n',
  1701. '\uFF4E': 'n',
  1702. '\u01F9': 'n',
  1703. '\u0144': 'n',
  1704. '\u00F1': 'n',
  1705. '\u1E45': 'n',
  1706. '\u0148': 'n',
  1707. '\u1E47': 'n',
  1708. '\u0146': 'n',
  1709. '\u1E4B': 'n',
  1710. '\u1E49': 'n',
  1711. '\u019E': 'n',
  1712. '\u0272': 'n',
  1713. '\u0149': 'n',
  1714. '\uA791': 'n',
  1715. '\uA7A5': 'n',
  1716. '\u01CC': 'nj',
  1717. '\u24DE': 'o',
  1718. '\uFF4F': 'o',
  1719. '\u00F2': 'o',
  1720. '\u00F3': 'o',
  1721. '\u00F4': 'o',
  1722. '\u1ED3': 'o',
  1723. '\u1ED1': 'o',
  1724. '\u1ED7': 'o',
  1725. '\u1ED5': 'o',
  1726. '\u00F5': 'o',
  1727. '\u1E4D': 'o',
  1728. '\u022D': 'o',
  1729. '\u1E4F': 'o',
  1730. '\u014D': 'o',
  1731. '\u1E51': 'o',
  1732. '\u1E53': 'o',
  1733. '\u014F': 'o',
  1734. '\u022F': 'o',
  1735. '\u0231': 'o',
  1736. '\u00F6': 'o',
  1737. '\u022B': 'o',
  1738. '\u1ECF': 'o',
  1739. '\u0151': 'o',
  1740. '\u01D2': 'o',
  1741. '\u020D': 'o',
  1742. '\u020F': 'o',
  1743. '\u01A1': 'o',
  1744. '\u1EDD': 'o',
  1745. '\u1EDB': 'o',
  1746. '\u1EE1': 'o',
  1747. '\u1EDF': 'o',
  1748. '\u1EE3': 'o',
  1749. '\u1ECD': 'o',
  1750. '\u1ED9': 'o',
  1751. '\u01EB': 'o',
  1752. '\u01ED': 'o',
  1753. '\u00F8': 'o',
  1754. '\u01FF': 'o',
  1755. '\u0254': 'o',
  1756. '\uA74B': 'o',
  1757. '\uA74D': 'o',
  1758. '\u0275': 'o',
  1759. '\u01A3': 'oi',
  1760. '\u0223': 'ou',
  1761. '\uA74F': 'oo',
  1762. '\u24DF': 'p',
  1763. '\uFF50': 'p',
  1764. '\u1E55': 'p',
  1765. '\u1E57': 'p',
  1766. '\u01A5': 'p',
  1767. '\u1D7D': 'p',
  1768. '\uA751': 'p',
  1769. '\uA753': 'p',
  1770. '\uA755': 'p',
  1771. '\u24E0': 'q',
  1772. '\uFF51': 'q',
  1773. '\u024B': 'q',
  1774. '\uA757': 'q',
  1775. '\uA759': 'q',
  1776. '\u24E1': 'r',
  1777. '\uFF52': 'r',
  1778. '\u0155': 'r',
  1779. '\u1E59': 'r',
  1780. '\u0159': 'r',
  1781. '\u0211': 'r',
  1782. '\u0213': 'r',
  1783. '\u1E5B': 'r',
  1784. '\u1E5D': 'r',
  1785. '\u0157': 'r',
  1786. '\u1E5F': 'r',
  1787. '\u024D': 'r',
  1788. '\u027D': 'r',
  1789. '\uA75B': 'r',
  1790. '\uA7A7': 'r',
  1791. '\uA783': 'r',
  1792. '\u24E2': 's',
  1793. '\uFF53': 's',
  1794. '\u00DF': 's',
  1795. '\u015B': 's',
  1796. '\u1E65': 's',
  1797. '\u015D': 's',
  1798. '\u1E61': 's',
  1799. '\u0161': 's',
  1800. '\u1E67': 's',
  1801. '\u1E63': 's',
  1802. '\u1E69': 's',
  1803. '\u0219': 's',
  1804. '\u015F': 's',
  1805. '\u023F': 's',
  1806. '\uA7A9': 's',
  1807. '\uA785': 's',
  1808. '\u1E9B': 's',
  1809. '\u24E3': 't',
  1810. '\uFF54': 't',
  1811. '\u1E6B': 't',
  1812. '\u1E97': 't',
  1813. '\u0165': 't',
  1814. '\u1E6D': 't',
  1815. '\u021B': 't',
  1816. '\u0163': 't',
  1817. '\u1E71': 't',
  1818. '\u1E6F': 't',
  1819. '\u0167': 't',
  1820. '\u01AD': 't',
  1821. '\u0288': 't',
  1822. '\u2C66': 't',
  1823. '\uA787': 't',
  1824. '\uA729': 'tz',
  1825. '\u24E4': 'u',
  1826. '\uFF55': 'u',
  1827. '\u00F9': 'u',
  1828. '\u00FA': 'u',
  1829. '\u00FB': 'u',
  1830. '\u0169': 'u',
  1831. '\u1E79': 'u',
  1832. '\u016B': 'u',
  1833. '\u1E7B': 'u',
  1834. '\u016D': 'u',
  1835. '\u00FC': 'u',
  1836. '\u01DC': 'u',
  1837. '\u01D8': 'u',
  1838. '\u01D6': 'u',
  1839. '\u01DA': 'u',
  1840. '\u1EE7': 'u',
  1841. '\u016F': 'u',
  1842. '\u0171': 'u',
  1843. '\u01D4': 'u',
  1844. '\u0215': 'u',
  1845. '\u0217': 'u',
  1846. '\u01B0': 'u',
  1847. '\u1EEB': 'u',
  1848. '\u1EE9': 'u',
  1849. '\u1EEF': 'u',
  1850. '\u1EED': 'u',
  1851. '\u1EF1': 'u',
  1852. '\u1EE5': 'u',
  1853. '\u1E73': 'u',
  1854. '\u0173': 'u',
  1855. '\u1E77': 'u',
  1856. '\u1E75': 'u',
  1857. '\u0289': 'u',
  1858. '\u24E5': 'v',
  1859. '\uFF56': 'v',
  1860. '\u1E7D': 'v',
  1861. '\u1E7F': 'v',
  1862. '\u028B': 'v',
  1863. '\uA75F': 'v',
  1864. '\u028C': 'v',
  1865. '\uA761': 'vy',
  1866. '\u24E6': 'w',
  1867. '\uFF57': 'w',
  1868. '\u1E81': 'w',
  1869. '\u1E83': 'w',
  1870. '\u0175': 'w',
  1871. '\u1E87': 'w',
  1872. '\u1E85': 'w',
  1873. '\u1E98': 'w',
  1874. '\u1E89': 'w',
  1875. '\u2C73': 'w',
  1876. '\u24E7': 'x',
  1877. '\uFF58': 'x',
  1878. '\u1E8B': 'x',
  1879. '\u1E8D': 'x',
  1880. '\u24E8': 'y',
  1881. '\uFF59': 'y',
  1882. '\u1EF3': 'y',
  1883. '\u00FD': 'y',
  1884. '\u0177': 'y',
  1885. '\u1EF9': 'y',
  1886. '\u0233': 'y',
  1887. '\u1E8F': 'y',
  1888. '\u00FF': 'y',
  1889. '\u1EF7': 'y',
  1890. '\u1E99': 'y',
  1891. '\u1EF5': 'y',
  1892. '\u01B4': 'y',
  1893. '\u024F': 'y',
  1894. '\u1EFF': 'y',
  1895. '\u24E9': 'z',
  1896. '\uFF5A': 'z',
  1897. '\u017A': 'z',
  1898. '\u1E91': 'z',
  1899. '\u017C': 'z',
  1900. '\u017E': 'z',
  1901. '\u1E93': 'z',
  1902. '\u1E95': 'z',
  1903. '\u01B6': 'z',
  1904. '\u0225': 'z',
  1905. '\u0240': 'z',
  1906. '\u2C6C': 'z',
  1907. '\uA763': 'z',
  1908. '\u0386': '\u0391',
  1909. '\u0388': '\u0395',
  1910. '\u0389': '\u0397',
  1911. '\u038A': '\u0399',
  1912. '\u03AA': '\u0399',
  1913. '\u038C': '\u039F',
  1914. '\u038E': '\u03A5',
  1915. '\u03AB': '\u03A5',
  1916. '\u038F': '\u03A9',
  1917. '\u03AC': '\u03B1',
  1918. '\u03AD': '\u03B5',
  1919. '\u03AE': '\u03B7',
  1920. '\u03AF': '\u03B9',
  1921. '\u03CA': '\u03B9',
  1922. '\u0390': '\u03B9',
  1923. '\u03CC': '\u03BF',
  1924. '\u03CD': '\u03C5',
  1925. '\u03CB': '\u03C5',
  1926. '\u03B0': '\u03C5',
  1927. '\u03C9': '\u03C9',
  1928. '\u03C2': '\u03C3'
  1929. };
  1930. return diacritics;
  1931. });
  1932. define('select2/data/base',[
  1933. '../utils'
  1934. ], function (Utils) {
  1935. function BaseAdapter ($element, options) {
  1936. BaseAdapter.__super__.constructor.call(this);
  1937. }
  1938. Utils.Extend(BaseAdapter, Utils.Observable);
  1939. BaseAdapter.prototype.current = function (callback) {
  1940. throw new Error('The `current` method must be defined in child classes.');
  1941. };
  1942. BaseAdapter.prototype.query = function (params, callback) {
  1943. throw new Error('The `query` method must be defined in child classes.');
  1944. };
  1945. BaseAdapter.prototype.bind = function (container, $container) {
  1946. // Can be implemented in subclasses
  1947. };
  1948. BaseAdapter.prototype.destroy = function () {
  1949. // Can be implemented in subclasses
  1950. };
  1951. BaseAdapter.prototype.generateResultId = function (container, data) {
  1952. var id = container.id + '-result-';
  1953. id += Utils.generateChars(4);
  1954. if (data.id != null) {
  1955. id += '-' + data.id.toString();
  1956. } else {
  1957. id += '-' + Utils.generateChars(4);
  1958. }
  1959. return id;
  1960. };
  1961. return BaseAdapter;
  1962. });
  1963. define('select2/data/select',[
  1964. './base',
  1965. '../utils',
  1966. 'jquery'
  1967. ], function (BaseAdapter, Utils, $) {
  1968. function SelectAdapter ($element, options) {
  1969. this.$element = $element;
  1970. this.options = options;
  1971. SelectAdapter.__super__.constructor.call(this);
  1972. }
  1973. Utils.Extend(SelectAdapter, BaseAdapter);
  1974. SelectAdapter.prototype.current = function (callback) {
  1975. var data = [];
  1976. var self = this;
  1977. this.$element.find(':selected').each(function () {
  1978. var $option = $(this);
  1979. var option = self.item($option);
  1980. data.push(option);
  1981. });
  1982. callback(data);
  1983. };
  1984. SelectAdapter.prototype.select = function (data) {
  1985. var self = this;
  1986. if (this.$element.prop('multiple')) {
  1987. this.current(function (currentData) {
  1988. var val = [];
  1989. data = [data];
  1990. data.push.apply(data, currentData);
  1991. for (var d = 0; d < data.length; d++) {
  1992. id = data[d].id;
  1993. if (val.indexOf(id) === -1) {
  1994. val.push(id);
  1995. }
  1996. }
  1997. self.$element.val(val);
  1998. self.$element.trigger('change');
  1999. });
  2000. } else {
  2001. var val = data.id;
  2002. this.$element.val(val);
  2003. this.$element.trigger('change');
  2004. }
  2005. };
  2006. SelectAdapter.prototype.unselect = function (data) {
  2007. var self = this;
  2008. if (!this.$element.prop('multiple')) {
  2009. return;
  2010. }
  2011. this.current(function (currentData) {
  2012. var val = [];
  2013. for (var d = 0; d < currentData.length; d++) {
  2014. id = currentData[d].id;
  2015. if (id !== data.id && val.indexOf(id) === -1) {
  2016. val.push(id);
  2017. }
  2018. }
  2019. self.$element.val(val);
  2020. self.$element.trigger('change');
  2021. });
  2022. };
  2023. SelectAdapter.prototype.bind = function (container, $container) {
  2024. var self = this;
  2025. this.container = container;
  2026. container.on('select', function (params) {
  2027. self.select(params.data);
  2028. });
  2029. container.on('unselect', function (params) {
  2030. self.unselect(params.data);
  2031. });
  2032. };
  2033. SelectAdapter.prototype.destroy = function () {
  2034. // Remove anything added to child elements
  2035. this.$element.find('*').each(function () {
  2036. // Remove any custom data set by Select2
  2037. $.removeData(this, 'data');
  2038. });
  2039. };
  2040. SelectAdapter.prototype.query = function (params, callback) {
  2041. var data = [];
  2042. var self = this;
  2043. var $options = this.$element.children();
  2044. $options.each(function () {
  2045. var $option = $(this);
  2046. if (!$option.is('option') && !$option.is('optgroup')) {
  2047. return;
  2048. }
  2049. var option = self.item($option);
  2050. var matches = self.matches(params, option);
  2051. if (matches !== null) {
  2052. data.push(matches);
  2053. }
  2054. });
  2055. callback(data);
  2056. };
  2057. SelectAdapter.prototype.option = function (data) {
  2058. var option = document.createElement('option');
  2059. option.value = data.id;
  2060. if (data.disabled) {
  2061. option.disabled = true;
  2062. }
  2063. if (data.selected) {
  2064. option.selected = true;
  2065. }
  2066. option.innerText = data.text;
  2067. var $option = $(option);
  2068. var normalizedData = this._normalizeItem(data);
  2069. // Override the option's data with the combined data
  2070. $.data(option, 'data', normalizedData);
  2071. return $option;
  2072. };
  2073. SelectAdapter.prototype.item = function ($option) {
  2074. var data = {};
  2075. data = $.data($option[0], 'data');
  2076. if (data != null) {
  2077. return data;
  2078. }
  2079. if ($option.is('option')) {
  2080. data = {
  2081. id: $option.val(),
  2082. text: $option.html(),
  2083. disabled: $option.prop('disabled'),
  2084. selected: $option.prop('selected')
  2085. };
  2086. } else if ($option.is('optgroup')) {
  2087. data = {
  2088. text: $option.attr('label'),
  2089. children: []
  2090. };
  2091. var $children = $option.children('option');
  2092. var children = [];
  2093. for (var c = 0; c < $children.length; c++) {
  2094. var $child = $($children[c]);
  2095. var child = this.item($child);
  2096. children.push(child);
  2097. }
  2098. data.children = children;
  2099. }
  2100. data = this._normalizeItem(data);
  2101. $.data($option[0], 'data', data);
  2102. return data;
  2103. };
  2104. SelectAdapter.prototype._normalizeItem = function (item) {
  2105. if (item.text == null) {
  2106. item = {
  2107. id: item,
  2108. text: item
  2109. };
  2110. }
  2111. var defaults = {
  2112. selected: false,
  2113. disabled: false
  2114. };
  2115. if (item.id != null) {
  2116. item.id = item.id.toString();
  2117. }
  2118. if (item.text != null) {
  2119. item.text = item.text.toString();
  2120. }
  2121. if (item._resultId == null && item.id && this.container != null) {
  2122. item._resultId = this.generateResultId(this.container, item);
  2123. }
  2124. return $.extend({}, defaults, item);
  2125. };
  2126. SelectAdapter.prototype.matches = function (params, data) {
  2127. var matcher = this.options.get('matcher');
  2128. return matcher(params, data);
  2129. };
  2130. return SelectAdapter;
  2131. });
  2132. define('select2/data/array',[
  2133. './select',
  2134. '../utils',
  2135. 'jquery'
  2136. ], function (SelectAdapter, Utils, $) {
  2137. function ArrayAdapter ($element, options) {
  2138. var data = options.get('data');
  2139. ArrayAdapter.__super__.constructor.call(this, $element, options);
  2140. this.convertToOptions(data);
  2141. }
  2142. Utils.Extend(ArrayAdapter, SelectAdapter);
  2143. ArrayAdapter.prototype.select = function (data) {
  2144. var $option = this.$element.find('option[value="' + data.id + '"]');
  2145. if ($option.length === 0) {
  2146. $option = this.option(data);
  2147. this.$element.append($option);
  2148. }
  2149. ArrayAdapter.__super__.select.call(this, data);
  2150. };
  2151. ArrayAdapter.prototype.convertToOptions = function (data) {
  2152. var self = this;
  2153. var $existing = this.$element.find('option');
  2154. var existingIds = $existing.map(function () {
  2155. return self.item($(this)).id;
  2156. }).get();
  2157. // Filter out all items except for the one passed in the argument
  2158. function onlyItem (item) {
  2159. return function () {
  2160. return $(this).val() == item.id;
  2161. };
  2162. }
  2163. for (var d = 0; d < data.length; d++) {
  2164. var item = data[d];
  2165. item.id = item.id.toString();
  2166. // Skip items which were pre-loaded, only merge the data
  2167. if (existingIds.indexOf(item.id) >= 0) {
  2168. var $existingOption = $existing.filter(onlyItem(item));
  2169. var existingData = this.item($existingOption);
  2170. var newData = $.extend(true, {}, existingData, item);
  2171. var $newOption = this.option(existingData);
  2172. $existingOption.replaceWith($newOption);
  2173. continue;
  2174. }
  2175. var $option = this.option(item);
  2176. this.$element.append($option);
  2177. }
  2178. };
  2179. return ArrayAdapter;
  2180. });
  2181. define('select2/data/ajax',[
  2182. './array',
  2183. '../utils',
  2184. 'jquery'
  2185. ], function (ArrayAdapter, Utils, $) {
  2186. function AjaxAdapter ($element, options) {
  2187. this.ajaxOptions = options.get('ajax');
  2188. if (this.ajaxOptions.processResults != null) {
  2189. this.processResults = this.ajaxOptions.processResults;
  2190. }
  2191. ArrayAdapter.__super__.constructor.call(this, $element, options);
  2192. }
  2193. Utils.Extend(AjaxAdapter, ArrayAdapter);
  2194. AjaxAdapter.prototype.processResults = function (results) {
  2195. return results;
  2196. };
  2197. AjaxAdapter.prototype.query = function (params, callback) {
  2198. var matches = [];
  2199. var self = this;
  2200. if (this._request) {
  2201. this._request.abort();
  2202. this._request = null;
  2203. }
  2204. var options = $.extend({
  2205. type: 'GET'
  2206. }, this.ajaxOptions);
  2207. if (typeof options.url === 'function') {
  2208. options.url = options.url(params);
  2209. }
  2210. if (typeof options.data === 'function') {
  2211. options.data = options.data(params);
  2212. }
  2213. function request () {
  2214. var $request = $.ajax(options);
  2215. $request.success(function (data) {
  2216. var results = self.processResults(data);
  2217. callback(results);
  2218. });
  2219. self._request = $request;
  2220. }
  2221. if (this.ajaxOptions.delay && params.term !== '') {
  2222. if (this._queryTimeout) {
  2223. window.clearTimeout(this._queryTimeout);
  2224. }
  2225. this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay);
  2226. } else {
  2227. request();
  2228. }
  2229. };
  2230. return AjaxAdapter;
  2231. });
  2232. define('select2/data/tags',[
  2233. ], function () {
  2234. function Tags (decorated, $element, options) {
  2235. var tags = options.get('tags');
  2236. decorated.call(this, $element, options);
  2237. if ($.isArray(tags)) {
  2238. for (var t = 0; t < tags.length; t++) {
  2239. var tag = tags[t];
  2240. var item = this._normalizeItem(tag);
  2241. var $option = this.option(item);
  2242. this.$element.append($option);
  2243. }
  2244. }
  2245. }
  2246. Tags.prototype.query = function (decorated, params, callback) {
  2247. var self = this;
  2248. this._removeOldTags();
  2249. if (params.term == null || params.term === '' || params.page != null) {
  2250. decorated.call(this, params, callback);
  2251. return;
  2252. }
  2253. function wrapper (data, child) {
  2254. for (var i = 0; i < data.length; i++) {
  2255. var option = data[i];
  2256. var checkChildren = (
  2257. option.children != null && !wrapper(option.children, true)
  2258. );
  2259. var checkText = option.text === params.term;
  2260. if (checkText || checkChildren) {
  2261. if (child) {
  2262. return false;
  2263. }
  2264. callback(data);
  2265. return;
  2266. }
  2267. }
  2268. if (child) {
  2269. return true;
  2270. }
  2271. var tag = self.createTag(params);
  2272. var $option = self.option(tag);
  2273. $option.attr('data-select2-tag', true);
  2274. self.$element.append($option);
  2275. self.insertTag(data, tag);
  2276. callback(data);
  2277. }
  2278. decorated.call(this, params, wrapper);
  2279. };
  2280. Tags.prototype.createTag = function (decorated, params) {
  2281. return {
  2282. id: params.term,
  2283. text: params.term
  2284. };
  2285. };
  2286. Tags.prototype.insertTag = function (_, data, tag) {
  2287. data.unshift(tag);
  2288. };
  2289. Tags.prototype._removeOldTags = function (_) {
  2290. var tag = this._lastTag;
  2291. var $options = this.$element.find('option[data-select2-tag]');
  2292. $options.each(function () {
  2293. if (this.selected) {
  2294. return;
  2295. }
  2296. $(this).remove();
  2297. });
  2298. };
  2299. return Tags;
  2300. });
  2301. define('select2/data/minimumInputLength',[
  2302. ], function () {
  2303. function MinimumInputLength (decorated, $e, options) {
  2304. this.minimumInputLength = options.get('minimumInputLength');
  2305. decorated.call(this, $e, options);
  2306. }
  2307. MinimumInputLength.prototype.query = function (decorated, params, callback) {
  2308. params.term = params.term || '';
  2309. if (params.term.length < this.minimumInputLength) {
  2310. this.trigger('results:message', {
  2311. message: 'inputTooShort',
  2312. args: {
  2313. minimum: this.minimumInputLength,
  2314. input: params.term,
  2315. params: params
  2316. }
  2317. });
  2318. return;
  2319. }
  2320. decorated.call(this, params, callback);
  2321. };
  2322. return MinimumInputLength;
  2323. });
  2324. define('select2/dropdown',[
  2325. './utils'
  2326. ], function (Utils) {
  2327. function Dropdown ($element, options) {
  2328. this.$element = $element;
  2329. }
  2330. Utils.Extend(Dropdown, Utils.Observable);
  2331. Dropdown.prototype.render = function () {
  2332. var $dropdown = $(
  2333. '<span class="dropdown">' +
  2334. '<span class="results"></span>' +
  2335. '</span>'
  2336. );
  2337. this.$dropdown = $dropdown;
  2338. return $dropdown;
  2339. };
  2340. Dropdown.prototype.destroy = function () {
  2341. // Remove the dropdown from the DOM
  2342. this.$dropdown.remove();
  2343. };
  2344. Dropdown.prototype.bind = function (container, $container) {
  2345. // Can be implemented in subclasses
  2346. };
  2347. return Dropdown;
  2348. });
  2349. define('select2/dropdown/search',[
  2350. '../utils'
  2351. ], function (Utils) {
  2352. function Search () { }
  2353. Search.prototype.render = function (decorated) {
  2354. var $rendered = decorated.call(this);
  2355. var $search = $(
  2356. '<span class="search">' +
  2357. '<input type="search" name="search" tabindex="-1" role="textbox" />' +
  2358. '</span>'
  2359. );
  2360. this.$searchContainer = $search;
  2361. this.$search = $search.find('input');
  2362. $rendered.prepend($search);
  2363. return $rendered;
  2364. };
  2365. Search.prototype.bind = function (decorated, container, $container) {
  2366. var self = this;
  2367. decorated.call(this, container, $container);
  2368. this.$search.on('keydown', function (evt) {
  2369. self.trigger('keypress', evt);
  2370. self._keyUpPrevented = evt.isDefaultPrevented();
  2371. });
  2372. this.$search.on('keyup', function (evt) {
  2373. self.handleSearch(evt);
  2374. });
  2375. container.on('open', function () {
  2376. self.$search.attr('tabindex', 0);
  2377. self.$search.focus();
  2378. });
  2379. container.on('close', function () {
  2380. self.$search.attr('tabindex', -1);
  2381. self.$search.val('');
  2382. });
  2383. container.on('results:all', function (params) {
  2384. if (params.query.term == null || params.query.term === '') {
  2385. var showSearch = self.showSearch(params);
  2386. if (showSearch) {
  2387. self.$searchContainer.show();
  2388. } else {
  2389. self.$searchContainer.hide();
  2390. }
  2391. }
  2392. });
  2393. };
  2394. Search.prototype.handleSearch = function (evt) {
  2395. if (!this._keyUpPrevented) {
  2396. var input = this.$search.val();
  2397. this.trigger('query', {
  2398. term: input
  2399. });
  2400. }
  2401. this._keyUpPrevented = false;
  2402. };
  2403. Search.prototype.showSearch = function (_, params) {
  2404. return true;
  2405. };
  2406. return Search;
  2407. });
  2408. define('select2/dropdown/hidePlaceholder',[
  2409. ], function () {
  2410. function HidePlaceholder (decorated, $element, options, dataAdapter) {
  2411. this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
  2412. decorated.call(this, $element, options, dataAdapter);
  2413. }
  2414. HidePlaceholder.prototype.append = function (decorated, data) {
  2415. data = this.removePlaceholder(data);
  2416. decorated.call(this, data);
  2417. };
  2418. HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) {
  2419. if (typeof placeholder === 'string') {
  2420. placeholder = {
  2421. id: '',
  2422. text: placeholder
  2423. };
  2424. }
  2425. return placeholder;
  2426. };
  2427. HidePlaceholder.prototype.removePlaceholder = function (_, data) {
  2428. var modifiedData = data.slice(0);
  2429. for (var d = data.length - 1; d >= 0; d--) {
  2430. var item = data[d];
  2431. if (this.placeholder.id === item.id) {
  2432. modifiedData.splice(d, 1);
  2433. }
  2434. }
  2435. return modifiedData;
  2436. };
  2437. return HidePlaceholder;
  2438. });
  2439. define('select2/dropdown/infiniteScroll',[
  2440. 'jquery'
  2441. ], function ($) {
  2442. function InfiniteScroll (decorated, $element, options, dataAdapter) {
  2443. this.lastParams = {};
  2444. decorated.call(this, $element, options, dataAdapter);
  2445. this.$loadingMore = this.createLoadingMore();
  2446. this.loading = false;
  2447. }
  2448. InfiniteScroll.prototype.append = function (decorated, data) {
  2449. this.$loadingMore.remove();
  2450. decorated.call(this, data);
  2451. if (data.length > 0) {
  2452. this.$results.append(this.$loadingMore);
  2453. }
  2454. this.loading = false;
  2455. };
  2456. InfiniteScroll.prototype.bind = function (decorated, container, $container) {
  2457. var self = this;
  2458. decorated.call(this, container, $container);
  2459. container.on('query', function (params) {
  2460. self.lastParams = params;
  2461. self.loading = true;
  2462. });
  2463. container.on('query:append', function (params) {
  2464. self.lastParams = params;
  2465. self.loading = true;
  2466. });
  2467. this.$results.on('scroll', function () {
  2468. var loadMoreVisible = $.contains(
  2469. document.documentElement,
  2470. self.$loadingMore[0]
  2471. );
  2472. if (self.loading || !loadMoreVisible) {
  2473. return;
  2474. }
  2475. var currentOffset = self.$results.offset().top +
  2476. self.$results.outerHeight(false);
  2477. var loadingMoreOffset = self.$loadingMore.offset().top +
  2478. self.$loadingMore.outerHeight(false);
  2479. if (currentOffset + 50 >= loadingMoreOffset) {
  2480. self.loadMore();
  2481. }
  2482. });
  2483. };
  2484. InfiniteScroll.prototype.loadMore = function () {
  2485. this.loading = true;
  2486. var params = $.extend({}, {page: 1}, this.lastParams);
  2487. params.page++;
  2488. this.trigger('query:append', params);
  2489. };
  2490. InfiniteScroll.prototype.createLoadingMore = function () {
  2491. var $option = $(
  2492. '<li class="option load-more" role="treeitem"></li>'
  2493. );
  2494. var message = this.options.get('translations').get('loadingMore');
  2495. $option.html(message(this.lastParams));
  2496. return $option;
  2497. };
  2498. return InfiniteScroll;
  2499. });
  2500. define('select2/i18n/en',[],function () {
  2501. return {
  2502. errorLoading: function () {
  2503. return 'The results could not be loaded.';
  2504. },
  2505. inputTooLong: function (args) {
  2506. var overChars = args.input.length - args.maximum;
  2507. var message = 'Please delete ' + overChars + ' character';
  2508. if (overChars != 1) {
  2509. message += 's';
  2510. }
  2511. return message;
  2512. },
  2513. inputTooShort: function (args) {
  2514. var remainingChars = args.minimum - args.input.length;
  2515. var message = 'Please enter ' + remainingChars + ' or more character';
  2516. if (remainingChars != 1) {
  2517. message += 's';
  2518. }
  2519. return message;
  2520. },
  2521. searching: function () {
  2522. return 'Searching…';
  2523. },
  2524. loadingMore: function () {
  2525. return 'Loading more results…';
  2526. },
  2527. maximumSelected: function (args) {
  2528. var message = 'You can only select' + args.maximum + ' item';
  2529. if (args.maximum != 1) {
  2530. message += 's';
  2531. }
  2532. return message;
  2533. },
  2534. noResults: function () {
  2535. return 'No results found';
  2536. }
  2537. };
  2538. });
  2539. define('select2/defaults',[
  2540. 'jquery',
  2541. './results',
  2542. './selection/single',
  2543. './selection/multiple',
  2544. './selection/placeholder',
  2545. './utils',
  2546. './translation',
  2547. './diacritics',
  2548. './data/select',
  2549. './data/array',
  2550. './data/ajax',
  2551. './data/tags',
  2552. './data/minimumInputLength',
  2553. './dropdown',
  2554. './dropdown/search',
  2555. './dropdown/hidePlaceholder',
  2556. './dropdown/infiniteScroll',
  2557. './i18n/en'
  2558. ], function ($, ResultsList,
  2559. SingleSelection, MultipleSelection, Placeholder,
  2560. Utils, Translation, DIACRITICS,
  2561. SelectData, ArrayData, AjaxData, Tags, MinimumInputLength,
  2562. Dropdown, Search, HidePlaceholder, InfiniteScroll,
  2563. EnglishTranslation) {
  2564. function Defaults () {
  2565. this.reset();
  2566. }
  2567. Defaults.prototype.apply = function (options) {
  2568. options = $.extend({}, this.defaults, options);
  2569. if (options.dataAdapter == null) {
  2570. if (options.ajax != null) {
  2571. options.dataAdapter = AjaxData;
  2572. } else if (options.data != null) {
  2573. options.dataAdapter = ArrayData;
  2574. } else {
  2575. options.dataAdapter = SelectData;
  2576. }
  2577. }
  2578. if (options.minimumInputLength > 0) {
  2579. options.dataAdapter = Utils.Decorate(
  2580. options.dataAdapter,
  2581. MinimumInputLength
  2582. );
  2583. }
  2584. if (options.tags != null) {
  2585. options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags);
  2586. }
  2587. if (options.resultsAdapter == null) {
  2588. options.resultsAdapter = ResultsList;
  2589. if (options.ajax != null) {
  2590. options.resultsAdapter = Utils.Decorate(
  2591. options.resultsAdapter,
  2592. InfiniteScroll
  2593. );
  2594. }
  2595. if (options.placeholder != null) {
  2596. options.resultsAdapter = Utils.Decorate(
  2597. options.resultsAdapter,
  2598. HidePlaceholder
  2599. );
  2600. }
  2601. }
  2602. if (options.dropdownAdapter == null) {
  2603. var SearchableDropdown = Utils.Decorate(Dropdown, Search);
  2604. options.dropdownAdapter = SearchableDropdown;
  2605. }
  2606. if (options.selectionAdapter == null) {
  2607. if (options.multiple) {
  2608. options.selectionAdapter = MultipleSelection;
  2609. } else {
  2610. options.selectionAdapter = SingleSelection;
  2611. }
  2612. // Add the placeholder mixin if a placeholder was specified
  2613. if (options.placeholder != null) {
  2614. options.selectionAdapter = Utils.Decorate(
  2615. options.selectionAdapter,
  2616. Placeholder
  2617. );
  2618. }
  2619. }
  2620. if (typeof options.language === 'string') {
  2621. options.language = [options.language];
  2622. }
  2623. if ($.isArray(options.language)) {
  2624. var languages = new Translation();
  2625. var languageNames = options.language.concat(this.defaults.language);
  2626. for (var l = 0; l < languageNames.length; l++) {
  2627. var name = languageNames[l];
  2628. var language = {};
  2629. try {
  2630. // Try to load it with the original name
  2631. language = Translation.loadPath(name);
  2632. } catch (e) {
  2633. // If we couldn't load it, check if it wasn't the full path
  2634. name = 'select2/i18n/' + name;
  2635. language = Translation.loadPath(name);
  2636. }
  2637. languages.extend(language);
  2638. }
  2639. options.translations = languages;
  2640. } else {
  2641. options.translations = new Translations(options.language);
  2642. }
  2643. return options;
  2644. };
  2645. Defaults.prototype.reset = function () {
  2646. function stripDiacritics (text) {
  2647. // Used 'uni range + named function' from http://jsperf.com/diacritics/18
  2648. function match(a) {
  2649. return DIACRITICS[a] || a;
  2650. }
  2651. return text.replace(/[^\u0000-\u007E]/g, match);
  2652. }
  2653. function matcher (params, data) {
  2654. // Always return the object if there is nothing to compare
  2655. if ($.trim(params.term) === '') {
  2656. return data;
  2657. }
  2658. // Do a recursive check for options with children
  2659. if (data.children && data.children.length > 0) {
  2660. // Clone the data object if there are children
  2661. // This is required as we modify the object to remove any non-matches
  2662. var match = $.extend(true, {}, data);
  2663. // Check each child of the option
  2664. for (var c = data.children.length - 1; c >= 0; c--) {
  2665. var child = data.children[c];
  2666. var matches = matcher(params, child);
  2667. // If there wasn't a match, remove the object in the array
  2668. if (matches == null) {
  2669. match.children.splice(c, 1);
  2670. }
  2671. }
  2672. // If any children matched, return the new object
  2673. if (match.children.length > 0) {
  2674. return match;
  2675. }
  2676. // If there were no matching children, check just the plain object
  2677. return matcher(params, match);
  2678. }
  2679. var original = stripDiacritics(data.text).toUpperCase();
  2680. var term = stripDiacritics(params.term).toUpperCase();
  2681. // Check if the text contains the term
  2682. if (original.indexOf(term) > -1) {
  2683. return data;
  2684. }
  2685. // If it doesn't contain the term, don't return anything
  2686. return null;
  2687. }
  2688. this.defaults = {
  2689. language: ['select2/i18n/en'],
  2690. matcher: matcher,
  2691. minimumInputLength: 0,
  2692. theme: 'default',
  2693. templateResult: function (result) {
  2694. return result.text;
  2695. },
  2696. templateSelection: function (selection) {
  2697. return selection.text;
  2698. }
  2699. };
  2700. };
  2701. var defaults = new Defaults();
  2702. return defaults;
  2703. });
  2704. define('select2/options',[
  2705. './defaults'
  2706. ], function (Defaults) {
  2707. function Options (options, $element) {
  2708. this.options = options;
  2709. if ($element != null) {
  2710. this.fromElement($element);
  2711. }
  2712. this.options = Defaults.apply(this.options);
  2713. }
  2714. Options.prototype.fromElement = function ($e) {
  2715. if (this.options.multiple == null) {
  2716. this.options.multiple = $e.prop('multiple');
  2717. }
  2718. return this;
  2719. };
  2720. Options.prototype.get = function (key) {
  2721. return this.options[key];
  2722. };
  2723. Options.prototype.set = function (key, val) {
  2724. this.options[key] = val;
  2725. };
  2726. return Options;
  2727. });
  2728. define('select2/core',[
  2729. 'jquery',
  2730. './options',
  2731. './utils',
  2732. './keys'
  2733. ], function ($, Options, Utils, KEYS) {
  2734. var Select2 = function ($element, options) {
  2735. if ($element.data('select2') != null) {
  2736. return;
  2737. }
  2738. this.$element = $element;
  2739. this.id = this._generateId($element);
  2740. options = options || {};
  2741. this.options = new Options(options, $element);
  2742. Select2.__super__.constructor.call(this);
  2743. // Set up containers and adapters
  2744. var DataAdapter = this.options.get('dataAdapter');
  2745. this.data = new DataAdapter($element, this.options);
  2746. var $container = this.render();
  2747. this._placeContainer($container);
  2748. var SelectionAdapter = this.options.get('selectionAdapter');
  2749. this.selection = new SelectionAdapter($element, this.options);
  2750. var $selection = this.selection.render();
  2751. this._placeSelection($selection);
  2752. var DropdownAdapter = this.options.get('dropdownAdapter');
  2753. this.dropdown = new DropdownAdapter($element, this.options);
  2754. var $dropdown = this.dropdown.render();
  2755. this._placeDropdown($dropdown);
  2756. var ResultsAdapter = this.options.get('resultsAdapter');
  2757. this.results = new ResultsAdapter($element, this.options, this.data);
  2758. var $results = this.results.render();
  2759. this._placeResults($results);
  2760. // Bind events
  2761. var self = this;
  2762. // Bind the container to all of the adapters
  2763. this._bindAdapters();
  2764. // Register any DOM event handlers
  2765. this._registerDomEvents();
  2766. // Register any internal event handlers
  2767. this._registerDataEvents();
  2768. this._registerSelectionEvents();
  2769. this._registerDropdownEvents();
  2770. this._registerResultsEvents();
  2771. this._registerEvents();
  2772. // Set the initial state
  2773. this.data.current(function (initialData) {
  2774. self.trigger('selection:update', {
  2775. data: initialData
  2776. });
  2777. });
  2778. // Hide the original select
  2779. $element.hide();
  2780. this._tabindex = $element.attr('tabindex') || 0;
  2781. $element.attr('tabindex', '-1');
  2782. $element.data('select2', this);
  2783. };
  2784. Utils.Extend(Select2, Utils.Observable);
  2785. Select2.prototype._generateId = function ($element) {
  2786. var id = '';
  2787. if ($element.attr('id') != null) {
  2788. id = $element.attr('id');
  2789. } else if ($element.attr('name') != null) {
  2790. id = $element.attr('name') + '-' + Utils.generateChars(2);
  2791. } else {
  2792. id = Utils.generateChars(4);
  2793. }
  2794. id = 'select2-' + id;
  2795. return id;
  2796. };
  2797. Select2.prototype._placeContainer = function ($container) {
  2798. $container.insertAfter(this.$element);
  2799. $container.width(this.$element.outerWidth(false));
  2800. };
  2801. Select2.prototype._placeSelection = function ($selection) {
  2802. var $selectionContainer = this.$container.find('.selection');
  2803. $selectionContainer.append($selection);
  2804. };
  2805. Select2.prototype._placeDropdown = function ($dropdown) {
  2806. this.$dropdown = $dropdown;
  2807. var $dropdownContainer = this.$container.find('.dropdown-wrapper');
  2808. $dropdownContainer.append($dropdown);
  2809. };
  2810. Select2.prototype._placeResults = function ($results) {
  2811. var $resultsContainer = this.$dropdown.find('.results');
  2812. $resultsContainer.append($results);
  2813. };
  2814. Select2.prototype._bindAdapters = function () {
  2815. this.data.bind(this, this.$container);
  2816. this.selection.bind(this, this.$container);
  2817. this.dropdown.bind(this, this.$container);
  2818. this.results.bind(this, this.$container);
  2819. };
  2820. Select2.prototype._registerDomEvents = function () {
  2821. var self = this;
  2822. this.$element.on('change.select2', function () {
  2823. self.data.current(function (data) {
  2824. self.trigger('selection:update', {
  2825. data: data
  2826. });
  2827. });
  2828. });
  2829. };
  2830. Select2.prototype._registerDataEvents = function () {
  2831. var self = this;
  2832. this.data.on('results:message', function (params) {
  2833. self.trigger('results:message', params);
  2834. });
  2835. };
  2836. Select2.prototype._registerSelectionEvents = function () {
  2837. var self = this;
  2838. this.selection.on('open', function () {
  2839. self.open();
  2840. });
  2841. this.selection.on('close', function () {
  2842. self.close();
  2843. });
  2844. this.selection.on('toggle', function () {
  2845. self.toggleDropdown();
  2846. });
  2847. this.selection.on('results:select', function () {
  2848. self.trigger('results:select');
  2849. });
  2850. this.selection.on('results:previous', function () {
  2851. self.trigger('results:previous');
  2852. });
  2853. this.selection.on('results:next', function () {
  2854. self.trigger('results:next');
  2855. });
  2856. this.selection.on('unselected', function (params) {
  2857. self.trigger('unselect', params);
  2858. self.close();
  2859. });
  2860. this.selection.on('keypress', function (e) {
  2861. self.trigger('keypress', e);
  2862. });
  2863. };
  2864. Select2.prototype._registerDropdownEvents = function () {
  2865. var self = this;
  2866. this.dropdown.on('query', function (params) {
  2867. self.trigger('query', params);
  2868. });
  2869. this.dropdown.on('keypress', function (e) {
  2870. self.trigger('keypress', e);
  2871. });
  2872. };
  2873. Select2.prototype._registerResultsEvents = function () {
  2874. var self = this;
  2875. this.results.on('query:append', function (params) {
  2876. self.trigger('query:append', params);
  2877. });
  2878. this.results.on('selected', function (params) {
  2879. self.trigger('select', params);
  2880. self.close();
  2881. });
  2882. this.results.on('unselected', function (params) {
  2883. self.trigger('unselect', params);
  2884. self.close();
  2885. });
  2886. this.results.on('results:focus', function (params) {
  2887. self.trigger('results:focus', params);
  2888. });
  2889. };
  2890. Select2.prototype._registerEvents = function () {
  2891. var self = this;
  2892. this.on('open', function () {
  2893. self.$container.addClass('open');
  2894. });
  2895. this.on('close', function () {
  2896. self.$container.removeClass('open');
  2897. });
  2898. this.on('query', function (params) {
  2899. this.data.query(params, function (data) {
  2900. self.trigger('results:all', {
  2901. data: data,
  2902. query: params
  2903. });
  2904. });
  2905. });
  2906. this.on('query:append', function (params) {
  2907. this.data.query(params, function (data) {
  2908. self.trigger('results:append', {
  2909. data: data,
  2910. query: params
  2911. });
  2912. });
  2913. });
  2914. this.on('keypress', function (evt) {
  2915. var key = evt.which;
  2916. if (self.isOpen()) {
  2917. if (key === KEYS.ENTER) {
  2918. self.trigger('results:select');
  2919. evt.preventDefault();
  2920. } else if (key === KEYS.UP) {
  2921. self.trigger('results:previous');
  2922. evt.preventDefault();
  2923. } else if (key === KEYS.DOWN) {
  2924. self.trigger('results:next');
  2925. evt.preventDefault();
  2926. } else if (key === KEYS.ESC || key === KEYS.TAB) {
  2927. self.close();
  2928. evt.preventDefault();
  2929. }
  2930. } else {
  2931. if (key === KEYS.ENTER || key === KEYS.SPACE) {
  2932. self.open();
  2933. evt.preventDefault();
  2934. }
  2935. }
  2936. });
  2937. };
  2938. Select2.prototype.toggleDropdown = function () {
  2939. if (this.isOpen()) {
  2940. this.close();
  2941. } else {
  2942. this.open();
  2943. }
  2944. };
  2945. Select2.prototype.open = function () {
  2946. if (this.isOpen()) {
  2947. return;
  2948. }
  2949. this.trigger('query', {});
  2950. this.trigger('open');
  2951. };
  2952. Select2.prototype.close = function () {
  2953. if (!this.isOpen()) {
  2954. return;
  2955. }
  2956. this.trigger('close');
  2957. };
  2958. Select2.prototype.isOpen = function () {
  2959. return this.$container.hasClass('open');
  2960. };
  2961. Select2.prototype.destroy = function () {
  2962. this.$container.remove();
  2963. this.$element.off('.select2');
  2964. this.$element.attr('tabindex', this._tabindex);
  2965. this.$element.show();
  2966. this.$element.removeData('select2');
  2967. this.data.destroy();
  2968. this.selection.destroy();
  2969. this.dropdown.destroy();
  2970. this.results.destroy();
  2971. this.data = null;
  2972. this.selection = null;
  2973. this.dropdown = null;
  2974. this.results = null;
  2975. };
  2976. Select2.prototype.render = function () {
  2977. var $container = $(
  2978. '<span class="select2 select2-container">' +
  2979. '<span class="selection"></span>' +
  2980. '<span class="dropdown-wrapper" aria-hidden="true"></span>' +
  2981. '</span>'
  2982. );
  2983. this.$container = $container;
  2984. this.$container.addClass('select2-theme-' + this.options.get('theme'));
  2985. $container.data('element', this.$element);
  2986. return $container;
  2987. };
  2988. return Select2;
  2989. });
  2990. define('jquery.select2',[
  2991. 'jquery',
  2992. 'select2/core'
  2993. ], function ($, Select2) {
  2994. if ($.fn.select2 == null) {
  2995. $.fn.select2 = function (options) {
  2996. options = options || {};
  2997. if (typeof options === 'object') {
  2998. this.each(function () {
  2999. var instance = new Select2($(this), options);
  3000. });
  3001. } else if (typeof options === 'string') {
  3002. var instance = this.data('select2');
  3003. var args = Array.prototype.slice.call(arguments, 1);
  3004. instance[options](args);
  3005. } else {
  3006. throw new Error('Invalid arguments for Select2: ' + options);
  3007. }
  3008. };
  3009. }
  3010. return Select2;
  3011. });
  3012. require('jquery.select2'); $.fn.select2.amd = { define: define, require: require };}());