select.min.js 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. /*!
  2. * ui-select
  3. * http://github.com/angular-ui/ui-select
  4. * Version: 0.11.2 - 2015-03-17T04:08:46.474Z
  5. * License: MIT
  6. */
  7. ! function() {
  8. "use strict";
  9. var e = {
  10. TAB: 9,
  11. ENTER: 13,
  12. ESC: 27,
  13. SPACE: 32,
  14. LEFT: 37,
  15. UP: 38,
  16. RIGHT: 39,
  17. DOWN: 40,
  18. SHIFT: 16,
  19. CTRL: 17,
  20. ALT: 18,
  21. PAGE_UP: 33,
  22. PAGE_DOWN: 34,
  23. HOME: 36,
  24. END: 35,
  25. BACKSPACE: 8,
  26. DELETE: 46,
  27. COMMAND: 91,
  28. MAP: { 91: "COMMAND", 8: "BACKSPACE", 9: "TAB", 13: "ENTER", 16: "SHIFT", 17: "CTRL", 18: "ALT", 19: "PAUSEBREAK", 20: "CAPSLOCK", 27: "ESC", 32: "SPACE", 33: "PAGE_UP", 34: "PAGE_DOWN", 35: "END", 36: "HOME", 37: "LEFT", 38: "UP", 39: "RIGHT", 40: "DOWN", 43: "+", 44: "PRINTSCREEN", 45: "INSERT", 46: "DELETE", 48: "0", 49: "1", 50: "2", 51: "3", 52: "4", 53: "5", 54: "6", 55: "7", 56: "8", 57: "9", 59: ";", 61: "=", 65: "A", 66: "B", 67: "C", 68: "D", 69: "E", 70: "F", 71: "G", 72: "H", 73: "I", 74: "J", 75: "K", 76: "L", 77: "M", 78: "N", 79: "O", 80: "P", 81: "Q", 82: "R", 83: "S", 84: "T", 85: "U", 86: "V", 87: "W", 88: "X", 89: "Y", 90: "Z", 96: "0", 97: "1", 98: "2", 99: "3", 100: "4", 101: "5", 102: "6", 103: "7", 104: "8", 105: "9", 106: "*", 107: "+", 109: "-", 110: ".", 111: "/", 112: "F1", 113: "F2", 114: "F3", 115: "F4", 116: "F5", 117: "F6", 118: "F7", 119: "F8", 120: "F9", 121: "F10", 122: "F11", 123: "F12", 144: "NUMLOCK", 145: "SCROLLLOCK", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", 221: "]", 222: "'" },
  29. isControl: function(t) {
  30. var c = t.which;
  31. switch (c) {
  32. case e.COMMAND:
  33. case e.SHIFT:
  34. case e.CTRL:
  35. case e.ALT:
  36. return !0
  37. }
  38. return t.metaKey ? !0 : !1
  39. },
  40. isFunctionKey: function(e) { return e = e.which ? e.which : e, e >= 112 && 123 >= e },
  41. isVerticalMovement: function(t) { return ~[e.UP, e.DOWN].indexOf(t) },
  42. isHorizontalMovement: function(t) { return ~[e.LEFT, e.RIGHT, e.BACKSPACE, e.DELETE].indexOf(t) }
  43. };
  44. void 0 === angular.element.prototype.querySelectorAll && (angular.element.prototype.querySelectorAll = function(e) { return angular.element(this[0].querySelectorAll(e)) }), void 0 === angular.element.prototype.closest && (angular.element.prototype.closest = function(e) {
  45. for (var t = this[0], c = t.matches || t.webkitMatchesSelector || t.mozMatchesSelector || t.msMatchesSelector; t;) {
  46. if (c.bind(t)(e)) return t;
  47. t = t.parentElement
  48. }
  49. return !1
  50. });
  51. var t = 0,
  52. c = angular.module("ui.select", []).constant("uiSelectConfig", { theme: "bootstrap", searchEnabled: !0, sortable: !1, placeholder: "", refreshDelay: 1e3, closeOnSelect: !0, generateId: function() { return t++ }, appendToBody: !1 }).service("uiSelectMinErr", function() {
  53. var e = angular.$$minErr("ui.select");
  54. return function() {
  55. var t = e.apply(this, arguments),
  56. c = t.message.replace(new RegExp("\nhttp://errors.angularjs.org/.*"), "");
  57. return new Error(c)
  58. }
  59. }).directive("uisTranscludeAppend", function() { return { link: function(e, t, c, i, s) { s(e, function(e) { t.append(e) }) } } }).filter("highlight", function() {
  60. function e(e) { return e.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1") }
  61. return function(t, c) { return c && t ? t.replace(new RegExp(e(c), "gi"), '<span class="ui-select-highlight">$&</span>') : t }
  62. }).factory("uisOffset", ["$document", "$window", function(e, t) { return function(c) { var i = c[0].getBoundingClientRect(); return { width: i.width || c.prop("offsetWidth"), height: i.height || c.prop("offsetHeight"), top: i.top + (t.pageYOffset || e[0].documentElement.scrollTop), left: i.left + (t.pageXOffset || e[0].documentElement.scrollLeft) } } }]);
  63. c.directive("uiSelectChoices", ["uiSelectConfig", "uisRepeatParser", "uiSelectMinErr", "$compile", function(e, t, c, i) {
  64. return {
  65. restrict: "EA",
  66. require: "^uiSelect",
  67. replace: !0,
  68. transclude: !0,
  69. templateUrl: function(t) { var c = t.parent().attr("theme") || e.theme; return c + "/choices.tpl.html" },
  70. compile: function(s, l) {
  71. if (!l.repeat) throw c("repeat", "Expected 'repeat' expression.");
  72. return function(s, l, n, a, r) {
  73. var o = n.groupBy;
  74. if (a.parseRepeatAttr(n.repeat, o), a.disableChoiceExpression = n.uiDisableChoice, a.onHighlightCallback = n.onHighlight, o) {
  75. var u = l.querySelectorAll(".ui-select-choices-group");
  76. if (1 !== u.length) throw c("rows", "Expected 1 .ui-select-choices-group but got '{0}'.", u.length);
  77. u.attr("ng-repeat", t.getGroupNgRepeatExpression())
  78. }
  79. var d = l.querySelectorAll(".ui-select-choices-row");
  80. if (1 !== d.length) throw c("rows", "Expected 1 .ui-select-choices-row but got '{0}'.", d.length);
  81. d.attr("ng-repeat", t.getNgRepeatExpression(a.parserResult.itemName, "$select.items", a.parserResult.trackByExp, o)).attr("ng-if", "$select.open").attr("ng-mouseenter", "$select.setActiveItem(" + a.parserResult.itemName + ")").attr("ng-click", "$select.select(" + a.parserResult.itemName + ",false,$event)");
  82. var p = l.querySelectorAll(".ui-select-choices-row-inner");
  83. if (1 !== p.length) throw c("rows", "Expected 1 .ui-select-choices-row-inner but got '{0}'.", p.length);
  84. p.attr("uis-transclude-append", ""), i(l, r)(s), s.$watch("$select.search", function(e) { e && !a.open && a.multiple && a.activate(!1, !0), a.activeIndex = a.tagging.isActivated ? -1 : 0, a.refresh(n.refresh) }), n.$observe("refreshDelay", function() {
  85. var t = s.$eval(n.refreshDelay);
  86. a.refreshDelay = void 0 !== t ? t : e.refreshDelay
  87. })
  88. }
  89. }
  90. }
  91. }]), c.controller("uiSelectCtrl", ["$scope", "$element", "$timeout", "$filter", "uisRepeatParser", "uiSelectMinErr", "uiSelectConfig", function(t, c, i, s, l, n, a) {
  92. function r() {
  93. (d.resetSearchInput || void 0 === d.resetSearchInput && a.resetSearchInput) && (d.search = p, d.selected && d.items.length && !d.multiple && (d.activeIndex = d.items.indexOf(d.selected)))
  94. }
  95. function o(t) {
  96. var c = !0;
  97. switch (t) {
  98. case e.DOWN:
  99. !d.open && d.multiple ? d.activate(!1, !0) : d.activeIndex < d.items.length - 1 && d.activeIndex++;
  100. break;
  101. case e.UP:
  102. !d.open && d.multiple ? d.activate(!1, !0) : (d.activeIndex > 0 || 0 === d.search.length && d.tagging.isActivated && d.activeIndex > -1) && d.activeIndex--;
  103. break;
  104. case e.TAB:
  105. (!d.multiple || d.open) && d.select(d.items[d.activeIndex], !0);
  106. break;
  107. case e.ENTER:
  108. d.open && d.activeIndex >= 0 ? d.select(d.items[d.activeIndex]) : d.activate(!1, !0);
  109. break;
  110. case e.ESC:
  111. d.close();
  112. break;
  113. default:
  114. c = !1
  115. }
  116. return c
  117. }
  118. function u() {
  119. var e = c.querySelectorAll(".ui-select-choices-content"),
  120. t = e.querySelectorAll(".ui-select-choices-row");
  121. if (t.length < 1) throw n("choices", "Expected multiple .ui-select-choices-row but got '{0}'.", t.length);
  122. if (!(d.activeIndex < 0)) {
  123. var i = t[d.activeIndex],
  124. s = i.offsetTop + i.clientHeight - e[0].scrollTop,
  125. l = e[0].offsetHeight;
  126. s > l ? e[0].scrollTop += s - l : s < i.clientHeight && (d.isGrouped && 0 === d.activeIndex ? e[0].scrollTop = 0 : e[0].scrollTop -= i.clientHeight - s)
  127. }
  128. }
  129. var d = this,
  130. p = "";
  131. if (d.placeholder = a.placeholder, d.searchEnabled = a.searchEnabled, d.sortable = a.sortable, d.refreshDelay = a.refreshDelay, d.removeSelected = !1, d.closeOnSelect = !0, d.search = p, d.activeIndex = 0, d.items = [], d.open = !1, d.focus = !1, d.disabled = !1, d.selected = void 0, d.focusser = void 0, d.resetSearchInput = !0, d.multiple = void 0, d.disableChoiceExpression = void 0, d.tagging = { isActivated: !1, fct: void 0 }, d.taggingTokens = { isActivated: !1, tokens: void 0 }, d.lockChoiceExpression = void 0, d.clickTriggeredSelect = !1, d.$filter = s, d.searchInput = c.querySelectorAll("input.ui-select-search"), 1 !== d.searchInput.length) throw n("searchInput", "Expected 1 input.ui-select-search but got '{0}'.", d.searchInput.length);
  132. d.isEmpty = function() { return angular.isUndefined(d.selected) || null === d.selected || "" === d.selected }, d.activate = function(e, c) { d.disabled || d.open || (c || r(), t.$broadcast("uis:activate"), d.open = !0, d.activeIndex = d.activeIndex >= d.items.length ? 0 : d.activeIndex, -1 === d.activeIndex && d.taggingLabel !== !1 && (d.activeIndex = 0), i(function() { d.search = e || d.search, d.searchInput[0].focus() })) }, d.findGroupByName = function(e) { return d.groups && d.groups.filter(function(t) { return t.name === e })[0] }, d.parseRepeatAttr = function(e, c) {
  133. function i(e) {
  134. d.groups = [], angular.forEach(e, function(e) {
  135. var i = t.$eval(c),
  136. s = angular.isFunction(i) ? i(e) : e[i],
  137. l = d.findGroupByName(s);
  138. l ? l.items.push(e) : d.groups.push({ name: s, items: [e] })
  139. }), d.items = [], d.groups.forEach(function(e) { d.items = d.items.concat(e.items) })
  140. }
  141. function s(e) { d.items = e }
  142. d.setItemsFn = c ? i : s, d.parserResult = l.parse(e), d.isGrouped = !!c, d.itemProperty = d.parserResult.itemName, d.refreshItems = function(e) {
  143. e = e || d.parserResult.source(t);
  144. var c = d.selected;
  145. if (angular.isArray(c) && !c.length || !d.removeSelected) d.setItemsFn(e);
  146. else if (void 0 !== e) {
  147. var i = e.filter(function(e) { return c.indexOf(e) < 0 });
  148. d.setItemsFn(i)
  149. }
  150. }, t.$watchCollection(d.parserResult.source, function(e) {
  151. if (void 0 === e || null === e) d.items = [];
  152. else {
  153. if (!angular.isArray(e)) throw n("items", "Expected an array but got '{0}'.", e);
  154. d.refreshItems(e), d.ngModel.$modelValue = null
  155. }
  156. })
  157. };
  158. var h;
  159. d.refresh = function(e) { void 0 !== e && (h && i.cancel(h), h = i(function() { t.$eval(e) }, d.refreshDelay)) }, d.setActiveItem = function(e) { d.activeIndex = d.items.indexOf(e) }, d.isActive = function(e) {
  160. if (!d.open) return !1;
  161. var t = d.items.indexOf(e[d.itemProperty]),
  162. c = t === d.activeIndex;
  163. return !c || 0 > t && d.taggingLabel !== !1 || 0 > t && d.taggingLabel === !1 ? !1 : (c && !angular.isUndefined(d.onHighlightCallback) && e.$eval(d.onHighlightCallback), c)
  164. }, d.isDisabled = function(e) {
  165. if (d.open) {
  166. var t, c = d.items.indexOf(e[d.itemProperty]),
  167. i = !1;
  168. return c >= 0 && !angular.isUndefined(d.disableChoiceExpression) && (t = d.items[c], i = !!e.$eval(d.disableChoiceExpression), t._uiSelectChoiceDisabled = i), i
  169. }
  170. }, d.select = function(e, c, s) {
  171. if (void 0 === e || !e._uiSelectChoiceDisabled) {
  172. if (!d.items && !d.search) return;
  173. if (!e || !e._uiSelectChoiceDisabled) {
  174. if (d.tagging.isActivated) {
  175. if (d.taggingLabel === !1)
  176. if (d.activeIndex < 0) { if (e = void 0 !== d.tagging.fct ? d.tagging.fct(d.search) : d.search, !e || angular.equals(d.items[0], e)) return } else e = d.items[d.activeIndex];
  177. else if (0 === d.activeIndex) { if (void 0 === e) return; if (void 0 !== d.tagging.fct && "string" == typeof e) { if (e = d.tagging.fct(d.search), !e) return } else "string" == typeof e && (e = e.replace(d.taggingLabel, "").trim()) }
  178. if (d.selected && angular.isArray(d.selected) && d.selected.filter(function(t) { return angular.equals(t, e) }).length > 0) return d.close(c), void 0
  179. }
  180. t.$broadcast("uis:select", e);
  181. var l = {};
  182. l[d.parserResult.itemName] = e, i(function() { d.onSelectCallback(t, { $item: e, $model: d.parserResult.modelMapper(t, l) }) }), d.closeOnSelect && d.close(c), s && "click" === s.type && (d.clickTriggeredSelect = !0)
  183. }
  184. }
  185. }, d.close = function(e) { d.open && (d.ngModel && d.ngModel.$setTouched && d.ngModel.$setTouched(), r(), d.open = !1, t.$broadcast("uis:close", e)) }, d.setFocus = function() { d.focus || d.focusInput[0].focus() }, d.clear = function(e) { d.select(void 0), e.stopPropagation(), d.focusser[0].focus() }, d.toggle = function(e) { d.open ? (d.close(), e.preventDefault(), e.stopPropagation()) : d.activate() }, d.isLocked = function(e, t) { var c, i = d.selected[t]; return i && !angular.isUndefined(d.lockChoiceExpression) && (c = !!e.$eval(d.lockChoiceExpression), i._uiSelectChoiceLocked = c), c };
  186. var g = null;
  187. d.sizeSearchInput = function() {
  188. var e = d.searchInput[0],
  189. c = d.searchInput.parent().parent()[0],
  190. s = function() { return c.clientWidth * !!e.offsetParent },
  191. l = function(t) { if (0 === t) return !1; var c = t - e.offsetLeft - 10; return 50 > c && (c = t), d.searchInput.css("width", c + "px"), !0 };
  192. d.searchInput.css("width", "10px"), i(function() { null !== g || l(s()) || (g = t.$watch(s, function(e) { l(e) && (g(), g = null) })) })
  193. }, d.searchInput.on("keydown", function(c) {
  194. var s = c.which;
  195. t.$apply(function() {
  196. var t = !1;
  197. if ((d.items.length > 0 || d.tagging.isActivated) && (o(s), d.taggingTokens.isActivated)) {
  198. for (var l = 0; l < d.taggingTokens.tokens.length; l++) d.taggingTokens.tokens[l] === e.MAP[c.keyCode] && d.search.length > 0 && (t = !0);
  199. t && i(function() {
  200. d.searchInput.triggerHandler("tagged");
  201. var t = d.search.replace(e.MAP[c.keyCode], "").trim();
  202. d.tagging.fct && (t = d.tagging.fct(t)), t && d.select(t, !0)
  203. })
  204. }
  205. }), e.isVerticalMovement(s) && d.items.length > 0 && u()
  206. }), d.searchInput.on("paste", function(e) {
  207. var t = e.originalEvent.clipboardData.getData("text/plain");
  208. if (t && t.length > 0 && d.taggingTokens.isActivated && d.tagging.fct) {
  209. var c = t.split(d.taggingTokens.tokens[0]);
  210. c && c.length > 0 && (angular.forEach(c, function(e) {
  211. var t = d.tagging.fct(e);
  212. t && d.select(t, !0)
  213. }), e.preventDefault(), e.stopPropagation())
  214. }
  215. }), d.searchInput.on("tagged", function() { i(function() { r() }) }), t.$on("$destroy", function() { d.searchInput.off("keyup keydown tagged blur paste") })
  216. }]), c.directive("uiSelect", ["$document", "uiSelectConfig", "uiSelectMinErr", "uisOffset", "$compile", "$parse", "$timeout", function(e, t, c, i, s, l, n) {
  217. return {
  218. restrict: "EA",
  219. templateUrl: function(e, c) { var i = c.theme || t.theme; return i + (angular.isDefined(c.multiple) ? "/select-multiple.tpl.html" : "/select.tpl.html") },
  220. replace: !0,
  221. transclude: !0,
  222. require: ["uiSelect", "^ngModel"],
  223. scope: !0,
  224. controller: "uiSelectCtrl",
  225. controllerAs: "$select",
  226. compile: function(s, a) {
  227. return angular.isDefined(a.multiple) ? s.append("<ui-select-multiple/>").removeAttr("multiple") : s.append("<ui-select-single/>"),
  228. function(s, a, r, o, u) {
  229. function d(e) {
  230. if (g.open) {
  231. var t = !1;
  232. if (t = window.jQuery ? window.jQuery.contains(a[0], e.target) : a[0].contains(e.target), !t && !g.clickTriggeredSelect) {
  233. var c = ["input", "button", "textarea"],
  234. i = angular.element(e.target).scope(),
  235. l = i && i.$select && i.$select !== g;
  236. l || (l = ~c.indexOf(e.target.tagName.toLowerCase())), g.close(l), s.$digest()
  237. }
  238. g.clickTriggeredSelect = !1
  239. }
  240. }
  241. function p() {
  242. var t = i(a);
  243. m = angular.element('<div class="ui-select-placeholder"></div>'), m[0].style.width = t.width + "px", m[0].style.height = t.height + "px", a.after(m), $ = a[0].style.width, e.find("body").append(a), a[0].style.position = "absolute", a[0].style.left = t.left + "px", a[0].style.top = t.top + "px", a[0].style.width = t.width + "px"
  244. }
  245. function h() { null !== m && (m.replaceWith(a), m = null, a[0].style.position = "", a[0].style.left = "", a[0].style.top = "", a[0].style.width = $) }
  246. var g = o[0],
  247. f = o[1];
  248. g.generatedId = t.generateId(), g.baseTitle = r.title || "Select box", g.focusserTitle = g.baseTitle + " focus", g.focusserId = "focusser-" + g.generatedId, g.closeOnSelect = function() { return angular.isDefined(r.closeOnSelect) ? l(r.closeOnSelect)() : t.closeOnSelect }(), g.onSelectCallback = l(r.onSelect), g.onRemoveCallback = l(r.onRemove), g.ngModel = f, g.choiceGrouped = function(e) { return g.isGrouped && e && e.name }, r.tabindex && r.$observe("tabindex", function(e) { g.focusInput.attr("tabindex", e), a.removeAttr("tabindex") }), s.$watch("searchEnabled", function() {
  249. var e = s.$eval(r.searchEnabled);
  250. g.searchEnabled = void 0 !== e ? e : t.searchEnabled
  251. }), s.$watch("sortable", function() {
  252. var e = s.$eval(r.sortable);
  253. g.sortable = void 0 !== e ? e : t.sortable
  254. }), r.$observe("disabled", function() { g.disabled = void 0 !== r.disabled ? r.disabled : !1 }), r.$observe("resetSearchInput", function() {
  255. var e = s.$eval(r.resetSearchInput);
  256. g.resetSearchInput = void 0 !== e ? e : !0
  257. }), r.$observe("tagging", function() {
  258. if (void 0 !== r.tagging) {
  259. var e = s.$eval(r.tagging);
  260. g.tagging = { isActivated: !0, fct: e !== !0 ? e : void 0 }
  261. } else g.tagging = { isActivated: !1, fct: void 0 }
  262. }), r.$observe("taggingLabel", function() { void 0 !== r.tagging && (g.taggingLabel = "false" === r.taggingLabel ? !1 : void 0 !== r.taggingLabel ? r.taggingLabel : "(new)") }), r.$observe("taggingTokens", function() {
  263. if (void 0 !== r.tagging) {
  264. var e = void 0 !== r.taggingTokens ? r.taggingTokens.split("|") : [",", "ENTER"];
  265. g.taggingTokens = { isActivated: !0, tokens: e }
  266. }
  267. }), angular.isDefined(r.autofocus) && n(function() { g.setFocus() }), angular.isDefined(r.focusOn) && s.$on(r.focusOn, function() { n(function() { g.setFocus() }) }), e.on("click", d), s.$on("$destroy", function() { e.off("click", d) }), u(s, function(e) {
  268. var t = angular.element("<div>").append(e),
  269. i = t.querySelectorAll(".ui-select-match");
  270. if (i.removeAttr("ui-select-match"), i.removeAttr("data-ui-select-match"), 1 !== i.length) throw c("transcluded", "Expected 1 .ui-select-match but got '{0}'.", i.length);
  271. a.querySelectorAll(".ui-select-match").replaceWith(i);
  272. var s = t.querySelectorAll(".ui-select-choices");
  273. if (s.removeAttr("ui-select-choices"), s.removeAttr("data-ui-select-choices"), 1 !== s.length) throw c("transcluded", "Expected 1 .ui-select-choices but got '{0}'.", s.length);
  274. a.querySelectorAll(".ui-select-choices").replaceWith(s)
  275. });
  276. var v = s.$eval(r.appendToBody);
  277. (void 0 !== v ? v : t.appendToBody) && (s.$watch("$select.open", function(e) { e ? p() : h() }), s.$on("$destroy", function() { h() }));
  278. var m = null,
  279. $ = ""
  280. }
  281. }
  282. }
  283. }]), c.directive("uiSelectMatch", ["uiSelectConfig", function(e) {
  284. return {
  285. restrict: "EA",
  286. require: "^uiSelect",
  287. replace: !0,
  288. transclude: !0,
  289. templateUrl: function(t) {
  290. var c = t.parent().attr("theme") || e.theme,
  291. i = t.parent().attr("multiple");
  292. return c + (i ? "/match-multiple.tpl.html" : "/match.tpl.html")
  293. },
  294. link: function(t, c, i, s) {
  295. function l(e) { s.allowClear = angular.isDefined(e) ? "" === e ? !0 : "true" === e.toLowerCase() : !1 }
  296. s.lockChoiceExpression = i.uiLockChoice, i.$observe("placeholder", function(t) { s.placeholder = void 0 !== t ? t : e.placeholder }), i.$observe("allowClear", l), l(i.allowClear), s.multiple && s.sizeSearchInput()
  297. }
  298. }
  299. }]), c.directive("uiSelectMultiple", ["uiSelectMinErr", "$timeout", function(t, c) {
  300. return {
  301. restrict: "EA",
  302. require: ["^uiSelect", "^ngModel"],
  303. controller: ["$scope", "$timeout", function(e, t) {
  304. var c, i = this,
  305. s = e.$select;
  306. e.$evalAsync(function() { c = e.ngModel }), i.activeMatchIndex = -1, i.updateModel = function() { c.$setViewValue(Date.now()), i.refreshComponent() }, i.refreshComponent = function() { s.refreshItems(), s.sizeSearchInput() }, i.removeChoice = function(c) {
  307. var l = s.selected[c];
  308. if (!l._uiSelectChoiceLocked) {
  309. var n = {};
  310. n[s.parserResult.itemName] = l, s.selected.splice(c, 1), i.activeMatchIndex = -1, s.sizeSearchInput(), t(function() { s.onRemoveCallback(e, { $item: l, $model: s.parserResult.modelMapper(e, n) }) }), i.updateModel()
  311. }
  312. }, i.getPlaceholder = function() { return s.selected.length ? void 0 : s.placeholder }
  313. }],
  314. controllerAs: "$selectMultiple",
  315. link: function(i, s, l, n) {
  316. function a(e) { return angular.isNumber(e.selectionStart) ? e.selectionStart : e.value.length }
  317. function r(t) {
  318. function c() {
  319. switch (t) {
  320. case e.LEFT:
  321. return ~h.activeMatchIndex ? u : n;
  322. case e.RIGHT:
  323. return ~h.activeMatchIndex && r !== n ? o : (d.activate(), !1);
  324. case e.BACKSPACE:
  325. return ~h.activeMatchIndex ? (h.removeChoice(r), u) : n;
  326. case e.DELETE:
  327. return ~h.activeMatchIndex ? (h.removeChoice(h.activeMatchIndex), r) : !1
  328. }
  329. }
  330. var i = a(d.searchInput[0]),
  331. s = d.selected.length,
  332. l = 0,
  333. n = s - 1,
  334. r = h.activeMatchIndex,
  335. o = h.activeMatchIndex + 1,
  336. u = h.activeMatchIndex - 1,
  337. p = r;
  338. return i > 0 || d.search.length && t == e.RIGHT ? !1 : (d.close(), p = c(), h.activeMatchIndex = d.selected.length && p !== !1 ? Math.min(n, Math.max(l, p)) : -1, !0)
  339. }
  340. function o(e) { if (void 0 === e || void 0 === d.search) return !1; var t = e.filter(function(e) { return void 0 === d.search.toUpperCase() || void 0 === e ? !1 : e.toUpperCase() === d.search.toUpperCase() }).length > 0; return t }
  341. function u(e, t) {
  342. var c = -1;
  343. if (angular.isArray(e))
  344. for (var i = angular.copy(e), s = 0; s < i.length; s++)
  345. if (void 0 === d.tagging.fct) i[s] + " " + d.taggingLabel === t && (c = s);
  346. else {
  347. var l = i[s];
  348. l.isTag = !0, angular.equals(l, t) && (c = s)
  349. }
  350. return c
  351. }
  352. var d = n[0],
  353. p = i.ngModel = n[1],
  354. h = i.$selectMultiple;
  355. d.multiple = !0, d.removeSelected = !0, d.focusInput = d.searchInput, p.$parsers.unshift(function() { for (var e, t = {}, c = [], s = d.selected.length - 1; s >= 0; s--) t = {}, t[d.parserResult.itemName] = d.selected[s], e = d.parserResult.modelMapper(i, t), c.unshift(e); return c }), p.$formatters.unshift(function(e) {
  356. var t, c = d.parserResult.source(i, { $select: { search: "" } }),
  357. s = {};
  358. if (!c) return e;
  359. var l = [],
  360. n = function(e, c) { if (e && e.length) { for (var n = e.length - 1; n >= 0; n--) { if (s[d.parserResult.itemName] = e[n], t = d.parserResult.modelMapper(i, s), d.parserResult.trackByExp) { var a = /\.(.+)/.exec(d.parserResult.trackByExp); if (a.length > 0 && t[a[1]] == c[a[1]]) return l.unshift(e[n]), !0 } if (angular.equals(t, c)) return l.unshift(e[n]), !0 } return !1 } };
  361. if (!e) return l;
  362. for (var a = e.length - 1; a >= 0; a--) n(d.selected, e[a]) || n(c, e[a]) || l.unshift(e[a]);
  363. return l
  364. }), i.$watchCollection(function() { return p.$modelValue }, function(e, t) { t != e && (p.$modelValue = null, h.refreshComponent()) }), p.$render = function() {
  365. if (!angular.isArray(p.$viewValue)) {
  366. if (!angular.isUndefined(p.$viewValue) && null !== p.$viewValue) throw t("multiarr", "Expected model value to be array but got '{0}'", p.$viewValue);
  367. d.selected = []
  368. }
  369. d.selected = p.$viewValue, i.$evalAsync()
  370. }, i.$on("uis:select", function(e, t) { d.selected.push(t), h.updateModel() }), i.$on("uis:activate", function() { h.activeMatchIndex = -1 }), i.$watch("$select.disabled", function(e, t) { t && !e && d.sizeSearchInput() }), d.searchInput.on("keydown", function(t) {
  371. var c = t.which;
  372. i.$apply(function() {
  373. var i = !1;
  374. e.isHorizontalMovement(c) && (i = r(c)), i && c != e.TAB && (t.preventDefault(), t.stopPropagation())
  375. })
  376. }), d.searchInput.on("keyup", function(t) {
  377. if (e.isVerticalMovement(t.which) || i.$evalAsync(function() { d.activeIndex = d.taggingLabel === !1 ? -1 : 0 }), d.tagging.isActivated && d.search.length > 0) {
  378. if (t.which === e.TAB || e.isControl(t) || e.isFunctionKey(t) || t.which === e.ESC || e.isVerticalMovement(t.which)) return;
  379. if (d.activeIndex = d.taggingLabel === !1 ? -1 : 0, d.taggingLabel === !1) return;
  380. var c, s, l, n, a = angular.copy(d.items),
  381. r = angular.copy(d.items),
  382. p = !1,
  383. h = -1;
  384. if (void 0 !== d.tagging.fct) {
  385. if (l = d.$filter("filter")(a, { isTag: !0 }), l.length > 0 && (n = l[0]), a.length > 0 && n && (p = !0, a = a.slice(1, a.length), r = r.slice(1, r.length)), c = d.tagging.fct(d.search), c.isTag = !0, r.filter(function(e) { return angular.equals(e, d.tagging.fct(d.search)) }).length > 0) return;
  386. c.isTag = !0
  387. } else { if (l = d.$filter("filter")(a, function(e) { return e.match(d.taggingLabel) }), l.length > 0 && (n = l[0]), s = a[0], void 0 !== s && a.length > 0 && n && (p = !0, a = a.slice(1, a.length), r = r.slice(1, r.length)), c = d.search + " " + d.taggingLabel, u(d.selected, d.search) > -1) return; if (o(r.concat(d.selected))) return p && (a = r, i.$evalAsync(function() { d.activeIndex = 0, d.items = a })), void 0; if (o(r)) return p && (d.items = r.slice(1, r.length)), void 0 }
  388. p && (h = u(d.selected, c)), h > -1 ? a = a.slice(h + 1, a.length - 1) : (a = [], a.push(c), a = a.concat(r)), i.$evalAsync(function() { d.activeIndex = 0, d.items = a })
  389. }
  390. }), d.searchInput.on("blur", function() { c(function() { h.activeMatchIndex = -1 }) })
  391. }
  392. }
  393. }]), c.directive("uiSelectSingle", ["$timeout", "$compile", function(t, c) {
  394. return {
  395. restrict: "EA",
  396. require: ["^uiSelect", "^ngModel"],
  397. link: function(i, s, l, n) {
  398. var a = n[0],
  399. r = n[1];
  400. r.$parsers.unshift(function(e) { var t, c = {}; return c[a.parserResult.itemName] = e, t = a.parserResult.modelMapper(i, c) }), r.$formatters.unshift(function(e) {
  401. var t, c = a.parserResult.source(i, { $select: { search: "" } }),
  402. s = {};
  403. if (c) {
  404. var l = function(c) { return s[a.parserResult.itemName] = c, t = a.parserResult.modelMapper(i, s), t == e };
  405. if (a.selected && l(a.selected)) return a.selected;
  406. for (var n = c.length - 1; n >= 0; n--)
  407. if (l(c[n])) return c[n]
  408. }
  409. return e
  410. }), i.$watch("$select.selected", function(e) { r.$viewValue !== e && r.$setViewValue(e) }), r.$render = function() { a.selected = r.$viewValue }, i.$on("uis:select", function(e, t) { a.selected = t }), i.$on("uis:close", function(e, c) { t(function() { a.focusser.prop("disabled", !1), c || a.focusser[0].focus() }, 0, !1) }), i.$on("uis:activate", function() { o.prop("disabled", !0) });
  411. var o = angular.element("<input ng-disabled='$select.disabled' class='ui-select-focusser ui-select-offscreen' type='text' id='{{ $select.focusserId }}' aria-label='{{ $select.focusserTitle }}' aria-haspopup='true' role='button' />");
  412. c(o)(i), a.focusser = o, a.focusInput = o, s.parent().append(o), o.bind("focus", function() { i.$evalAsync(function() { a.focus = !0 }) }), o.bind("blur", function() { i.$evalAsync(function() { a.focus = !1 }) }), o.bind("keydown", function(t) { return t.which === e.BACKSPACE ? (t.preventDefault(), t.stopPropagation(), a.select(void 0), i.$apply(), void 0) : (t.which === e.TAB || e.isControl(t) || e.isFunctionKey(t) || t.which === e.ESC || ((t.which == e.DOWN || t.which == e.UP || t.which == e.ENTER || t.which == e.SPACE) && (t.preventDefault(), t.stopPropagation(), a.activate()), i.$digest()), void 0) }), o.bind("keyup input", function(t) { t.which === e.TAB || e.isControl(t) || e.isFunctionKey(t) || t.which === e.ESC || t.which == e.ENTER || t.which === e.BACKSPACE || (a.activate(o.val()), o.val(""), i.$digest()) })
  413. }
  414. }
  415. }]), c.directive("uiSelectSort", ["$timeout", "uiSelectConfig", "uiSelectMinErr", function(e, t, c) {
  416. return {
  417. require: "^uiSelect",
  418. link: function(t, i, s, l) {
  419. if (null === t[s.uiSelectSort]) throw c("sort", "Expected a list to sort");
  420. var n = angular.extend({ axis: "horizontal" }, t.$eval(s.uiSelectSortOptions)),
  421. a = n.axis,
  422. r = "dragging",
  423. o = "dropping",
  424. u = "dropping-before",
  425. d = "dropping-after";
  426. t.$watch(function() { return l.sortable }, function(e) { e ? i.attr("draggable", !0) : i.removeAttr("draggable") }), i.on("dragstart", function(e) { i.addClass(r), (e.dataTransfer || e.originalEvent.dataTransfer).setData("text/plain", t.$index) }), i.on("dragend", function() { i.removeClass(r) });
  427. var p, h = function(e, t) { this.splice(t, 0, this.splice(e, 1)[0]) },
  428. g = function(e) {
  429. e.preventDefault();
  430. var t = "vertical" === a ? e.offsetY || e.layerY || (e.originalEvent ? e.originalEvent.offsetY : 0) : e.offsetX || e.layerX || (e.originalEvent ? e.originalEvent.offsetX : 0);
  431. t < this["vertical" === a ? "offsetHeight" : "offsetWidth"] / 2 ? (i.removeClass(d), i.addClass(u)) : (i.removeClass(u), i.addClass(d))
  432. },
  433. f = function(t) {
  434. t.preventDefault();
  435. var c = parseInt((t.dataTransfer || t.originalEvent.dataTransfer).getData("text/plain"), 10);
  436. e.cancel(p), p = e(function() { v(c) }, 20)
  437. },
  438. v = function(e) {
  439. var c = t.$eval(s.uiSelectSort),
  440. l = c[e],
  441. n = null;
  442. n = i.hasClass(u) ? e < t.$index ? t.$index - 1 : t.$index : e < t.$index ? t.$index : t.$index + 1, h.apply(c, [e, n]), t.$apply(function() { t.$emit("uiSelectSort:change", { array: c, item: l, from: e, to: n }) }), i.removeClass(o), i.removeClass(u), i.removeClass(d), i.off("drop", f)
  443. };
  444. i.on("dragenter", function() { i.hasClass(r) || (i.addClass(o), i.on("dragover", g), i.on("drop", f)) }), i.on("dragleave", function(e) { e.target == i && (i.removeClass(o), i.removeClass(u), i.removeClass(d), i.off("dragover", g), i.off("drop", f)) })
  445. }
  446. }
  447. }]), c.service("uisRepeatParser", ["uiSelectMinErr", "$parse", function(e, t) {
  448. var c = this;
  449. c.parse = function(c) { var i = c.match(/^\s*(?:([\s\S]+?)\s+as\s+)?([\S]+?)\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?\s*$/); if (!i) throw e("iexp", "Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '{0}'.", c); return { itemName: i[2], source: t(i[3]), trackByExp: i[4], modelMapper: t(i[1] || i[2]) } }, c.getGroupNgRepeatExpression = function() { return "$group in $select.groups" }, c.getNgRepeatExpression = function(e, t, c, i) { var s = e + " in " + (i ? "$group.items" : t); return c && (s += " track by " + c), s }
  450. }])
  451. }(), angular.module("ui.select").run(["$templateCache", function(e) {
  452. e.put("bootstrap/choices.tpl.html", '<ul class="ui-select-choices ui-select-choices-content dropdown-menu" role="listbox" ng-show="$select.items.length > 0"><li class="ui-select-choices-group" id="ui-select-choices-{{ $select.generatedId }}"><div class="divider" ng-show="$select.isGrouped && $index > 0"></div><div ng-show="$select.isGrouped" class="ui-select-choices-group-label dropdown-header" ng-bind="$group.name"></div><div id="ui-select-choices-row-{{ $select.generatedId }}-{{$index}}" class="ui-select-choices-row" ng-class="{active: $select.isActive(this), disabled: $select.isDisabled(this)}" role="option"><a href="javascript:void(0)" class="ui-select-choices-row-inner"></a></div></li></ul>'), e.put("bootstrap/match-multiple.tpl.html", '<span class="ui-select-match"><span ng-repeat="$item in $select.selected"><span class="ui-select-match-item btn btn-default btn-xs" tabindex="-1" type="button" ng-disabled="$select.disabled" ng-click="$selectMultiple.activeMatchIndex = $index;" ng-class="{\'btn-primary\':$selectMultiple.activeMatchIndex === $index, \'select-locked\':$select.isLocked(this, $index)}" ui-select-sort="$select.selected"><span class="close ui-select-match-close" ng-hide="$select.disabled" ng-click="$selectMultiple.removeChoice($index)">&nbsp;&times;</span> <span uis-transclude-append=""></span></span></span></span>'), e.put("bootstrap/match.tpl.html", '<div class="ui-select-match" ng-hide="$select.open" ng-disabled="$select.disabled" ng-class="{\'btn-default-focus\':$select.focus}"><span tabindex="-1" class="btn btn-default form-control ui-select-toggle" aria-label="{{ $select.baseTitle }} activate" ng-disabled="$select.disabled" ng-click="$select.activate()" style="outline: 0;"><span ng-show="$select.isEmpty()" class="ui-select-placeholder text-muted">{{$select.placeholder}}</span> <span ng-hide="$select.isEmpty()" class="ui-select-match-text pull-left" ng-class="{\'ui-select-allow-clear\': $select.allowClear && !$select.isEmpty()}" ng-transclude=""></span> <i class="caret pull-right" ng-click="$select.toggle($event)"></i> <a ng-show="$select.allowClear && !$select.isEmpty()" aria-label="{{ $select.baseTitle }} clear" style="margin-right: 10px" ng-click="$select.clear($event)" class="btn btn-xs btn-link pull-right"><i class="glyphicon glyphicon-remove" aria-hidden="true"></i></a></span></div>'), e.put("bootstrap/select-multiple.tpl.html", '<div class="ui-select-container ui-select-multiple ui-select-bootstrap dropdown form-control" ng-class="{open: $select.open}"><div><div class="ui-select-match"></div><input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" class="ui-select-search input-xs" placeholder="{{$selectMultiple.getPlaceholder()}}" ng-disabled="$select.disabled" ng-hide="$select.disabled" ng-click="$select.activate()" ng-model="$select.search" role="combobox" aria-label="{{ $select.baseTitle }}" ondrop="return false;"></div><div class="ui-select-choices"></div></div>'), e.put("bootstrap/select.tpl.html", '<div class="ui-select-container ui-select-bootstrap dropdown" ng-class="{open: $select.open}"><div class="ui-select-match"></div><input type="text" autocomplete="off" tabindex="-1" aria-expanded="true" aria-label="{{ $select.baseTitle }}" aria-owns="ui-select-choices-{{ $select.generatedId }}" aria-activedescendant="ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}" class="form-control ui-select-search" placeholder="{{$select.placeholder}}" ng-model="$select.search" ng-show="$select.searchEnabled && $select.open"><div class="ui-select-choices"></div></div>'), e.put("select2/choices.tpl.html", '<ul class="ui-select-choices ui-select-choices-content select2-results"><li class="ui-select-choices-group" ng-class="{\'select2-result-with-children\': $select.choiceGrouped($group) }"><div ng-show="$select.choiceGrouped($group)" class="ui-select-choices-group-label select2-result-label" ng-bind="$group.name"></div><ul role="listbox" id="ui-select-choices-{{ $select.generatedId }}" ng-class="{\'select2-result-sub\': $select.choiceGrouped($group), \'select2-result-single\': !$select.choiceGrouped($group) }"><li role="option" id="ui-select-choices-row-{{ $select.generatedId }}-{{$index}}" class="ui-select-choices-row" ng-class="{\'select2-highlighted\': $select.isActive(this), \'select2-disabled\': $select.isDisabled(this)}"><div class="select2-result-label ui-select-choices-row-inner"></div></li></ul></li></ul>'), e.put("select2/match-multiple.tpl.html", '<span class="ui-select-match"><li class="ui-select-match-item select2-search-choice" ng-repeat="$item in $select.selected" ng-class="{\'select2-search-choice-focus\':$selectMultiple.activeMatchIndex === $index, \'select2-locked\':$select.isLocked(this, $index)}" ui-select-sort="$select.selected"><span uis-transclude-append=""></span> <a href="javascript:;" class="ui-select-match-close select2-search-choice-close" ng-click="$selectMultiple.removeChoice($index)" tabindex="-1"></a></li></span>'), e.put("select2/match.tpl.html", '<a class="select2-choice ui-select-match" ng-class="{\'select2-default\': $select.isEmpty()}" ng-click="$select.toggle($event)" aria-label="{{ $select.baseTitle }} select"><span ng-show="$select.isEmpty()" class="select2-chosen">{{$select.placeholder}}</span> <span ng-hide="$select.isEmpty()" class="select2-chosen" ng-transclude=""></span> <abbr ng-if="$select.allowClear && !$select.isEmpty()" class="select2-search-choice-close" ng-click="$select.clear($event)"></abbr> <span class="select2-arrow ui-select-toggle"><b></b></span></a>'), e.put("select2/select-multiple.tpl.html", '<div class="ui-select-container ui-select-multiple select2 select2-container select2-container-multi" ng-class="{\'select2-container-active select2-dropdown-open open\': $select.open, \'select2-container-disabled\': $select.disabled}"><ul class="select2-choices"><span class="ui-select-match"></span><li class="select2-search-field"><input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="combobox" aria-expanded="true" aria-owns="ui-select-choices-{{ $select.generatedId }}" aria-label="{{ $select.baseTitle }}" aria-activedescendant="ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}" class="select2-input ui-select-search" placeholder="{{$selectMultiple.getPlaceholder()}}" ng-disabled="$select.disabled" ng-hide="$select.disabled" ng-model="$select.search" ng-click="$select.activate()" style="width: 34px;" ondrop="return false;"></li></ul><div class="select2-drop select2-with-searchbox select2-drop-active" ng-class="{\'select2-display-none\': !$select.open}"><div class="ui-select-choices"></div></div></div>'), e.put("select2/select.tpl.html", '<div class="ui-select-container select2 select2-container" ng-class="{\'select2-container-active select2-dropdown-open open\': $select.open, \'select2-container-disabled\': $select.disabled, \'select2-container-active\': $select.focus, \'select2-allowclear\': $select.allowClear && !$select.isEmpty()}"><div class="ui-select-match"></div><div class="select2-drop select2-with-searchbox select2-drop-active" ng-class="{\'select2-display-none\': !$select.open}"><div class="select2-search" ng-show="$select.searchEnabled"><input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="combobox" aria-expanded="true" aria-owns="ui-select-choices-{{ $select.generatedId }}" aria-label="{{ $select.baseTitle }}" aria-activedescendant="ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}" class="ui-select-search select2-input" ng-model="$select.search"></div><div class="ui-select-choices"></div></div></div>'), e.put("selectize/choices.tpl.html", '<div ng-show="$select.open" class="ui-select-choices selectize-dropdown single"><div class="ui-select-choices-content selectize-dropdown-content"><div class="ui-select-choices-group optgroup" role="listbox"><div ng-show="$select.isGrouped" class="ui-select-choices-group-label optgroup-header" ng-bind="$group.name"></div><div role="option" class="ui-select-choices-row" ng-class="{active: $select.isActive(this), disabled: $select.isDisabled(this)}"><div class="option ui-select-choices-row-inner" data-selectable=""></div></div></div></div></div>'), e.put("selectize/match.tpl.html", '<div ng-hide="($select.open || $select.isEmpty())" class="ui-select-match" ng-transclude=""></div>'), e.put("selectize/select.tpl.html", '<div class="ui-select-container selectize-control single" ng-class="{\'open\': $select.open}"><div class="selectize-input" ng-class="{\'focus\': $select.open, \'disabled\': $select.disabled, \'selectize-focus\' : $select.focus}" ng-click="$select.activate()"><div class="ui-select-match"></div><input type="text" autocomplete="off" tabindex="-1" class="ui-select-search ui-select-toggle" ng-click="$select.toggle($event)" placeholder="{{$select.placeholder}}" ng-model="$select.search" ng-hide="!$select.searchEnabled || ($select.selected && !$select.open)" ng-disabled="$select.disabled" aria-label="{{ $select.baseTitle }}"></div><div class="ui-select-choices"></div></div>')
  453. }]);