selectSrchFun.js 88 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131
  1. /*
  2. Copyright 2012 Igor Vaynberg
  3. Modifed by keenthemes for Metronic theme integration.
  4. Version: 3.4.3 Timestamp: Tue Sep 17 06:47:14 PDT 2013
  5. This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
  6. General Public License version 2 (the "GPL License"). You may choose either license to govern your
  7. use of this software only upon the condition that you accept all of the terms of either the Apache
  8. License or the GPL License.
  9. You may obtain a copy of the Apache License and the GPL License at:
  10. http://www.apache.org/licenses/LICENSE-2.0
  11. http://www.gnu.org/licenses/gpl-2.0.html
  12. Unless required by applicable law or agreed to in writing, software distributed under the Apache License
  13. or the GPL Licesnse is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  14. either express or implied. See the Apache License and the GPL License for the specific language governing
  15. permissions and limitations under the Apache License and the GPL License.
  16. */
  17. !
  18. function (e) {
  19. "undefined" == typeof e.fn.each2 && e.extend(e.fn, {
  20. each2: function (t) {
  21. for (var i = e([0]), n = -1, a = this.length; ++n < a && (i.context = i[0] = this[n]) && t.call(i[0], n, i) !== !1;);
  22. return this
  23. }
  24. })
  25. }(jQuery), function (e, t) {
  26. "use strict";
  27. function i(e) {
  28. var t, i, n, a;
  29. if (!e || e.length < 1) return e;
  30. for (t = "", i = 0, n = e.length; n > i; i++) a = e.charAt(i), t += B[a] || a;
  31. return t
  32. }
  33. function n(e, t) {
  34. for (var i = 0, n = t.length; n > i; i += 1) if (r(e, t[i])) return i;
  35. return -1
  36. }
  37. function a() {
  38. var t = e(H);
  39. t.appendTo("body");
  40. var i = {
  41. width: t.width() - t[0].clientWidth,
  42. height: t.height() - t[0].clientHeight
  43. };
  44. return t.remove(), i
  45. }
  46. function r(e, i) {
  47. return e === i ? !0 : e === t || i === t ? !1 : null === e || null === i ? !1 : e.constructor === String ? e + "" == i + "" : i.constructor === String ? i + "" == e + "" : !1
  48. }
  49. function o(t, i) {
  50. var n, a, r;
  51. if (null === t || t.length < 1) return [];
  52. for (n = t.split(i), a = 0, r = n.length; r > a; a += 1) n[a] = e.trim(n[a]);
  53. return n
  54. }
  55. function s(e) {
  56. return e.outerWidth(!1) - e.width()
  57. }
  58. function l(i) {
  59. var n = "keyup-change-value";
  60. i.on("keydown", function () {
  61. e.data(i, n) === t && e.data(i, n, i.val())
  62. }), i.on("keyup", function () {
  63. var a = e.data(i, n);
  64. a !== t && i.val() !== a && (e.removeData(i, n), i.trigger("keyup-change"))
  65. })
  66. }
  67. function d(i) {
  68. i.on("mousemove", function (i) {
  69. var n = O;
  70. (n === t || n.x !== i.pageX || n.y !== i.pageY) && e(i.target).trigger("mousemove-filtered", i)
  71. })
  72. }
  73. function h(e, i, n) {
  74. n = n || t;
  75. var a;
  76. return function () {
  77. var t = arguments;
  78. window.clearTimeout(a), a = window.setTimeout(function () {
  79. i.apply(n, t)
  80. }, e)
  81. }
  82. }
  83. function c(e) {
  84. var t, i = !1;
  85. return function () {
  86. return i === !1 && (t = e(), i = !0), t
  87. }
  88. }
  89. function u(e, t) {
  90. var i = h(e, function (e) {
  91. t.trigger("scroll-debounced", e)
  92. });
  93. t.on("scroll", function (e) {
  94. n(e.target, t.get()) >= 0 && i(e)
  95. })
  96. }
  97. function p(e) {
  98. e[0] !== document.activeElement && window.setTimeout(function () {
  99. var t, i = e[0],
  100. n = e.val().length;
  101. e.focus(), e.is(":visible") && i === document.activeElement && (i.setSelectionRange ? i.setSelectionRange(n, n) : i.createTextRange && (t = i.createTextRange(), t.collapse(!1), t.select()))
  102. }, 0)
  103. }
  104. function g(t) {
  105. t = e(t)[0];
  106. var i = 0,
  107. n = 0;
  108. if ("selectionStart" in t) i = t.selectionStart, n = t.selectionEnd - i;
  109. else if ("selection" in document) {
  110. t.focus();
  111. var a = document.selection.createRange();
  112. n = document.selection.createRange().text.length, a.moveStart("character", -t.value.length), i = a.text.length - n
  113. }
  114. return {
  115. offset: i,
  116. length: n
  117. }
  118. }
  119. function f(e) {
  120. e.preventDefault(), e.stopPropagation()
  121. }
  122. function m(e) {
  123. e.preventDefault(), e.stopImmediatePropagation()
  124. }
  125. function v(t) {
  126. if (!j) {
  127. var i = t[0].currentStyle || window.getComputedStyle(t[0], null);
  128. j = e(document.createElement("div")).css({
  129. position: "absolute",
  130. left: "-10000px",
  131. top: "-10000px",
  132. display: "none",
  133. fontSize: i.fontSize,
  134. fontFamily: i.fontFamily,
  135. fontStyle: i.fontStyle,
  136. fontWeight: i.fontWeight,
  137. letterSpacing: i.letterSpacing,
  138. textTransform: i.textTransform,
  139. whiteSpace: "nowrap"
  140. }), j.attr("class", "sp-selSrch-sizer"), e("body").append(j)
  141. }
  142. return j.text(t.val()), j.width()
  143. }
  144. function y(t, i, n) {
  145. var a, r, o = [];
  146. a = t.attr("class"), a && (a = "" + a, e(a.split(" ")).each2(function () {
  147. 0 === this.indexOf("sp-selSrch-") && o.push(this)
  148. })), a = i.attr("class"), a && (a = "" + a, e(a.split(" ")).each2(function () {
  149. 0 !== this.indexOf("sp-selSrch-") && (r = n(this), r && o.push(this))
  150. })), t.attr("class", o.join(" "))
  151. }
  152. function b(e, t, n, a) {
  153. var r = i(e.toUpperCase()).indexOf(i(t.toUpperCase())),
  154. o = t.length;
  155. return 0 > r ? (n.push(a(e)), void 0) : (n.push(a(e.substring(0, r))), n.push("<span class='sp-selSrch-match'>"), n.push(a(e.substring(r, r + o))), n.push("</span>"), n.push(a(e.substring(r + o, e.length))), void 0)
  156. }
  157. function x(e) {
  158. var t = {
  159. "\\": "&#92;",
  160. "&": "&amp;",
  161. "<": "&lt;",
  162. ">": "&gt;",
  163. '"': "&quot;",
  164. "'": "&#39;",
  165. "/": "&#47;"
  166. };
  167. return String(e).replace(/[&<>"'\/\\]/g, function (e) {
  168. return t[e]
  169. })
  170. }
  171. function w(i) {
  172. var n, a = null,
  173. r = i.quietMillis || 100,
  174. o = i.url,
  175. s = this;
  176. return function (l) {
  177. window.clearTimeout(n), n = window.setTimeout(function () {
  178. var n = i.data,
  179. r = o,
  180. d = i.transport || e.fn.selectSrchFun.ajaxDefaults.transport,
  181. h = {
  182. type: i.type || "GET",
  183. cache: i.cache || !1,
  184. jsonpCallback: i.jsonpCallback || t,
  185. dataType: i.dataType || "json"
  186. },
  187. c = e.extend({}, e.fn.selectSrchFun.ajaxDefaults.params, h);
  188. n = n ? n.call(s, l.term, l.page, l.context) : null, r = "function" == typeof r ? r.call(s, l.term, l.page, l.context) : r, a && a.abort(), i.params && (e.isFunction(i.params) ? e.extend(c, i.params.call(s)) : e.extend(c, i.params)), e.extend(c, {
  189. url: r,
  190. dataType: i.dataType,
  191. data: n,
  192. success: function (e) {
  193. var t = i.results(e, l.page);
  194. l.callback(t)
  195. }
  196. }), a = d.call(s, c)
  197. }, r)
  198. }
  199. }
  200. function C(t) {
  201. var i, n, a = t,
  202. r = function (e) {
  203. return "" + e.text
  204. };
  205. e.isArray(a) && (n = a, a = {
  206. results: n
  207. }), e.isFunction(a) === !1 && (n = a, a = function () {
  208. return n
  209. });
  210. var o = a();
  211. return o.text && (r = o.text, e.isFunction(r) || (i = o.text, r = function (e) {
  212. return e[i]
  213. })), function (t) {
  214. var i, n = t.term,
  215. o = {
  216. results: []
  217. };
  218. return "" === n ? (t.callback(a()), void 0) : (i = function (a, o) {
  219. var s, l;
  220. if (a = a[0], a.children) {
  221. s = {};
  222. for (l in a) a.hasOwnProperty(l) && (s[l] = a[l]);
  223. s.children = [], e(a.children).each2(function (e, t) {
  224. i(t, s.children)
  225. }), (s.children.length || t.matcher(n, r(s), a)) && o.push(s)
  226. } else t.matcher(n, r(a), a) && o.push(a)
  227. }, e(a().results).each2(function (e, t) {
  228. i(t, o.results)
  229. }), t.callback(o), void 0)
  230. }
  231. }
  232. function _(i) {
  233. var n = e.isFunction(i);
  234. return function (a) {
  235. var r = a.term,
  236. o = {
  237. results: []
  238. };
  239. e(n ? i() : i).each(function () {
  240. var e = this.text !== t,
  241. i = e ? this.text : this;
  242. ("" === r || a.matcher(r, i)) && o.results.push(e ? this : {
  243. id: this,
  244. text: this
  245. })
  246. }), a.callback(o)
  247. }
  248. }
  249. function T(t, i) {
  250. if (e.isFunction(t)) return !0;
  251. if (!t) return !1;
  252. throw new Error(i + " must be a function or a falsy value")
  253. }
  254. function k(t) {
  255. return e.isFunction(t) ? t() : t
  256. }
  257. function M(t) {
  258. var i = 0;
  259. return e.each(t, function (e, t) {
  260. t.children ? i += M(t.children) : i++
  261. }), i
  262. }
  263. function S(e, i, n, a) {
  264. var o, s, l, d, h, c = e,
  265. u = !1;
  266. if (!a.createSearchChoice || !a.tokenSeparators || a.tokenSeparators.length < 1) return t;
  267. for (; ;) {
  268. for (s = -1, l = 0, d = a.tokenSeparators.length; d > l && (h = a.tokenSeparators[l], s = e.indexOf(h), !(s >= 0)) ; l++);
  269. if (0 > s) break;
  270. if (o = e.substring(0, s), e = e.substring(s + h.length), o.length > 0 && (o = a.createSearchChoice.call(this, o, i), o !== t && null !== o && a.id(o) !== t && null !== a.id(o))) {
  271. for (u = !1, l = 0, d = i.length; d > l; l++) if (r(a.id(o), a.id(i[l]))) {
  272. u = !0;
  273. break
  274. }
  275. u || n(o)
  276. }
  277. }
  278. return c !== e ? e : void 0
  279. }
  280. function E(t, i) {
  281. var n = function () { };
  282. return n.prototype = new t, n.prototype.constructor = n, n.prototype.parent = t.prototype, n.prototype = e.extend(n.prototype, i), n
  283. }
  284. if (window.Select2 === t) {
  285. var A, I, R, N, D, j, P, L, O = {
  286. x: 0,
  287. y: 0
  288. },
  289. A = {
  290. TAB: 9,
  291. ENTER: 13,
  292. ESC: 27,
  293. SPACE: 32,
  294. LEFT: 37,
  295. UP: 38,
  296. RIGHT: 39,
  297. DOWN: 40,
  298. SHIFT: 16,
  299. CTRL: 17,
  300. ALT: 18,
  301. PAGE_UP: 33,
  302. PAGE_DOWN: 34,
  303. HOME: 36,
  304. END: 35,
  305. BACKSPACE: 8,
  306. DELETE: 46,
  307. isArrow: function (e) {
  308. switch (e = e.which ? e.which : e) {
  309. case A.LEFT:
  310. case A.RIGHT:
  311. case A.UP:
  312. case A.DOWN:
  313. return !0
  314. }
  315. return !1
  316. },
  317. isControl: function (e) {
  318. var t = e.which;
  319. switch (t) {
  320. case A.SHIFT:
  321. case A.CTRL:
  322. case A.ALT:
  323. return !0
  324. }
  325. return e.metaKey ? !0 : !1
  326. },
  327. isFunctionKey: function (e) {
  328. return e = e.which ? e.which : e, e >= 112 && 123 >= e
  329. }
  330. },
  331. H = "<div class='sp-selSrch-measure-scrollbar'></div>",
  332. B = {
  333. "Ⓐ": "A",
  334. "A": "A",
  335. "À": "A",
  336. "Á": "A",
  337. "Â": "A",
  338. "Ầ": "A",
  339. "Ấ": "A",
  340. "Ẫ": "A",
  341. "Ẩ": "A",
  342. "Ã": "A",
  343. "Ā": "A",
  344. "Ă": "A",
  345. "Ằ": "A",
  346. "Ắ": "A",
  347. "Ẵ": "A",
  348. "Ẳ": "A",
  349. "Ȧ": "A",
  350. "Ǡ": "A",
  351. "Ä": "A",
  352. "Ǟ": "A",
  353. "Ả": "A",
  354. "Å": "A",
  355. "Ǻ": "A",
  356. "Ǎ": "A",
  357. "Ȁ": "A",
  358. "Ȃ": "A",
  359. "Ạ": "A",
  360. "Ậ": "A",
  361. "Ặ": "A",
  362. "Ḁ": "A",
  363. "Ą": "A",
  364. "Ⱥ": "A",
  365. "Ɐ": "A",
  366. "Ꜳ": "AA",
  367. "Æ": "AE",
  368. "Ǽ": "AE",
  369. "Ǣ": "AE",
  370. "Ꜵ": "AO",
  371. "Ꜷ": "AU",
  372. "Ꜹ": "AV",
  373. "Ꜻ": "AV",
  374. "Ꜽ": "AY",
  375. "Ⓑ": "B",
  376. "B": "B",
  377. "Ḃ": "B",
  378. "Ḅ": "B",
  379. "Ḇ": "B",
  380. "Ƀ": "B",
  381. "Ƃ": "B",
  382. "Ɓ": "B",
  383. "Ⓒ": "C",
  384. "C": "C",
  385. "Ć": "C",
  386. "Ĉ": "C",
  387. "Ċ": "C",
  388. "Č": "C",
  389. "Ç": "C",
  390. "Ḉ": "C",
  391. "Ƈ": "C",
  392. "Ȼ": "C",
  393. "Ꜿ": "C",
  394. "Ⓓ": "D",
  395. "D": "D",
  396. "Ḋ": "D",
  397. "Ď": "D",
  398. "Ḍ": "D",
  399. "Ḑ": "D",
  400. "Ḓ": "D",
  401. "Ḏ": "D",
  402. "Đ": "D",
  403. "Ƌ": "D",
  404. "Ɗ": "D",
  405. "Ɖ": "D",
  406. "Ꝺ": "D",
  407. "DZ": "DZ",
  408. "DŽ": "DZ",
  409. "Dz": "Dz",
  410. "Dž": "Dz",
  411. "Ⓔ": "E",
  412. "E": "E",
  413. "È": "E",
  414. "É": "E",
  415. "Ê": "E",
  416. "Ề": "E",
  417. "Ế": "E",
  418. "Ễ": "E",
  419. "Ể": "E",
  420. "Ẽ": "E",
  421. "Ē": "E",
  422. "Ḕ": "E",
  423. "Ḗ": "E",
  424. "Ĕ": "E",
  425. "Ė": "E",
  426. "Ë": "E",
  427. "Ẻ": "E",
  428. "Ě": "E",
  429. "Ȅ": "E",
  430. "Ȇ": "E",
  431. "Ẹ": "E",
  432. "Ệ": "E",
  433. "Ȩ": "E",
  434. "Ḝ": "E",
  435. "Ę": "E",
  436. "Ḙ": "E",
  437. "Ḛ": "E",
  438. "Ɛ": "E",
  439. "Ǝ": "E",
  440. "Ⓕ": "F",
  441. "F": "F",
  442. "Ḟ": "F",
  443. "Ƒ": "F",
  444. "Ꝼ": "F",
  445. "Ⓖ": "G",
  446. "G": "G",
  447. "Ǵ": "G",
  448. "Ĝ": "G",
  449. "Ḡ": "G",
  450. "Ğ": "G",
  451. "Ġ": "G",
  452. "Ǧ": "G",
  453. "Ģ": "G",
  454. "Ǥ": "G",
  455. "Ɠ": "G",
  456. "Ꞡ": "G",
  457. "Ᵹ": "G",
  458. "Ꝿ": "G",
  459. "Ⓗ": "H",
  460. "H": "H",
  461. "Ĥ": "H",
  462. "Ḣ": "H",
  463. "Ḧ": "H",
  464. "Ȟ": "H",
  465. "Ḥ": "H",
  466. "Ḩ": "H",
  467. "Ḫ": "H",
  468. "Ħ": "H",
  469. "Ⱨ": "H",
  470. "Ⱶ": "H",
  471. "Ɥ": "H",
  472. "Ⓘ": "I",
  473. "I": "I",
  474. "Ì": "I",
  475. "Í": "I",
  476. "Î": "I",
  477. "Ĩ": "I",
  478. "Ī": "I",
  479. "Ĭ": "I",
  480. "İ": "I",
  481. "Ï": "I",
  482. "Ḯ": "I",
  483. "Ỉ": "I",
  484. "Ǐ": "I",
  485. "Ȉ": "I",
  486. "Ȋ": "I",
  487. "Ị": "I",
  488. "Į": "I",
  489. "Ḭ": "I",
  490. "Ɨ": "I",
  491. "Ⓙ": "J",
  492. "J": "J",
  493. "Ĵ": "J",
  494. "Ɉ": "J",
  495. "Ⓚ": "K",
  496. "K": "K",
  497. "Ḱ": "K",
  498. "Ǩ": "K",
  499. "Ḳ": "K",
  500. "Ķ": "K",
  501. "Ḵ": "K",
  502. "Ƙ": "K",
  503. "Ⱪ": "K",
  504. "Ꝁ": "K",
  505. "Ꝃ": "K",
  506. "Ꝅ": "K",
  507. "Ꞣ": "K",
  508. "Ⓛ": "L",
  509. "L": "L",
  510. "Ŀ": "L",
  511. "Ĺ": "L",
  512. "Ľ": "L",
  513. "Ḷ": "L",
  514. "Ḹ": "L",
  515. "Ļ": "L",
  516. "Ḽ": "L",
  517. "Ḻ": "L",
  518. "Ł": "L",
  519. "Ƚ": "L",
  520. "Ɫ": "L",
  521. "Ⱡ": "L",
  522. "Ꝉ": "L",
  523. "Ꝇ": "L",
  524. "Ꞁ": "L",
  525. "LJ": "LJ",
  526. "Lj": "Lj",
  527. "Ⓜ": "M",
  528. "M": "M",
  529. "Ḿ": "M",
  530. "Ṁ": "M",
  531. "Ṃ": "M",
  532. "Ɱ": "M",
  533. "Ɯ": "M",
  534. "Ⓝ": "N",
  535. "N": "N",
  536. "Ǹ": "N",
  537. "Ń": "N",
  538. "Ñ": "N",
  539. "Ṅ": "N",
  540. "Ň": "N",
  541. "Ṇ": "N",
  542. "Ņ": "N",
  543. "Ṋ": "N",
  544. "Ṉ": "N",
  545. "Ƞ": "N",
  546. "Ɲ": "N",
  547. "Ꞑ": "N",
  548. "Ꞥ": "N",
  549. "NJ": "NJ",
  550. "Nj": "Nj",
  551. "Ⓞ": "O",
  552. "O": "O",
  553. "Ò": "O",
  554. "Ó": "O",
  555. "Ô": "O",
  556. "Ồ": "O",
  557. "Ố": "O",
  558. "Ỗ": "O",
  559. "Ổ": "O",
  560. "Õ": "O",
  561. "Ṍ": "O",
  562. "Ȭ": "O",
  563. "Ṏ": "O",
  564. "Ō": "O",
  565. "Ṑ": "O",
  566. "Ṓ": "O",
  567. "Ŏ": "O",
  568. "Ȯ": "O",
  569. "Ȱ": "O",
  570. "Ö": "O",
  571. "Ȫ": "O",
  572. "Ỏ": "O",
  573. "Ő": "O",
  574. "Ǒ": "O",
  575. "Ȍ": "O",
  576. "Ȏ": "O",
  577. "Ơ": "O",
  578. "Ờ": "O",
  579. "Ớ": "O",
  580. "Ỡ": "O",
  581. "Ở": "O",
  582. "Ợ": "O",
  583. "Ọ": "O",
  584. "Ộ": "O",
  585. "Ǫ": "O",
  586. "Ǭ": "O",
  587. "Ø": "O",
  588. "Ǿ": "O",
  589. "Ɔ": "O",
  590. "Ɵ": "O",
  591. "Ꝋ": "O",
  592. "Ꝍ": "O",
  593. "Ƣ": "OI",
  594. "Ꝏ": "OO",
  595. "Ȣ": "OU",
  596. "Ⓟ": "P",
  597. "P": "P",
  598. "Ṕ": "P",
  599. "Ṗ": "P",
  600. "Ƥ": "P",
  601. "Ᵽ": "P",
  602. "Ꝑ": "P",
  603. "Ꝓ": "P",
  604. "Ꝕ": "P",
  605. "Ⓠ": "Q",
  606. "Q": "Q",
  607. "Ꝗ": "Q",
  608. "Ꝙ": "Q",
  609. "Ɋ": "Q",
  610. "Ⓡ": "R",
  611. "R": "R",
  612. "Ŕ": "R",
  613. "Ṙ": "R",
  614. "Ř": "R",
  615. "Ȑ": "R",
  616. "Ȓ": "R",
  617. "Ṛ": "R",
  618. "Ṝ": "R",
  619. "Ŗ": "R",
  620. "Ṟ": "R",
  621. "Ɍ": "R",
  622. "Ɽ": "R",
  623. "Ꝛ": "R",
  624. "Ꞧ": "R",
  625. "Ꞃ": "R",
  626. "Ⓢ": "S",
  627. "S": "S",
  628. "ẞ": "S",
  629. "Ś": "S",
  630. "Ṥ": "S",
  631. "Ŝ": "S",
  632. "Ṡ": "S",
  633. "Š": "S",
  634. "Ṧ": "S",
  635. "Ṣ": "S",
  636. "Ṩ": "S",
  637. "Ș": "S",
  638. "Ş": "S",
  639. "Ȿ": "S",
  640. "Ꞩ": "S",
  641. "Ꞅ": "S",
  642. "Ⓣ": "T",
  643. "T": "T",
  644. "Ṫ": "T",
  645. "Ť": "T",
  646. "Ṭ": "T",
  647. "Ț": "T",
  648. "Ţ": "T",
  649. "Ṱ": "T",
  650. "Ṯ": "T",
  651. "Ŧ": "T",
  652. "Ƭ": "T",
  653. "Ʈ": "T",
  654. "Ⱦ": "T",
  655. "Ꞇ": "T",
  656. "Ꜩ": "TZ",
  657. "Ⓤ": "U",
  658. "U": "U",
  659. "Ù": "U",
  660. "Ú": "U",
  661. "Û": "U",
  662. "Ũ": "U",
  663. "Ṹ": "U",
  664. "Ū": "U",
  665. "Ṻ": "U",
  666. "Ŭ": "U",
  667. "Ü": "U",
  668. "Ǜ": "U",
  669. "Ǘ": "U",
  670. "Ǖ": "U",
  671. "Ǚ": "U",
  672. "Ủ": "U",
  673. "Ů": "U",
  674. "Ű": "U",
  675. "Ǔ": "U",
  676. "Ȕ": "U",
  677. "Ȗ": "U",
  678. "Ư": "U",
  679. "Ừ": "U",
  680. "Ứ": "U",
  681. "Ữ": "U",
  682. "Ử": "U",
  683. "Ự": "U",
  684. "Ụ": "U",
  685. "Ṳ": "U",
  686. "Ų": "U",
  687. "Ṷ": "U",
  688. "Ṵ": "U",
  689. "Ʉ": "U",
  690. "Ⓥ": "V",
  691. "V": "V",
  692. "Ṽ": "V",
  693. "Ṿ": "V",
  694. "Ʋ": "V",
  695. "Ꝟ": "V",
  696. "Ʌ": "V",
  697. "Ꝡ": "VY",
  698. "Ⓦ": "W",
  699. "W": "W",
  700. "Ẁ": "W",
  701. "Ẃ": "W",
  702. "Ŵ": "W",
  703. "Ẇ": "W",
  704. "Ẅ": "W",
  705. "Ẉ": "W",
  706. "Ⱳ": "W",
  707. "Ⓧ": "X",
  708. "X": "X",
  709. "Ẋ": "X",
  710. "Ẍ": "X",
  711. "Ⓨ": "Y",
  712. "Y": "Y",
  713. "Ỳ": "Y",
  714. "Ý": "Y",
  715. "Ŷ": "Y",
  716. "Ỹ": "Y",
  717. "Ȳ": "Y",
  718. "Ẏ": "Y",
  719. "Ÿ": "Y",
  720. "Ỷ": "Y",
  721. "Ỵ": "Y",
  722. "Ƴ": "Y",
  723. "Ɏ": "Y",
  724. "Ỿ": "Y",
  725. "Ⓩ": "Z",
  726. "Z": "Z",
  727. "Ź": "Z",
  728. "Ẑ": "Z",
  729. "Ż": "Z",
  730. "Ž": "Z",
  731. "Ẓ": "Z",
  732. "Ẕ": "Z",
  733. "Ƶ": "Z",
  734. "Ȥ": "Z",
  735. "Ɀ": "Z",
  736. "Ⱬ": "Z",
  737. "Ꝣ": "Z",
  738. "ⓐ": "a",
  739. "a": "a",
  740. "ẚ": "a",
  741. "à": "a",
  742. "á": "a",
  743. "â": "a",
  744. "ầ": "a",
  745. "ấ": "a",
  746. "ẫ": "a",
  747. "ẩ": "a",
  748. "ã": "a",
  749. "ā": "a",
  750. "ă": "a",
  751. "ằ": "a",
  752. "ắ": "a",
  753. "ẵ": "a",
  754. "ẳ": "a",
  755. "ȧ": "a",
  756. "ǡ": "a",
  757. "ä": "a",
  758. "ǟ": "a",
  759. "ả": "a",
  760. "å": "a",
  761. "ǻ": "a",
  762. "ǎ": "a",
  763. "ȁ": "a",
  764. "ȃ": "a",
  765. "ạ": "a",
  766. "ậ": "a",
  767. "ặ": "a",
  768. "ḁ": "a",
  769. "ą": "a",
  770. "ⱥ": "a",
  771. "ɐ": "a",
  772. "ꜳ": "aa",
  773. "æ": "ae",
  774. "ǽ": "ae",
  775. "ǣ": "ae",
  776. "ꜵ": "ao",
  777. "ꜷ": "au",
  778. "ꜹ": "av",
  779. "ꜻ": "av",
  780. "ꜽ": "ay",
  781. "ⓑ": "b",
  782. "b": "b",
  783. "ḃ": "b",
  784. "ḅ": "b",
  785. "ḇ": "b",
  786. "ƀ": "b",
  787. "ƃ": "b",
  788. "ɓ": "b",
  789. "ⓒ": "c",
  790. "c": "c",
  791. "ć": "c",
  792. "ĉ": "c",
  793. "ċ": "c",
  794. "č": "c",
  795. "ç": "c",
  796. "ḉ": "c",
  797. "ƈ": "c",
  798. "ȼ": "c",
  799. "ꜿ": "c",
  800. "ↄ": "c",
  801. "ⓓ": "d",
  802. "d": "d",
  803. "ḋ": "d",
  804. "ď": "d",
  805. "ḍ": "d",
  806. "ḑ": "d",
  807. "ḓ": "d",
  808. "ḏ": "d",
  809. "đ": "d",
  810. "ƌ": "d",
  811. "ɖ": "d",
  812. "ɗ": "d",
  813. "ꝺ": "d",
  814. "dz": "dz",
  815. "dž": "dz",
  816. "ⓔ": "e",
  817. "e": "e",
  818. "è": "e",
  819. "é": "e",
  820. "ê": "e",
  821. "ề": "e",
  822. "ế": "e",
  823. "ễ": "e",
  824. "ể": "e",
  825. "ẽ": "e",
  826. "ē": "e",
  827. "ḕ": "e",
  828. "ḗ": "e",
  829. "ĕ": "e",
  830. "ė": "e",
  831. "ë": "e",
  832. "ẻ": "e",
  833. "ě": "e",
  834. "ȅ": "e",
  835. "ȇ": "e",
  836. "ẹ": "e",
  837. "ệ": "e",
  838. "ȩ": "e",
  839. "ḝ": "e",
  840. "ę": "e",
  841. "ḙ": "e",
  842. "ḛ": "e",
  843. "ɇ": "e",
  844. "ɛ": "e",
  845. "ǝ": "e",
  846. "ⓕ": "f",
  847. "f": "f",
  848. "ḟ": "f",
  849. "ƒ": "f",
  850. "ꝼ": "f",
  851. "ⓖ": "g",
  852. "g": "g",
  853. "ǵ": "g",
  854. "ĝ": "g",
  855. "ḡ": "g",
  856. "ğ": "g",
  857. "ġ": "g",
  858. "ǧ": "g",
  859. "ģ": "g",
  860. "ǥ": "g",
  861. "ɠ": "g",
  862. "ꞡ": "g",
  863. "ᵹ": "g",
  864. "ꝿ": "g",
  865. "ⓗ": "h",
  866. "h": "h",
  867. "ĥ": "h",
  868. "ḣ": "h",
  869. "ḧ": "h",
  870. "ȟ": "h",
  871. "ḥ": "h",
  872. "ḩ": "h",
  873. "ḫ": "h",
  874. "ẖ": "h",
  875. "ħ": "h",
  876. "ⱨ": "h",
  877. "ⱶ": "h",
  878. "ɥ": "h",
  879. "ƕ": "hv",
  880. "ⓘ": "i",
  881. "i": "i",
  882. "ì": "i",
  883. "í": "i",
  884. "î": "i",
  885. "ĩ": "i",
  886. "ī": "i",
  887. "ĭ": "i",
  888. "ï": "i",
  889. "ḯ": "i",
  890. "ỉ": "i",
  891. "ǐ": "i",
  892. "ȉ": "i",
  893. "ȋ": "i",
  894. "ị": "i",
  895. "į": "i",
  896. "ḭ": "i",
  897. "ɨ": "i",
  898. "ı": "i",
  899. "ⓙ": "j",
  900. "j": "j",
  901. "ĵ": "j",
  902. "ǰ": "j",
  903. "ɉ": "j",
  904. "ⓚ": "k",
  905. "k": "k",
  906. "ḱ": "k",
  907. "ǩ": "k",
  908. "ḳ": "k",
  909. "ķ": "k",
  910. "ḵ": "k",
  911. "ƙ": "k",
  912. "ⱪ": "k",
  913. "ꝁ": "k",
  914. "ꝃ": "k",
  915. "ꝅ": "k",
  916. "ꞣ": "k",
  917. "ⓛ": "l",
  918. "l": "l",
  919. "ŀ": "l",
  920. "ĺ": "l",
  921. "ľ": "l",
  922. "ḷ": "l",
  923. "ḹ": "l",
  924. "ļ": "l",
  925. "ḽ": "l",
  926. "ḻ": "l",
  927. "ſ": "l",
  928. "ł": "l",
  929. "ƚ": "l",
  930. "ɫ": "l",
  931. "ⱡ": "l",
  932. "ꝉ": "l",
  933. "ꞁ": "l",
  934. "ꝇ": "l",
  935. "lj": "lj",
  936. "ⓜ": "m",
  937. "m": "m",
  938. "ḿ": "m",
  939. "ṁ": "m",
  940. "ṃ": "m",
  941. "ɱ": "m",
  942. "ɯ": "m",
  943. "ⓝ": "n",
  944. "n": "n",
  945. "ǹ": "n",
  946. "ń": "n",
  947. "ñ": "n",
  948. "ṅ": "n",
  949. "ň": "n",
  950. "ṇ": "n",
  951. "ņ": "n",
  952. "ṋ": "n",
  953. "ṉ": "n",
  954. "ƞ": "n",
  955. "ɲ": "n",
  956. "ʼn": "n",
  957. "ꞑ": "n",
  958. "ꞥ": "n",
  959. "nj": "nj",
  960. "ⓞ": "o",
  961. "o": "o",
  962. "ò": "o",
  963. "ó": "o",
  964. "ô": "o",
  965. "ồ": "o",
  966. "ố": "o",
  967. "ỗ": "o",
  968. "ổ": "o",
  969. "õ": "o",
  970. "ṍ": "o",
  971. "ȭ": "o",
  972. "ṏ": "o",
  973. "ō": "o",
  974. "ṑ": "o",
  975. "ṓ": "o",
  976. "ŏ": "o",
  977. "ȯ": "o",
  978. "ȱ": "o",
  979. "ö": "o",
  980. "ȫ": "o",
  981. "ỏ": "o",
  982. "ő": "o",
  983. "ǒ": "o",
  984. "ȍ": "o",
  985. "ȏ": "o",
  986. "ơ": "o",
  987. "ờ": "o",
  988. "ớ": "o",
  989. "ỡ": "o",
  990. "ở": "o",
  991. "ợ": "o",
  992. "ọ": "o",
  993. "ộ": "o",
  994. "ǫ": "o",
  995. "ǭ": "o",
  996. "ø": "o",
  997. "ǿ": "o",
  998. "ɔ": "o",
  999. "ꝋ": "o",
  1000. "ꝍ": "o",
  1001. "ɵ": "o",
  1002. "ƣ": "oi",
  1003. "ȣ": "ou",
  1004. "ꝏ": "oo",
  1005. "ⓟ": "p",
  1006. "p": "p",
  1007. "ṕ": "p",
  1008. "ṗ": "p",
  1009. "ƥ": "p",
  1010. "ᵽ": "p",
  1011. "ꝑ": "p",
  1012. "ꝓ": "p",
  1013. "ꝕ": "p",
  1014. "ⓠ": "q",
  1015. "q": "q",
  1016. "ɋ": "q",
  1017. "ꝗ": "q",
  1018. "ꝙ": "q",
  1019. "ⓡ": "r",
  1020. "r": "r",
  1021. "ŕ": "r",
  1022. "ṙ": "r",
  1023. "ř": "r",
  1024. "ȑ": "r",
  1025. "ȓ": "r",
  1026. "ṛ": "r",
  1027. "ṝ": "r",
  1028. "ŗ": "r",
  1029. "ṟ": "r",
  1030. "ɍ": "r",
  1031. "ɽ": "r",
  1032. "ꝛ": "r",
  1033. "ꞧ": "r",
  1034. "ꞃ": "r",
  1035. "ⓢ": "s",
  1036. "s": "s",
  1037. "ß": "s",
  1038. "ś": "s",
  1039. "ṥ": "s",
  1040. "ŝ": "s",
  1041. "ṡ": "s",
  1042. "š": "s",
  1043. "ṧ": "s",
  1044. "ṣ": "s",
  1045. "ṩ": "s",
  1046. "ș": "s",
  1047. "ş": "s",
  1048. "ȿ": "s",
  1049. "ꞩ": "s",
  1050. "ꞅ": "s",
  1051. "ẛ": "s",
  1052. "ⓣ": "t",
  1053. "t": "t",
  1054. "ṫ": "t",
  1055. "ẗ": "t",
  1056. "ť": "t",
  1057. "ṭ": "t",
  1058. "ț": "t",
  1059. "ţ": "t",
  1060. "ṱ": "t",
  1061. "ṯ": "t",
  1062. "ŧ": "t",
  1063. "ƭ": "t",
  1064. "ʈ": "t",
  1065. "ⱦ": "t",
  1066. "ꞇ": "t",
  1067. "ꜩ": "tz",
  1068. "ⓤ": "u",
  1069. "u": "u",
  1070. "ù": "u",
  1071. "ú": "u",
  1072. "û": "u",
  1073. "ũ": "u",
  1074. "ṹ": "u",
  1075. "ū": "u",
  1076. "ṻ": "u",
  1077. "ŭ": "u",
  1078. "ü": "u",
  1079. "ǜ": "u",
  1080. "ǘ": "u",
  1081. "ǖ": "u",
  1082. "ǚ": "u",
  1083. "ủ": "u",
  1084. "ů": "u",
  1085. "ű": "u",
  1086. "ǔ": "u",
  1087. "ȕ": "u",
  1088. "ȗ": "u",
  1089. "ư": "u",
  1090. "ừ": "u",
  1091. "ứ": "u",
  1092. "ữ": "u",
  1093. "ử": "u",
  1094. "ự": "u",
  1095. "ụ": "u",
  1096. "ṳ": "u",
  1097. "ų": "u",
  1098. "ṷ": "u",
  1099. "ṵ": "u",
  1100. "ʉ": "u",
  1101. "ⓥ": "v",
  1102. "v": "v",
  1103. "ṽ": "v",
  1104. "ṿ": "v",
  1105. "ʋ": "v",
  1106. "ꝟ": "v",
  1107. "ʌ": "v",
  1108. "ꝡ": "vy",
  1109. "ⓦ": "w",
  1110. "w": "w",
  1111. "ẁ": "w",
  1112. "ẃ": "w",
  1113. "ŵ": "w",
  1114. "ẇ": "w",
  1115. "ẅ": "w",
  1116. "ẘ": "w",
  1117. "ẉ": "w",
  1118. "ⱳ": "w",
  1119. "ⓧ": "x",
  1120. "x": "x",
  1121. "ẋ": "x",
  1122. "ẍ": "x",
  1123. "ⓨ": "y",
  1124. "y": "y",
  1125. "ỳ": "y",
  1126. "ý": "y",
  1127. "ŷ": "y",
  1128. "ỹ": "y",
  1129. "ȳ": "y",
  1130. "ẏ": "y",
  1131. "ÿ": "y",
  1132. "ỷ": "y",
  1133. "ẙ": "y",
  1134. "ỵ": "y",
  1135. "ƴ": "y",
  1136. "ɏ": "y",
  1137. "ỿ": "y",
  1138. "ⓩ": "z",
  1139. "z": "z",
  1140. "ź": "z",
  1141. "ẑ": "z",
  1142. "ż": "z",
  1143. "ž": "z",
  1144. "ẓ": "z",
  1145. "ẕ": "z",
  1146. "ƶ": "z",
  1147. "ȥ": "z",
  1148. "ɀ": "z",
  1149. "ⱬ": "z",
  1150. "ꝣ": "z"
  1151. };
  1152. P = e(document), D = function () {
  1153. var e = 1;
  1154. return function () {
  1155. return e++
  1156. }
  1157. }(), P.on("mousemove", function (e) {
  1158. O.x = e.pageX, O.y = e.pageY
  1159. }), I = E(Object, {
  1160. bind: function (e) {
  1161. var t = this;
  1162. return function () {
  1163. e.apply(t, arguments)
  1164. }
  1165. },
  1166. init: function (i) {
  1167. var n, r, o, s, h = ".sp-selSrch-results";
  1168. this.opts = i = this.prepareOpts(i), this.id = i.id, i.element.data("selectSrchFun") !== t && null !== i.element.data("selectSrchFun") && i.element.data("selectSrchFun").destroy(), this.container = this.createContainer(), this.containerId = "s2id_" + (i.element.attr("id") || "autogen" + D()), this.containerSelector = "#" + this.containerId.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, "\\$1"), this.container.attr("id", this.containerId), this.body = c(function () {
  1169. return i.element.closest("body")
  1170. }), y(this.container, this.opts.element, this.opts.adaptContainerCssClass), this.container.attr("style", i.element.attr("style")), this.container.css(k(i.containerCss)), this.container.addClass(k(i.containerCssClass)), this.elementTabIndex = this.opts.element.attr("tabindex"), this.opts.element.data("selectSrchFun", this).attr("tabindex", "-1").before(this.container).on("click.selectSrchFun", f), this.container.data("selectSrchFun", this), this.dropdown = this.container.find(".sp-selSrch-drop"), y(this.dropdown, this.opts.element, this.opts.adaptDropdownCssClass), this.dropdown.addClass(k(i.dropdownCssClass)), this.dropdown.data("selectSrchFun", this), this.dropdown.on("click", f), this.results = n = this.container.find(h), this.search = r = this.container.find("input.sp-selSrch-input"), this.queryCount = 0, this.resultsPage = 0, this.context = null, this.initContainer(), this.container.on("click", f), d(this.results), this.dropdown.on("mousemove-filtered touchstart touchmove touchend", h, this.bind(this.highlightUnderEvent)), u(80, this.results), this.dropdown.on("scroll-debounced", h, this.bind(this.loadMoreIfNeeded)), e(this.container).on("change", ".sp-selSrch-input", function (e) {
  1171. e.stopPropagation()
  1172. }), e(this.dropdown).on("change", ".sp-selSrch-input", function (e) {
  1173. e.stopPropagation()
  1174. }), e.fn.mousewheel && n.mousewheel(function (e, t, i, a) {
  1175. var r = n.scrollTop();
  1176. a > 0 && 0 >= r - a ? (n.scrollTop(0), f(e)) : 0 > a && n.get(0).scrollHeight - n.scrollTop() + a <= n.height() && (n.scrollTop(n.get(0).scrollHeight - n.height()), f(e))
  1177. }), l(r), r.on("keyup-change input paste", this.bind(this.updateResults)), r.on("focus", function () {
  1178. r.addClass("sp-selSrch-focused")
  1179. }), r.on("blur", function () {
  1180. r.removeClass("sp-selSrch-focused")
  1181. }), this.dropdown.on("mouseup", h, this.bind(function (t) {
  1182. e(t.target).closest(".sp-selSrch-result-selectable").length > 0 && (this.highlightUnderEvent(t), this.selectHighlighted(t))
  1183. })), this.dropdown.on("click mouseup mousedown", function (e) {
  1184. e.stopPropagation()
  1185. }), e.isFunction(this.opts.initSelection) && (this.initSelection(), this.monitorSource()), null !== i.maximumInputLength && this.search.attr("maxlength", i.maximumInputLength);
  1186. var o = i.element.prop("disabled");
  1187. o === t && (o = !1), this.enable(!o);
  1188. var s = i.element.prop("readonly");
  1189. s === t && (s = !1), this.readonly(s), L = L || a(), this.autofocus = i.element.prop("autofocus"), i.element.prop("autofocus", !1), this.autofocus && this.focus(), this.nextSearchTerm = t
  1190. },
  1191. destroy: function () {
  1192. var e = this.opts.element,
  1193. i = e.data("selectSrchFun");
  1194. this.close(), this.propertyObserver && (delete this.propertyObserver, this.propertyObserver = null), i !== t && (i.container.remove(), i.dropdown.remove(), e.removeClass("sp-selSrch-offscreen").removeData("selectSrchFun").off(".selectSrchFun").prop("autofocus", this.autofocus || !1), this.elementTabIndex ? e.attr({
  1195. tabindex: this.elementTabIndex
  1196. }) : e.removeAttr("tabindex"), e.show())
  1197. },
  1198. optionToData: function (e) {
  1199. return e.is("option") ? {
  1200. id: e.prop("value"),
  1201. text: e.text(),
  1202. element: e.get(),
  1203. css: e.attr("class"),
  1204. disabled: e.prop("disabled"),
  1205. locked: r(e.attr("locked"), "locked") || r(e.data("locked"), !0)
  1206. } : e.is("optgroup") ? {
  1207. text: e.attr("label"),
  1208. children: [],
  1209. element: e.get(),
  1210. css: e.attr("class")
  1211. } : void 0
  1212. },
  1213. prepareOpts: function (i) {
  1214. var n, a, s, l, d = this;
  1215. if (n = i.element, "select" === n.get(0).tagName.toLowerCase() && (this.select = a = i.element), a && e.each(["id", "multiple", "ajax", "query", "createSearchChoice", "initSelection", "data", "tags"], function () {
  1216. if (this in i) throw new Error("Option '" + this + "' is not allowed for Select2 when attached to a <select> element.")
  1217. }), i = e.extend({}, {
  1218. populateResults: function (n, a, r) {
  1219. var o, s = this.opts.id;
  1220. o = function (n, a, l) {
  1221. var h, c, u, p, g, f, m, v, y, b;
  1222. for (n = i.sortResults(n, a, r), h = 0, c = n.length; c > h; h += 1) u = n[h], g = u.disabled === !0, p = !g && s(u) !== t, f = u.children && u.children.length > 0, m = e("<li></li>"), m.addClass("sp-selSrch-results-dept-" + l), m.addClass("sp-selSrch-result"), m.addClass(p ? "sp-selSrch-result-selectable" : "sp-selSrch-result-unselectable"), g && m.addClass("sp-selSrch-disabled"), f && m.addClass("sp-selSrch-result-with-children"), m.addClass(d.opts.formatResultCssClass(u)), v = e(document.createElement("div")), v.addClass("sp-selSrch-result-label"), b = i.formatResult(u, v, r, d.opts.escapeMarkup), b !== t && v.html(b), m.append(v), f && (y = e("<ul></ul>"), y.addClass("sp-selSrch-result-sub"), o(u.children, y, l + 1), m.append(y)), m.data("sp-selSrch-data", u), a.append(m)
  1223. }, o(a, n, 0)
  1224. }
  1225. }, e.fn.selectSrchFun.defaults, i), "function" != typeof i.id && (s = i.id, i.id = function (e) {
  1226. return e[s]
  1227. }), e.isArray(i.element.data("select2Tags"))) {
  1228. if ("tags" in i) throw "tags specified as both an attribute 'data-sp-selSrch-tags' and in options of Select2 " + i.element.attr("id");
  1229. i.tags = i.element.data("select2Tags")
  1230. }
  1231. if (a ? (i.query = this.bind(function (e) {
  1232. var i, a, r, o = {
  1233. results: [],
  1234. more: !1
  1235. },
  1236. s = e.term;
  1237. r = function (t, i) {
  1238. var n;
  1239. t.is("option") ? e.matcher(s, t.text(), t) && i.push(d.optionToData(t)) : t.is("optgroup") && (n = d.optionToData(t), t.children().each2(function (e, t) {
  1240. r(t, n.children)
  1241. }), n.children.length > 0 && i.push(n))
  1242. }, i = n.children(), this.getPlaceholder() !== t && i.length > 0 && (a = this.getPlaceholderOption(), a && (i = i.not(a))), i.each2(function (e, t) {
  1243. r(t, o.results)
  1244. }), e.callback(o)
  1245. }), i.id = function (e) {
  1246. return e.id
  1247. }, i.formatResultCssClass = function (e) {
  1248. return e.css
  1249. }) : "query" in i || ("ajax" in i ? (l = i.element.data("ajax-url"), l && l.length > 0 && (i.ajax.url = l), i.query = w.call(i.element, i.ajax)) : "data" in i ? i.query = C(i.data) : "tags" in i && (i.query = _(i.tags), i.createSearchChoice === t && (i.createSearchChoice = function (t) {
  1250. return {
  1251. id: e.trim(t),
  1252. text: e.trim(t)
  1253. }
  1254. }), i.initSelection === t && (i.initSelection = function (t, n) {
  1255. var a = [];
  1256. e(o(t.val(), i.separator)).each(function () {
  1257. var t = {
  1258. id: this,
  1259. text: this
  1260. },
  1261. n = i.tags;
  1262. e.isFunction(n) && (n = n()), e(n).each(function () {
  1263. return r(this.id, t.id) ? (t = this, !1) : void 0
  1264. }), a.push(t)
  1265. }), n(a)
  1266. }))), "function" != typeof i.query) throw "query function not defined for Select2 " + i.element.attr("id");
  1267. return i
  1268. },
  1269. monitorSource: function () {
  1270. var e, i = this.opts.element;
  1271. i.on("change.selectSrchFun", this.bind(function () {
  1272. this.opts.element.data("sp-selSrch-change-triggered") !== !0 && this.initSelection()
  1273. })), e = this.bind(function () {
  1274. var e, n = i.prop("disabled");
  1275. n === t && (n = !1), this.enable(!n);
  1276. var e = i.prop("readonly");
  1277. e === t && (e = !1), this.readonly(e), y(this.container, this.opts.element, this.opts.adaptContainerCssClass), this.container.addClass(k(this.opts.containerCssClass)), y(this.dropdown, this.opts.element, this.opts.adaptDropdownCssClass), this.dropdown.addClass(k(this.opts.dropdownCssClass))
  1278. }), i.on("propertychange.selectSrchFun DOMAttrModified.selectSrchFun", e), this.mutationCallback === t && (this.mutationCallback = function (t) {
  1279. t.forEach(e)
  1280. }), "undefined" != typeof WebKitMutationObserver && (this.propertyObserver && (delete this.propertyObserver, this.propertyObserver = null), this.propertyObserver = new WebKitMutationObserver(this.mutationCallback), this.propertyObserver.observe(i.get(0), {
  1281. attributes: !0,
  1282. subtree: !1
  1283. }))
  1284. },
  1285. triggerSelect: function (t) {
  1286. var i = e.Event("sp-selSrch-selecting", {
  1287. val: this.id(t),
  1288. object: t
  1289. });
  1290. return this.opts.element.trigger(i), !i.isDefaultPrevented()
  1291. },
  1292. triggerChange: function (t) {
  1293. t = t || {}, t = e.extend({}, t, {
  1294. type: "change",
  1295. val: this.val()
  1296. }), this.opts.element.data("sp-selSrch-change-triggered", !0), this.opts.element.trigger(t), this.opts.element.data("sp-selSrch-change-triggered", !1), this.opts.element.click(), this.opts.blurOnChange && this.opts.element.blur()
  1297. },
  1298. isInterfaceEnabled: function () {
  1299. return this.enabledInterface === !0
  1300. },
  1301. enableInterface: function () {
  1302. var e = this._enabled && !this._readonly,
  1303. t = !e;
  1304. return e === this.enabledInterface ? !1 : (this.container.toggleClass("sp-selSrch-container-disabled", t), this.close(), this.enabledInterface = e, !0)
  1305. },
  1306. enable: function (e) {
  1307. e === t && (e = !0), this._enabled !== e && (this._enabled = e, this.opts.element.prop("disabled", !e), this.enableInterface())
  1308. },
  1309. disable: function () {
  1310. this.enable(!1)
  1311. },
  1312. readonly: function (e) {
  1313. return e === t && (e = !1), this._readonly === e ? !1 : (this._readonly = e, this.opts.element.prop("readonly", e), this.enableInterface(), !0)
  1314. },
  1315. opened: function () {
  1316. return this.container.hasClass("sp-selSrch-dropdown-open")
  1317. },
  1318. positionDropdown: function () {
  1319. var t, i, n, a, r = this.dropdown,
  1320. o = this.container.offset(),
  1321. s = this.container.outerHeight(!1),
  1322. l = r.outerHeight(!1),
  1323. d = e(window).scrollLeft() + e(window).width(),
  1324. h = e(window).scrollTop() + e(window).height(),
  1325. c = o.top + s,
  1326. u = o.left,
  1327. p = h >= c + l,
  1328. g = o.top - l >= this.body().scrollTop(),
  1329. f = r.outerWidth(!1),
  1330. m = d >= u + f,
  1331. v = r.hasClass("sp-selSrch-drop-above");
  1332. if (selectSrchInit.isIE8() || selectSrchInit.isIE9()) var y = this.container.outerWidth(!1);
  1333. else var y = window.getComputedStyle(this.container[0]).width;
  1334. this.opts.dropdownAutoWidth ? (a = e(".sp-selSrch-results", r)[0], r.addClass("sp-selSrch-drop-auto-width"), r.css("width", ""), f = r.outerWidth(!1) + (a.scrollHeight === a.clientHeight ? 0 : L.width), f > y ? y = f : f = y, m = d >= u + f) : this.container.removeClass("sp-selSrch-drop-auto-width"), "static" !== this.body().css("position") && (t = this.body().offset(), c -= t.top, u -= t.left), v ? (i = !0, !g && p && (i = !1)) : (i = !1, !p && g && (i = !0)), m || (u = o.left + y - f), i ? (c = o.top - l, this.container.addClass("sp-selSrch-drop-above"), r.addClass("sp-selSrch-drop-above")) : (this.container.removeClass("sp-selSrch-drop-above"), r.removeClass("sp-selSrch-drop-above")), n = e.extend({
  1335. top: c,
  1336. left: u,
  1337. width: y
  1338. }, k(this.opts.dropdownCss)), r.css(n)
  1339. },
  1340. shouldOpen: function () {
  1341. var t;
  1342. return this.opened() ? !1 : this._enabled === !1 || this._readonly === !0 ? !1 : (t = e.Event("sp-selSrch-opening"), this.opts.element.trigger(t), !t.isDefaultPrevented())
  1343. },
  1344. clearDropdownAlignmentPreference: function () {
  1345. this.container.removeClass("sp-selSrch-drop-above"), this.dropdown.removeClass("sp-selSrch-drop-above")
  1346. },
  1347. open: function () {
  1348. return this.shouldOpen() ? (this.opening(), !0) : !1
  1349. },
  1350. opening: function () {
  1351. var t, i = this.containerId,
  1352. n = "scroll." + i,
  1353. a = "resize." + i,
  1354. r = "orientationchange." + i;
  1355. this.container.addClass("sp-selSrch-dropdown-open").addClass("sp-selSrch-container-active"), this.clearDropdownAlignmentPreference(), this.dropdown[0] !== this.body().children().last()[0] && this.dropdown.detach().appendTo(this.body()), t = e("#sp-selSrch-drop-mask"), 0 == t.length && (t = e(document.createElement("div")), t.attr("id", "sp-selSrch-drop-mask").attr("class", "sp-selSrch-drop-mask"), t.hide(), t.appendTo(this.body()), t.on("mousedown touchstart click", function (t) {
  1356. var i, n = e("#sp-selSrch-drop");
  1357. n.length > 0 && (i = n.data("selectSrchFun"), i.opts.selectOnBlur && i.selectHighlighted({
  1358. noFocus: !0
  1359. }), i.close({
  1360. focus: !1
  1361. }), t.preventDefault(), t.stopPropagation())
  1362. })), this.dropdown.prev()[0] !== t[0] && this.dropdown.before(t), e("#sp-selSrch-drop").removeAttr("id"), this.dropdown.attr("id", "sp-selSrch-drop"), t.show(), this.positionDropdown(), this.dropdown.show(), this.positionDropdown(), this.dropdown.addClass("sp-selSrch-drop-active");
  1363. var o = this;
  1364. this.container.parents().add(window).each(function () {
  1365. e(this).on(a + " " + n + " " + r, function () {
  1366. o.positionDropdown()
  1367. })
  1368. })
  1369. },
  1370. close: function () {
  1371. if (this.opened()) {
  1372. var t = this.containerId,
  1373. i = "scroll." + t,
  1374. n = "resize." + t,
  1375. a = "orientationchange." + t;
  1376. this.container.parents().add(window).each(function () {
  1377. e(this).off(i).off(n).off(a)
  1378. }), this.clearDropdownAlignmentPreference(), e("#sp-selSrch-drop-mask").hide(), this.dropdown.removeAttr("id"), this.dropdown.hide(), this.container.removeClass("sp-selSrch-dropdown-open").removeClass("sp-selSrch-container-active"), this.results.empty(), this.clearSearch(), this.search.removeClass("sp-selSrch-active"), this.opts.element.trigger(e.Event("sp-selSrch-close"))
  1379. }
  1380. },
  1381. externalSearch: function (e) {
  1382. this.open(), this.search.val(e), this.updateResults(!1)
  1383. },
  1384. clearSearch: function () { },
  1385. getMaximumSelectionSize: function () {
  1386. return k(this.opts.maximumSelectionSize)
  1387. },
  1388. ensureHighlightVisible: function () {
  1389. var t, i, n, a, r, o, s, l = this.results;
  1390. if (i = this.highlight(), !(0 > i)) {
  1391. if (0 == i) return l.scrollTop(0), void 0;
  1392. t = this.findHighlightableChoices().find(".sp-selSrch-result-label"), n = e(t[i]), a = n.offset().top + n.outerHeight(!0), i === t.length - 1 && (s = l.find("li.sp-selSrch-more-results"), s.length > 0 && (a = s.offset().top + s.outerHeight(!0))), r = l.offset().top + l.outerHeight(!0), a > r && l.scrollTop(l.scrollTop() + (a - r)), o = n.offset().top - l.offset().top, 0 > o && "none" != n.css("display") && l.scrollTop(l.scrollTop() + o)
  1393. }
  1394. },
  1395. findHighlightableChoices: function () {
  1396. return this.results.find(".sp-selSrch-result-selectable:not(.sp-selSrch-disabled)")
  1397. },
  1398. moveHighlight: function (t) {
  1399. for (var i = this.findHighlightableChoices(), n = this.highlight() ; n > -1 && n < i.length;) {
  1400. n += t;
  1401. var a = e(i[n]);
  1402. if (a.hasClass("sp-selSrch-result-selectable") && !a.hasClass("sp-selSrch-disabled") && !a.hasClass("sp-selSrch-selected")) {
  1403. this.highlight(n);
  1404. break
  1405. }
  1406. }
  1407. },
  1408. highlight: function (t) {
  1409. var i, a, r = this.findHighlightableChoices();
  1410. return 0 === arguments.length ? n(r.filter(".sp-selSrch-highlighted")[0], r.get()) : (t >= r.length && (t = r.length - 1), 0 > t && (t = 0), this.removeHighlight(), i = e(r[t]), i.addClass("sp-selSrch-highlighted"), this.ensureHighlightVisible(), a = i.data("sp-selSrch-data"), a && this.opts.element.trigger({
  1411. type: "sp-selSrch-highlight",
  1412. val: this.id(a),
  1413. choice: a
  1414. }), void 0)
  1415. },
  1416. removeHighlight: function () {
  1417. this.results.find(".sp-selSrch-highlighted").removeClass("sp-selSrch-highlighted")
  1418. },
  1419. countSelectableResults: function () {
  1420. return this.findHighlightableChoices().length
  1421. },
  1422. highlightUnderEvent: function (t) {
  1423. var i = e(t.target).closest(".sp-selSrch-result-selectable");
  1424. if (i.length > 0 && !i.is(".sp-selSrch-highlighted")) {
  1425. var n = this.findHighlightableChoices();
  1426. this.highlight(n.index(i))
  1427. } else 0 == i.length && this.removeHighlight()
  1428. },
  1429. loadMoreIfNeeded: function () {
  1430. var e, t = this.results,
  1431. i = t.find("li.sp-selSrch-more-results"),
  1432. n = this.resultsPage + 1,
  1433. a = this,
  1434. r = this.search.val(),
  1435. o = this.context;
  1436. 0 !== i.length && (e = i.offset().top - t.offset().top - t.height(), e <= this.opts.loadMorePadding && (i.addClass("sp-selSrch-active"), this.opts.query({
  1437. element: this.opts.element,
  1438. term: r,
  1439. page: n,
  1440. context: o,
  1441. matcher: this.opts.matcher,
  1442. callback: this.bind(function (e) {
  1443. a.opened() && (a.opts.populateResults.call(this, t, e.results, {
  1444. term: r,
  1445. page: n,
  1446. context: o
  1447. }), a.postprocessResults(e, !1, !1), e.more === !0 ? (i.detach().appendTo(t).text(a.opts.formatLoadMore(n + 1)), window.setTimeout(function () {
  1448. a.loadMoreIfNeeded()
  1449. }, 10)) : i.remove(), a.positionDropdown(), a.resultsPage = n, a.context = e.context, this.opts.element.trigger({
  1450. type: "sp-selSrch-loaded",
  1451. items: e
  1452. }))
  1453. })
  1454. })))
  1455. },
  1456. tokenize: function () { },
  1457. updateResults: function (i) {
  1458. function n() {
  1459. d.removeClass("sp-selSrch-active"), u.positionDropdown()
  1460. }
  1461. function a(e) {
  1462. h.html(e), n()
  1463. }
  1464. var o, s, l, d = this.search,
  1465. h = this.results,
  1466. c = this.opts,
  1467. u = this,
  1468. p = d.val(),
  1469. g = e.data(this.container, "sp-selSrch-last-term");
  1470. if ((i === !0 || !g || !r(p, g)) && (e.data(this.container, "sp-selSrch-last-term", p), i === !0 || this.showSearchInput !== !1 && this.opened())) {
  1471. l = ++this.queryCount;
  1472. var f = this.getMaximumSelectionSize();
  1473. if (f >= 1 && (o = this.data(), e.isArray(o) && o.length >= f && T(c.formatSelectionTooBig, "formatSelectionTooBig"))) return a("<li class='sp-selSrch-selection-limit'>" + c.formatSelectionTooBig(f) + "</li>"), void 0;
  1474. if (d.val().length < c.minimumInputLength) return T(c.formatInputTooShort, "formatInputTooShort") ? a("<li class='sp-selSrch-no-results'>" + c.formatInputTooShort(d.val(), c.minimumInputLength) + "</li>") : a(""), i && this.showSearch && this.showSearch(!0), void 0;
  1475. if (c.maximumInputLength && d.val().length > c.maximumInputLength) return T(c.formatInputTooLong, "formatInputTooLong") ? a("<li class='sp-selSrch-no-results'>" + c.formatInputTooLong(d.val(), c.maximumInputLength) + "</li>") : a(""), void 0;
  1476. c.formatSearching && 0 === this.findHighlightableChoices().length && a("<li class='sp-selSrch-searching'>" + c.formatSearching() + "</li>"), d.addClass("sp-selSrch-active"), this.removeHighlight(), s = this.tokenize(), s != t && null != s && d.val(s), this.resultsPage = 1, c.query({
  1477. element: c.element,
  1478. term: d.val(),
  1479. page: this.resultsPage,
  1480. context: null,
  1481. matcher: c.matcher,
  1482. callback: this.bind(function (o) {
  1483. var s;
  1484. if (l == this.queryCount) {
  1485. if (!this.opened()) return this.search.removeClass("sp-selSrch-active"), void 0;
  1486. if (this.context = o.context === t ? null : o.context, this.opts.createSearchChoice && "" !== d.val() && (s = this.opts.createSearchChoice.call(u, d.val(), o.results), s !== t && null !== s && u.id(s) !== t && null !== u.id(s) && 0 === e(o.results).filter(function () {
  1487. return r(u.id(this), u.id(s))
  1488. }).length && o.results.unshift(s)), 0 === o.results.length && T(c.formatNoMatches, "formatNoMatches")) return a("<li class='sp-selSrch-no-results'>" + c.formatNoMatches(d.val()) + "</li>"), void 0;
  1489. h.empty(), u.opts.populateResults.call(this, h, o.results, {
  1490. term: d.val(),
  1491. page: this.resultsPage,
  1492. context: null
  1493. }), o.more === !0 && T(c.formatLoadMore, "formatLoadMore") && (h.append("<li class='sp-selSrch-more-results'>" + u.opts.escapeMarkup(c.formatLoadMore(this.resultsPage)) + "</li>"), window.setTimeout(function () {
  1494. u.loadMoreIfNeeded()
  1495. }, 10)), this.postprocessResults(o, i), n(), this.opts.element.trigger({
  1496. type: "sp-selSrch-loaded",
  1497. items: o
  1498. })
  1499. }
  1500. })
  1501. })
  1502. }
  1503. },
  1504. cancel: function () {
  1505. this.close()
  1506. },
  1507. blur: function () {
  1508. this.opts.selectOnBlur && this.selectHighlighted({
  1509. noFocus: !0
  1510. }), this.close(), this.container.removeClass("sp-selSrch-container-active"), this.search[0] === document.activeElement && this.search.blur(), this.clearSearch(), this.selection.find(".sp-selSrch-search-choice-focus").removeClass("sp-selSrch-search-choice-focus")
  1511. },
  1512. focusSearch: function () {
  1513. p(this.search)
  1514. },
  1515. selectHighlighted: function (e) {
  1516. var t = this.highlight(),
  1517. i = this.results.find(".sp-selSrch-highlighted"),
  1518. n = i.closest(".sp-selSrch-result").data("sp-selSrch-data");
  1519. n ? (this.highlight(t), this.onSelect(n, e)) : e && e.noFocus && this.close()
  1520. },
  1521. getPlaceholder: function () {
  1522. var e;
  1523. return this.opts.element.attr("placeholder") || this.opts.element.attr("data-placeholder") || this.opts.element.data("placeholder") || this.opts.placeholder || ((e = this.getPlaceholderOption()) !== t ? e.text() : t)
  1524. },
  1525. getPlaceholderOption: function () {
  1526. if (this.select) {
  1527. var e = this.select.children().first();
  1528. if (this.opts.placeholderOption !== t) return "first" === this.opts.placeholderOption && e || "function" == typeof this.opts.placeholderOption && this.opts.placeholderOption(this.select);
  1529. if ("" === e.text() && "" === e.val()) return e
  1530. }
  1531. },
  1532. initContainerWidth: function () {
  1533. function i() {
  1534. var i, n, a, r, o;
  1535. if ("off" === this.opts.width) return null;
  1536. if ("element" === this.opts.width) return 0 === this.opts.element.outerWidth(!1) ? "auto" : this.opts.element.outerWidth(!1) + "px";
  1537. if ("copy" === this.opts.width || "resolve" === this.opts.width) {
  1538. if (i = this.opts.element.attr("style"), i !== t) for (n = i.split(";"), r = 0, o = n.length; o > r; r += 1) if (a = n[r].replace(/\s/g, "").match(/[^-]width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i), null !== a && a.length >= 1) return a[1];
  1539. return "resolve" === this.opts.width ? (i = this.opts.element.css("width"), i.indexOf("%") > 0 ? i : 0 === this.opts.element.outerWidth(!1) ? "auto" : this.opts.element.outerWidth(!1) + "px") : null
  1540. }
  1541. return e.isFunction(this.opts.width) ? this.opts.width() : this.opts.width
  1542. }
  1543. var n = i.call(this);
  1544. null !== n && this.container.css("width", n)
  1545. }
  1546. }), R = E(I, {
  1547. createContainer: function () {
  1548. var t = e(document.createElement("div")).attr({
  1549. "class": "sp-selSrch-container"
  1550. }).html(["<a href='javascript:void(0)' onclick='return false;' class='sp-selSrch-choice' tabindex='-1'>", " <span class='sp-selSrch-chosen'>&nbsp;</span><abbr class='sp-selSrch-search-choice-close'></abbr>", " <span class='sp-selSrch-arrow'><b></b></span>", "</a>", "<input class='sp-selSrch-focusser sp-selSrch-offscreen' type='text'/>", "<div class='sp-selSrch-drop sp-selSrch-display-none'>", " <div class='sp-selSrch-search'>", " <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='sp-selSrch-input'/>", " </div>", " <ul class='sp-selSrch-results'>", " </ul>", "</div>"].join(""));
  1551. return t
  1552. },
  1553. enableInterface: function () {
  1554. this.parent.enableInterface.apply(this, arguments) && this.focusser.prop("disabled", !this.isInterfaceEnabled())
  1555. },
  1556. opening: function () {
  1557. var i, n, a;
  1558. this.opts.minimumResultsForSearch >= 0 && this.showSearch(!0), this.parent.opening.apply(this, arguments), this.showSearchInput !== !1 && this.search.val(this.focusser.val()), this.search.focus(), i = this.search.get(0), i.createTextRange ? (n = i.createTextRange(), n.collapse(!1), n.select()) : i.setSelectionRange && (a = this.search.val().length, i.setSelectionRange(a, a)), "" === this.search.val() && this.nextSearchTerm != t && (this.search.val(this.nextSearchTerm), this.search.select()), this.focusser.prop("disabled", !0).val(""), this.updateResults(!0), this.opts.element.trigger(e.Event("sp-selSrch-open"))
  1559. },
  1560. close: function (e) {
  1561. this.opened() && (this.parent.close.apply(this, arguments), e = e || {
  1562. focus: !0
  1563. }, this.focusser.removeAttr("disabled"), e.focus && this.focusser.focus())
  1564. },
  1565. focus: function () {
  1566. this.opened() ? this.close() : (this.focusser.removeAttr("disabled"), this.focusser.focus())
  1567. },
  1568. isFocused: function () {
  1569. return this.container.hasClass("sp-selSrch-container-active")
  1570. },
  1571. cancel: function () {
  1572. this.parent.cancel.apply(this, arguments), this.focusser.removeAttr("disabled"), this.focusser.focus()
  1573. },
  1574. destroy: function () {
  1575. e("label[for='" + this.focusser.attr("id") + "']").attr("for", this.opts.element.attr("id")), this.parent.destroy.apply(this, arguments)
  1576. },
  1577. initContainer: function () {
  1578. var t, i = this.container,
  1579. n = this.dropdown;
  1580. this.opts.minimumResultsForSearch < 0 ? this.showSearch(!1) : this.showSearch(!0), this.selection = t = i.find(".sp-selSrch-choice"), this.focusser = i.find(".sp-selSrch-focusser"), this.focusser.attr("id", "s2id_autogen" + D()), e("label[for='" + this.opts.element.attr("id") + "']").attr("for", this.focusser.attr("id")), this.focusser.attr("tabindex", this.elementTabIndex), this.search.on("keydown", this.bind(function (e) {
  1581. if (this.isInterfaceEnabled()) {
  1582. if (e.which === A.PAGE_UP || e.which === A.PAGE_DOWN) return f(e), void 0;
  1583. switch (e.which) {
  1584. case A.UP:
  1585. case A.DOWN:
  1586. return this.moveHighlight(e.which === A.UP ? -1 : 1), f(e), void 0;
  1587. case A.ENTER:
  1588. return this.selectHighlighted(), f(e), void 0;
  1589. case A.TAB:
  1590. return this.selectHighlighted({
  1591. noFocus: !0
  1592. }), void 0;
  1593. case A.ESC:
  1594. return this.cancel(e), f(e), void 0
  1595. }
  1596. }
  1597. })), this.search.on("blur", this.bind(function () {
  1598. document.activeElement === this.body().get(0) && window.setTimeout(this.bind(function () {
  1599. this.search.focus()
  1600. }), 0)
  1601. })), this.focusser.on("keydown", this.bind(function (e) {
  1602. if (this.isInterfaceEnabled() && e.which !== A.TAB && !A.isControl(e) && !A.isFunctionKey(e) && e.which !== A.ESC) {
  1603. if (this.opts.openOnEnter === !1 && e.which === A.ENTER) return f(e), void 0;
  1604. if (e.which == A.DOWN || e.which == A.UP || e.which == A.ENTER && this.opts.openOnEnter) {
  1605. if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) return;
  1606. return this.open(), f(e), void 0
  1607. }
  1608. return e.which == A.DELETE || e.which == A.BACKSPACE ? (this.opts.allowClear && this.clear(), f(e), void 0) : void 0
  1609. }
  1610. })), l(this.focusser), this.focusser.on("keyup-change input", this.bind(function (e) {
  1611. if (this.opts.minimumResultsForSearch >= 0) {
  1612. if (e.stopPropagation(), this.opened()) return;
  1613. this.open()
  1614. }
  1615. })), t.on("mousedown", "abbr", this.bind(function (e) {
  1616. this.isInterfaceEnabled() && (this.clear(), m(e), this.close(), this.selection.focus())
  1617. })), t.on("mousedown", this.bind(function (t) {
  1618. this.container.hasClass("sp-selSrch-container-active") || this.opts.element.trigger(e.Event("sp-selSrch-focus")), this.opened() ? this.close() : this.isInterfaceEnabled() && this.open(), f(t)
  1619. })), n.on("mousedown", this.bind(function () {
  1620. this.search.focus()
  1621. })), t.on("focus", this.bind(function (e) {
  1622. f(e)
  1623. })), this.focusser.on("focus", this.bind(function () {
  1624. this.container.hasClass("sp-selSrch-container-active") || this.opts.element.trigger(e.Event("sp-selSrch-focus")), this.container.addClass("sp-selSrch-container-active")
  1625. })).on("blur", this.bind(function () {
  1626. this.opened() || (this.container.removeClass("sp-selSrch-container-active"), this.opts.element.trigger(e.Event("sp-selSrch-blur")))
  1627. })), this.search.on("focus", this.bind(function () {
  1628. this.container.hasClass("sp-selSrch-container-active") || this.opts.element.trigger(e.Event("sp-selSrch-focus")), this.container.addClass("sp-selSrch-container-active")
  1629. })), this.initContainerWidth(), this.opts.element.addClass("sp-selSrch-offscreen"), this.setPlaceholder()
  1630. },
  1631. clear: function (t) {
  1632. var i = this.selection.data("sp-selSrch-data");
  1633. if (i) {
  1634. var n = e.Event("sp-selSrch-clearing");
  1635. if (this.opts.element.trigger(n), n.isDefaultPrevented()) return;
  1636. var a = this.getPlaceholderOption();
  1637. this.opts.element.val(a ? a.val() : ""), this.selection.find(".sp-selSrch-chosen").empty(), this.selection.removeData("sp-selSrch-data"), this.setPlaceholder(), t !== !1 && (this.opts.element.trigger({
  1638. type: "sp-selSrch-removed",
  1639. val: this.id(i),
  1640. choice: i
  1641. }), this.triggerChange({
  1642. removed: i
  1643. }))
  1644. }
  1645. },
  1646. initSelection: function () {
  1647. if (this.isPlaceholderOptionSelected()) this.updateSelection(null), this.close(), this.setPlaceholder();
  1648. else {
  1649. var e = this;
  1650. this.opts.initSelection.call(null, this.opts.element, function (i) {
  1651. i !== t && null !== i && (e.updateSelection(i), e.close(), e.setPlaceholder())
  1652. })
  1653. }
  1654. },
  1655. isPlaceholderOptionSelected: function () {
  1656. var e;
  1657. return this.getPlaceholder() ? (e = this.getPlaceholderOption()) !== t && e.is(":selected") || "" === this.opts.element.val() || this.opts.element.val() === t || null === this.opts.element.val() : !1
  1658. },
  1659. prepareOpts: function () {
  1660. var t = this.parent.prepareOpts.apply(this, arguments),
  1661. i = this;
  1662. return "select" === t.element.get(0).tagName.toLowerCase() ? t.initSelection = function (e, t) {
  1663. var n = e.find(":selected");
  1664. t(i.optionToData(n))
  1665. } : "data" in t && (t.initSelection = t.initSelection ||
  1666. function (i, n) {
  1667. var a = i.val(),
  1668. o = null;
  1669. t.query({
  1670. matcher: function (e, i, n) {
  1671. var s = r(a, t.id(n));
  1672. return s && (o = n), s
  1673. },
  1674. callback: e.isFunction(n) ?
  1675. function () {
  1676. n(o)
  1677. } : e.noop
  1678. })
  1679. }), t
  1680. },
  1681. getPlaceholder: function () {
  1682. return this.select && this.getPlaceholderOption() === t ? t : this.parent.getPlaceholder.apply(this, arguments)
  1683. },
  1684. setPlaceholder: function () {
  1685. var e = this.getPlaceholder();
  1686. if (this.isPlaceholderOptionSelected() && e !== t) {
  1687. if (this.select && this.getPlaceholderOption() === t) return;
  1688. this.selection.find(".sp-selSrch-chosen").html(this.opts.escapeMarkup(e)), this.selection.addClass("sp-selSrch-default"), this.container.removeClass("sp-selSrch-allowclear")
  1689. }
  1690. },
  1691. postprocessResults: function (e, t, i) {
  1692. var n = 0,
  1693. a = this;
  1694. if (this.findHighlightableChoices().each2(function (e, t) {
  1695. return r(a.id(t.data("sp-selSrch-data")), a.opts.element.val()) ? (n = e, !1) : void 0
  1696. }), i !== !1 && (t === !0 && n >= 0 ? this.highlight(n) : this.highlight(0)), t === !0) {
  1697. var o = this.opts.minimumResultsForSearch;
  1698. o >= 0 && this.showSearch(M(e.results) >= o)
  1699. }
  1700. },
  1701. showSearch: function (t) {
  1702. this.showSearchInput !== t && (this.showSearchInput = t, this.dropdown.find(".sp-selSrch-search").toggleClass("sp-selSrch-search-hidden", !t), this.dropdown.find(".sp-selSrch-search").toggleClass("sp-selSrch-offscreen", !t), e(this.dropdown, this.container).toggleClass("sp-selSrch-with-searchbox", t))
  1703. },
  1704. onSelect: function (e, t) {
  1705. if (this.triggerSelect(e)) {
  1706. var i = this.opts.element.val(),
  1707. n = this.data();
  1708. this.opts.element.val(this.id(e)), this.updateSelection(e), this.opts.element.trigger({
  1709. type: "sp-selSrch-selected",
  1710. val: this.id(e),
  1711. choice: e
  1712. }), this.nextSearchTerm = this.opts.nextSearchTerm(e, this.search.val()), this.close(), t && t.noFocus || this.focusser.focus(), r(i, this.id(e)) || this.triggerChange({
  1713. added: e,
  1714. removed: n
  1715. })
  1716. }
  1717. },
  1718. updateSelection: function (e) {
  1719. var i, n, a = this.selection.find(".sp-selSrch-chosen");
  1720. this.selection.data("sp-selSrch-data", e), a.empty(), null !== e && (i = this.opts.formatSelection(e, a, this.opts.escapeMarkup)), i !== t && a.append(i), n = this.opts.formatSelectionCssClass(e, a), n !== t && a.addClass(n), this.selection.removeClass("sp-selSrch-default"), this.opts.allowClear && this.getPlaceholder() !== t && this.container.addClass("sp-selSrch-allowclear")
  1721. },
  1722. val: function () {
  1723. var e, i = !1,
  1724. n = null,
  1725. a = this,
  1726. r = this.data();
  1727. if (0 === arguments.length) return this.opts.element.val();
  1728. if (e = arguments[0], arguments.length > 1 && (i = arguments[1]), this.select) this.select.val(e).find(":selected").each2(function (e, t) {
  1729. return n = a.optionToData(t), !1
  1730. }), this.updateSelection(n), this.setPlaceholder(), i && this.triggerChange({
  1731. added: n,
  1732. removed: r
  1733. });
  1734. else {
  1735. if (!e && 0 !== e) return this.clear(i), void 0;
  1736. if (this.opts.initSelection === t) throw new Error("cannot call val() if initSelection() is not defined");
  1737. this.opts.element.val(e), this.opts.initSelection(this.opts.element, function (e) {
  1738. a.opts.element.val(e ? a.id(e) : ""), a.updateSelection(e), a.setPlaceholder(), i && a.triggerChange({
  1739. added: e,
  1740. removed: r
  1741. })
  1742. })
  1743. }
  1744. },
  1745. clearSearch: function () {
  1746. this.search.val(""), this.focusser.val("")
  1747. },
  1748. data: function (e) {
  1749. var i, n = !1;
  1750. return 0 === arguments.length ? (i = this.selection.data("sp-selSrch-data"), i == t && (i = null), i) : (arguments.length > 1 && (n = arguments[1]), e ? (i = this.data(), this.opts.element.val(e ? this.id(e) : ""), this.updateSelection(e), n && this.triggerChange({
  1751. added: e,
  1752. removed: i
  1753. })) : this.clear(n), void 0)
  1754. }
  1755. }), N = E(I, {
  1756. createContainer: function () {
  1757. var t = e(document.createElement("div")).attr({
  1758. "class": "sp-selSrch-container sp-selSrch-container-multi"
  1759. }).html(["<ul class='sp-selSrch-choices'>", " <li class='sp-selSrch-search-field'>", " <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='sp-selSrch-input'>", " </li>", "</ul>", "<div class='sp-selSrch-drop sp-selSrch-drop-multi sp-selSrch-display-none'>", " <ul class='sp-selSrch-results'>", " </ul>", "</div>"].join(""));
  1760. return t
  1761. },
  1762. prepareOpts: function () {
  1763. var t = this.parent.prepareOpts.apply(this, arguments),
  1764. i = this;
  1765. return "select" === t.element.get(0).tagName.toLowerCase() ? t.initSelection = function (e, t) {
  1766. var n = [];
  1767. e.find(":selected").each2(function (e, t) {
  1768. n.push(i.optionToData(t))
  1769. }), t(n)
  1770. } : "data" in t && (t.initSelection = t.initSelection ||
  1771. function (i, n) {
  1772. var a = o(i.val(), t.separator),
  1773. s = [];
  1774. t.query({
  1775. matcher: function (i, n, o) {
  1776. var l = e.grep(a, function (e) {
  1777. return r(e, t.id(o))
  1778. }).length;
  1779. return l && s.push(o), l
  1780. },
  1781. callback: e.isFunction(n) ?
  1782. function () {
  1783. for (var e = [], i = 0; i < a.length; i++) for (var o = a[i], l = 0; l < s.length; l++) {
  1784. var d = s[l];
  1785. if (r(o, t.id(d))) {
  1786. e.push(d), s.splice(l, 1);
  1787. break
  1788. }
  1789. }
  1790. n(e)
  1791. } : e.noop
  1792. })
  1793. }), t
  1794. },
  1795. selectChoice: function (e) {
  1796. var t = this.container.find(".sp-selSrch-search-choice-focus");
  1797. t.length && e && e[0] == t[0] || (t.length && this.opts.element.trigger("choice-deselected", t), t.removeClass("sp-selSrch-search-choice-focus"), e && e.length && (this.close(), e.addClass("sp-selSrch-search-choice-focus"), this.opts.element.trigger("choice-selected", e)))
  1798. },
  1799. destroy: function () {
  1800. e("label[for='" + this.search.attr("id") + "']").attr("for", this.opts.element.attr("id")), this.parent.destroy.apply(this, arguments)
  1801. },
  1802. initContainer: function () {
  1803. var t, i = ".sp-selSrch-choices";
  1804. this.searchContainer = this.container.find(".sp-selSrch-search-field"), this.selection = t = this.container.find(i);
  1805. var n = this;
  1806. this.selection.on("click", ".sp-selSrch-search-choice:not(.sp-selSrch-locked)", function () {
  1807. n.search[0].focus(), n.selectChoice(e(this))
  1808. }), this.search.attr("id", "s2id_autogen" + D()), e("label[for='" + this.opts.element.attr("id") + "']").attr("for", this.search.attr("id")), this.search.on("input paste", this.bind(function () {
  1809. this.isInterfaceEnabled() && (this.opened() || this.open())
  1810. })), this.search.attr("tabindex", this.elementTabIndex), this.keydowns = 0, this.search.on("keydown", this.bind(function (e) {
  1811. if (this.isInterfaceEnabled()) {
  1812. ++this.keydowns;
  1813. var i = t.find(".sp-selSrch-search-choice-focus"),
  1814. n = i.prev(".sp-selSrch-search-choice:not(.sp-selSrch-locked)"),
  1815. a = i.next(".sp-selSrch-search-choice:not(.sp-selSrch-locked)"),
  1816. r = g(this.search);
  1817. if (i.length && (e.which == A.LEFT || e.which == A.RIGHT || e.which == A.BACKSPACE || e.which == A.DELETE || e.which == A.ENTER)) {
  1818. var o = i;
  1819. return e.which == A.LEFT && n.length ? o = n : e.which == A.RIGHT ? o = a.length ? a : null : e.which === A.BACKSPACE ? (this.unselect(i.first()), this.search.width(10), o = n.length ? n : a) : e.which == A.DELETE ? (this.unselect(i.first()), this.search.width(10), o = a.length ? a : null) : e.which == A.ENTER && (o = null), this.selectChoice(o), f(e), o && o.length || this.open(), void 0
  1820. }
  1821. if ((e.which === A.BACKSPACE && 1 == this.keydowns || e.which == A.LEFT) && 0 == r.offset && !r.length) return this.selectChoice(t.find(".sp-selSrch-search-choice:not(.sp-selSrch-locked)").last()), f(e), void 0;
  1822. if (this.selectChoice(null), this.opened()) switch (e.which) {
  1823. case A.UP:
  1824. case A.DOWN:
  1825. return this.moveHighlight(e.which === A.UP ? -1 : 1), f(e), void 0;
  1826. case A.ENTER:
  1827. return this.selectHighlighted(), f(e), void 0;
  1828. case A.TAB:
  1829. return this.selectHighlighted({
  1830. noFocus: !0
  1831. }), this.close(), void 0;
  1832. case A.ESC:
  1833. return this.cancel(e), f(e), void 0
  1834. }
  1835. if (e.which !== A.TAB && !A.isControl(e) && !A.isFunctionKey(e) && e.which !== A.BACKSPACE && e.which !== A.ESC) {
  1836. if (e.which === A.ENTER) {
  1837. if (this.opts.openOnEnter === !1) return;
  1838. if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) return
  1839. }
  1840. this.open(), (e.which === A.PAGE_UP || e.which === A.PAGE_DOWN) && f(e), e.which === A.ENTER && f(e)
  1841. }
  1842. }
  1843. })), this.search.on("keyup", this.bind(function () {
  1844. this.keydowns = 0, this.resizeSearch()
  1845. })), this.search.on("blur", this.bind(function (t) {
  1846. this.container.removeClass("sp-selSrch-container-active"), this.search.removeClass("sp-selSrch-focused"), this.selectChoice(null), this.opened() || this.clearSearch(), t.stopImmediatePropagation(), this.opts.element.trigger(e.Event("sp-selSrch-blur"))
  1847. })), this.container.on("click", i, this.bind(function (t) {
  1848. this.isInterfaceEnabled() && (e(t.target).closest(".sp-selSrch-search-choice").length > 0 || (this.selectChoice(null), this.clearPlaceholder(), this.container.hasClass("sp-selSrch-container-active") || this.opts.element.trigger(e.Event("sp-selSrch-focus")), this.open(), this.focusSearch(), t.preventDefault()))
  1849. })), this.container.on("focus", i, this.bind(function () {
  1850. this.isInterfaceEnabled() && (this.container.hasClass("sp-selSrch-container-active") || this.opts.element.trigger(e.Event("sp-selSrch-focus")), this.container.addClass("sp-selSrch-container-active"), this.dropdown.addClass("sp-selSrch-drop-active"), this.clearPlaceholder())
  1851. })), this.initContainerWidth(), this.opts.element.addClass("sp-selSrch-offscreen"), this.clearSearch()
  1852. },
  1853. enableInterface: function () {
  1854. this.parent.enableInterface.apply(this, arguments) && this.search.prop("disabled", !this.isInterfaceEnabled())
  1855. },
  1856. initSelection: function () {
  1857. if ("" === this.opts.element.val() && "" === this.opts.element.text() && (this.updateSelection([]), this.close(), this.clearSearch()), this.select || "" !== this.opts.element.val()) {
  1858. var e = this;
  1859. this.opts.initSelection.call(null, this.opts.element, function (i) {
  1860. i !== t && null !== i && (e.updateSelection(i), e.close(), e.clearSearch())
  1861. })
  1862. }
  1863. },
  1864. clearSearch: function () {
  1865. var e = this.getPlaceholder(),
  1866. i = this.getMaxSearchWidth();
  1867. e !== t && 0 === this.getVal().length && this.search.hasClass("sp-selSrch-focused") === !1 ? (this.search.val(e).addClass("sp-selSrch-default"), this.search.width(i > 0 ? i : this.container.css("width"))) : this.search.val("").width(10)
  1868. },
  1869. clearPlaceholder: function () {
  1870. this.search.hasClass("sp-selSrch-default") && this.search.val("").removeClass("sp-selSrch-default")
  1871. },
  1872. opening: function () {
  1873. this.clearPlaceholder(), this.resizeSearch(), this.parent.opening.apply(this, arguments), this.focusSearch(), this.updateResults(!0), this.search.focus(), this.opts.element.trigger(e.Event("sp-selSrch-open"))
  1874. },
  1875. close: function () {
  1876. this.opened() && this.parent.close.apply(this, arguments)
  1877. },
  1878. focus: function () {
  1879. this.close(), this.search.focus()
  1880. },
  1881. isFocused: function () {
  1882. return this.search.hasClass("sp-selSrch-focused")
  1883. },
  1884. updateSelection: function (t) {
  1885. var i = [],
  1886. a = [],
  1887. r = this;
  1888. e(t).each(function () {
  1889. n(r.id(this), i) < 0 && (i.push(r.id(this)), a.push(this))
  1890. }), t = a, this.selection.find(".sp-selSrch-search-choice").remove(), e(t).each(function () {
  1891. r.addSelectedChoice(this)
  1892. }), r.postprocessResults()
  1893. },
  1894. tokenize: function () {
  1895. var e = this.search.val();
  1896. e = this.opts.tokenizer.call(this, e, this.data(), this.bind(this.onSelect), this.opts), null != e && e != t && (this.search.val(e), e.length > 0 && this.open())
  1897. },
  1898. onSelect: function (e, t) {
  1899. this.triggerSelect(e) && (this.addSelectedChoice(e), this.opts.element.trigger({
  1900. type: "selected",
  1901. val: this.id(e),
  1902. choice: e
  1903. }), (this.select || !this.opts.closeOnSelect) && this.postprocessResults(e, !1, this.opts.closeOnSelect === !0), this.opts.closeOnSelect ? (this.close(), this.search.width(10)) : this.countSelectableResults() > 0 ? (this.search.width(10), this.resizeSearch(), this.getMaximumSelectionSize() > 0 && this.val().length >= this.getMaximumSelectionSize() && this.updateResults(!0), this.positionDropdown()) : (this.close(), this.search.width(10)), this.triggerChange({
  1904. added: e
  1905. }), t && t.noFocus || this.focusSearch())
  1906. },
  1907. cancel: function () {
  1908. this.close(), this.focusSearch()
  1909. },
  1910. addSelectedChoice: function (i) {
  1911. var n, a, r = !i.locked,
  1912. o = e("<li class='sp-selSrch-search-choice'> <div></div> <a href='#' onclick='return false;' class='sp-selSrch-search-choice-close' tabindex='-1'></a></li>"),
  1913. s = e("<li class='sp-selSrch-search-choice sp-selSrch-locked'><div></div></li>"),
  1914. l = r ? o : s,
  1915. d = this.id(i),
  1916. h = this.getVal();
  1917. n = this.opts.formatSelection(i, l.find("div"), this.opts.escapeMarkup), n != t && l.find("div").replaceWith("<div>" + n + "</div>"), a = this.opts.formatSelectionCssClass(i, l.find("div")), a != t && l.addClass(a), r && l.find(".sp-selSrch-search-choice-close").on("mousedown", f).on("click dblclick", this.bind(function (t) {
  1918. this.isInterfaceEnabled() && (e(t.target).closest(".sp-selSrch-search-choice").fadeOut("fast", this.bind(function () {
  1919. this.unselect(e(t.target)), this.selection.find(".sp-selSrch-search-choice-focus").removeClass("sp-selSrch-search-choice-focus"), this.close(), this.focusSearch()
  1920. })).dequeue(), f(t))
  1921. })).on("focus", this.bind(function () {
  1922. this.isInterfaceEnabled() && (this.container.addClass("sp-selSrch-container-active"), this.dropdown.addClass("sp-selSrch-drop-active"))
  1923. })), l.data("sp-selSrch-data", i), l.insertBefore(this.searchContainer), h.push(d), this.setVal(h)
  1924. },
  1925. unselect: function (e) {
  1926. var t, i, a = this.getVal();
  1927. if (e = e.closest(".sp-selSrch-search-choice"), 0 === e.length) throw "Invalid argument: " + e + ". Must be .sp-selSrch-search-choice";
  1928. if (t = e.data("sp-selSrch-data")) {
  1929. for (;
  1930. (i = n(this.id(t), a)) >= 0;) a.splice(i, 1), this.setVal(a), this.select && this.postprocessResults();
  1931. e.remove(), this.opts.element.trigger({
  1932. type: "removed",
  1933. val: this.id(t),
  1934. choice: t
  1935. }), this.triggerChange({
  1936. removed: t
  1937. })
  1938. }
  1939. },
  1940. postprocessResults: function (e, t, i) {
  1941. var a = this.getVal(),
  1942. r = this.results.find(".sp-selSrch-result"),
  1943. o = this.results.find(".sp-selSrch-result-with-children"),
  1944. s = this;
  1945. r.each2(function (e, t) {
  1946. var i = s.id(t.data("sp-selSrch-data"));
  1947. n(i, a) >= 0 && (t.addClass("sp-selSrch-selected"), t.find(".sp-selSrch-result-selectable").addClass("sp-selSrch-selected"))
  1948. }), o.each2(function (e, t) {
  1949. t.is(".sp-selSrch-result-selectable") || 0 !== t.find(".sp-selSrch-result-selectable:not(.sp-selSrch-selected)").length || t.addClass("sp-selSrch-selected")
  1950. }), -1 == this.highlight() && i !== !1 && s.highlight(0), !this.opts.createSearchChoice && !r.filter(".sp-selSrch-result:not(.sp-selSrch-selected)").length > 0 && (!e || e && !e.more && 0 === this.results.find(".sp-selSrch-no-results").length) && T(s.opts.formatNoMatches, "formatNoMatches") && this.results.append("<li class='sp-selSrch-no-results'>" + s.opts.formatNoMatches(s.search.val()) + "</li>")
  1951. },
  1952. getMaxSearchWidth: function () {
  1953. return this.selection.width() - s(this.search)
  1954. },
  1955. resizeSearch: function () {
  1956. var e, t, i, n, a, r = s(this.search);
  1957. e = v(this.search) + 10, t = this.search.offset().left, i = this.selection.width(), n = this.selection.offset().left, a = i - (t - n) - r, e > a && (a = i - r), 40 > a && (a = i - r), 0 >= a && (a = e), this.search.width(Math.floor(a))
  1958. },
  1959. getVal: function () {
  1960. var e;
  1961. return this.select ? (e = this.select.val(), null === e ? [] : e) : (e = this.opts.element.val(), o(e, this.opts.separator))
  1962. },
  1963. setVal: function (t) {
  1964. var i;
  1965. this.select ? this.select.val(t) : (i = [], e(t).each(function () {
  1966. n(this, i) < 0 && i.push(this)
  1967. }), this.opts.element.val(0 === i.length ? "" : i.join(this.opts.separator)))
  1968. },
  1969. buildChangeDetails: function (e, t) {
  1970. for (var t = t.slice(0), e = e.slice(0), i = 0; i < t.length; i++) for (var n = 0; n < e.length; n++) r(this.opts.id(t[i]), this.opts.id(e[n])) && (t.splice(i, 1), i--, e.splice(n, 1), n--);
  1971. return {
  1972. added: t,
  1973. removed: e
  1974. }
  1975. },
  1976. val: function (i, n) {
  1977. var a, r = this;
  1978. if (0 === arguments.length) return this.getVal();
  1979. if (a = this.data(), a.length || (a = []), !i && 0 !== i) return this.opts.element.val(""), this.updateSelection([]), this.clearSearch(), n && this.triggerChange({
  1980. added: this.data(),
  1981. removed: a
  1982. }), void 0;
  1983. if (this.setVal(i), this.select) this.opts.initSelection(this.select, this.bind(this.updateSelection)), n && this.triggerChange(this.buildChangeDetails(a, this.data()));
  1984. else {
  1985. if (this.opts.initSelection === t) throw new Error("val() cannot be called if initSelection() is not defined");
  1986. this.opts.initSelection(this.opts.element, function (t) {
  1987. var i = e.map(t, r.id);
  1988. r.setVal(i), r.updateSelection(t), r.clearSearch(), n && r.triggerChange(r.buildChangeDetails(a, this.data()))
  1989. })
  1990. }
  1991. this.clearSearch()
  1992. },
  1993. onSortStart: function () {
  1994. if (this.select) throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.");
  1995. this.search.width(0), this.searchContainer.hide()
  1996. },
  1997. onSortEnd: function () {
  1998. var t = [],
  1999. i = this;
  2000. this.searchContainer.show(), this.searchContainer.appendTo(this.searchContainer.parent()), this.resizeSearch(), this.selection.find(".sp-selSrch-search-choice").each(function () {
  2001. t.push(i.opts.id(e(this).data("sp-selSrch-data")))
  2002. }), this.setVal(t), this.triggerChange()
  2003. },
  2004. data: function (t, i) {
  2005. var n, a, r = this;
  2006. return 0 === arguments.length ? this.selection.find(".sp-selSrch-search-choice").map(function () {
  2007. return e(this).data("sp-selSrch-data")
  2008. }).get() : (a = this.data(), t || (t = []), n = e.map(t, function (e) {
  2009. return r.opts.id(e)
  2010. }), this.setVal(n), this.updateSelection(t), this.clearSearch(), i && this.triggerChange(this.buildChangeDetails(a, this.data())), void 0)
  2011. }
  2012. }), e.fn.selectSrchFun = function () {
  2013. var i, a, r, o, s, l = Array.prototype.slice.call(arguments, 0),
  2014. d = ["val", "destroy", "opened", "open", "close", "focus", "isFocused", "container", "dropdown", "onSortStart", "onSortEnd", "enable", "disable", "readonly", "positionDropdown", "data", "search"],
  2015. h = ["opened", "isFocused", "container", "dropdown"],
  2016. c = ["val", "data"],
  2017. u = {
  2018. search: "externalSearch"
  2019. };
  2020. return this.each(function () {
  2021. if (0 === l.length || "object" == typeof l[0]) i = 0 === l.length ? {} : e.extend({}, l[0]), i.element = e(this), "select" === i.element.get(0).tagName.toLowerCase() ? s = i.element.prop("multiple") : (s = i.multiple || !1, "tags" in i && (i.multiple = s = !0)), a = s ? new N : new R, a.init(i);
  2022. else {
  2023. if ("string" != typeof l[0]) throw "Invalid arguments to selectSrchFun plugin: " + l;
  2024. if (n(l[0], d) < 0) throw "Unknown method: " + l[0];
  2025. if (o = t, a = e(this).data("selectSrchFun"), a === t) return;
  2026. if (r = l[0], "container" === r ? o = a.container : "dropdown" === r ? o = a.dropdown : (u[r] && (r = u[r]), o = a[r].apply(a, l.slice(1))), n(l[0], h) >= 0 || n(l[0], c) && 1 == l.length) return !1
  2027. }
  2028. }), o === t ? this : o
  2029. }, e.fn.selectSrchFun.defaults = {
  2030. width: "copy",
  2031. loadMorePadding: 0,
  2032. closeOnSelect: !0,
  2033. openOnEnter: !0,
  2034. containerCss: {},
  2035. dropdownCss: {},
  2036. containerCssClass: "",
  2037. dropdownCssClass: "",
  2038. formatResult: function (e, t, i, n) {
  2039. var a = [];
  2040. return b(e.text, i.term, a, n), a.join("")
  2041. },
  2042. formatSelection: function (e, i, n) {
  2043. return e ? n(e.text) : t
  2044. },
  2045. sortResults: function (e) {
  2046. return e
  2047. },
  2048. formatResultCssClass: function () {
  2049. return t
  2050. },
  2051. formatSelectionCssClass: function () {
  2052. return t
  2053. },
  2054. formatNoMatches: function () {
  2055. return "没有匹配的选项"
  2056. },
  2057. formatInputTooShort: function (e, t) {
  2058. var i = t - e.length;
  2059. return "Please enter " + i + " more character" + (1 == i ? "" : "s")
  2060. },
  2061. formatInputTooLong: function (e, t) {
  2062. var i = e.length - t;
  2063. return "Please delete " + i + " character" + (1 == i ? "" : "s")
  2064. },
  2065. formatSelectionTooBig: function (e) {
  2066. return "You can only select " + e + " item" + (1 == e ? "" : "s")
  2067. },
  2068. formatLoadMore: function () {
  2069. return "Loading more results..."
  2070. },
  2071. formatSearching: function () {
  2072. return "Searching..."
  2073. },
  2074. minimumResultsForSearch: 0,
  2075. minimumInputLength: 0,
  2076. maximumInputLength: null,
  2077. maximumSelectionSize: 0,
  2078. id: function (e) {
  2079. return e.id
  2080. },
  2081. matcher: function (e, t) {
  2082. return i("" + t).toUpperCase().indexOf(i("" + e).toUpperCase()) >= 0
  2083. },
  2084. separator: ",",
  2085. tokenSeparators: [],
  2086. tokenizer: S,
  2087. escapeMarkup: x,
  2088. blurOnChange: !1,
  2089. selectOnBlur: !1,
  2090. adaptContainerCssClass: function (e) {
  2091. return e
  2092. },
  2093. adaptDropdownCssClass: function () {
  2094. return null
  2095. },
  2096. nextSearchTerm: function () {
  2097. return t
  2098. }
  2099. }, e.fn.selectSrchFun.ajaxDefaults = {
  2100. transport: e.ajax,
  2101. params: {
  2102. type: "GET",
  2103. cache: !1,
  2104. dataType: "json"
  2105. }
  2106. }, window.Select2 = {
  2107. query: {
  2108. ajax: w,
  2109. local: C,
  2110. tags: _
  2111. },
  2112. util: {
  2113. debounce: h,
  2114. markMatch: b,
  2115. escapeMarkup: x,
  2116. stripDiacritics: i
  2117. },
  2118. "class": {
  2119. "abstract": I,
  2120. single: R,
  2121. multi: N
  2122. }
  2123. }
  2124. }
  2125. }(jQuery);