/*! jQuery v2.2.4 | (c) jQuery Foundation | jquery.org/license */ !function (a, b) { "object" == typeof module && "object" == typeof module.exports ? module.exports = a.document ? b(a, !0) : function (a) { if (!a.document) throw new Error("jQuery requires a window with a document"); return b(a) } : b(a) }("undefined" != typeof window ? window : this, function (a, b) { var c = [], d = a.document, e = c.slice, f = c.concat, g = c.push, h = c.indexOf, i = {}, j = i.toString, k = i.hasOwnProperty, l = {}, m = "2.2.4", n = function (a, b) { return new n.fn.init(a, b) }, o = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, p = /^-ms-/, q = /-([\da-z])/gi, r = function (a, b) { return b.toUpperCase() }; n.fn = n.prototype = { jquery: m, constructor: n, selector: "", length: 0, toArray: function () { return e.call(this) }, get: function (a) { return null != a ? 0 > a ? this[a + this.length] : this[a] : e.call(this) }, pushStack: function (a) { var b = n.merge(this.constructor(), a); return b.prevObject = this, b.context = this.context, b }, each: function (a) { return n.each(this, a) }, map: function (a) { return this.pushStack(n.map(this, function (b, c) { return a.call(b, c, b) })) }, slice: function () { return this.pushStack(e.apply(this, arguments)) }, first: function () { return this.eq(0) }, last: function () { return this.eq(-1) }, eq: function (a) { var b = this.length, c = +a + (0 > a ? b : 0); return this.pushStack(c >= 0 && b > c ? [this[c]] : []) }, end: function () { return this.prevObject || this.constructor() }, push: g, sort: c.sort, splice: c.splice }, n.extend = n.fn.extend = function () { var a, b, c, d, e, f, g = arguments[0] || {}, h = 1, i = arguments.length, j = !1; for ("boolean" == typeof g && (j = g, g = arguments[h] || {}, h++), "object" == typeof g || n.isFunction(g) || (g = {}), h === i && (g = this, h--); i > h; h++)if (null != (a = arguments[h])) for (b in a) c = g[b], d = a[b], g !== d && (j && d && (n.isPlainObject(d) || (e = n.isArray(d))) ? (e ? (e = !1, f = c && n.isArray(c) ? c : []) : f = c && n.isPlainObject(c) ? c : {}, g[b] = n.extend(j, f, d)) : void 0 !== d && (g[b] = d)); return g }, n.extend({ expando: "jQuery" + (m + Math.random()).replace(/\D/g, ""), isReady: !0, error: function (a) { throw new Error(a) }, noop: function () { }, isFunction: function (a) { return "function" === n.type(a) }, isArray: Array.isArray, isWindow: function (a) { return null != a && a === a.window }, isNumeric: function (a) { var b = a && a.toString(); return !n.isArray(a) && b - parseFloat(b) + 1 >= 0 }, isPlainObject: function (a) { var b; if ("object" !== n.type(a) || a.nodeType || n.isWindow(a)) return !1; if (a.constructor && !k.call(a, "constructor") && !k.call(a.constructor.prototype || {}, "isPrototypeOf")) return !1; for (b in a); return void 0 === b || k.call(a, b) }, isEmptyObject: function (a) { var b; for (b in a) return !1; return !0 }, type: function (a) { return null == a ? a + "" : "object" == typeof a || "function" == typeof a ? i[j.call(a)] || "object" : typeof a }, globalEval: function (a) { var b, c = eval; a = n.trim(a), a && (1 === a.indexOf("use strict") ? (b = d.createElement("script"), b.text = a, d.head.appendChild(b).parentNode.removeChild(b)) : c(a)) }, camelCase: function (a) { return a.replace(p, "ms-").replace(q, r) }, nodeName: function (a, b) { return a.nodeName && a.nodeName.toLowerCase() === b.toLowerCase() }, each: function (a, b) { var c, d = 0; if (s(a)) { for (c = a.length; c > d; d++)if (b.call(a[d], d, a[d]) === !1) break } else for (d in a) if (b.call(a[d], d, a[d]) === !1) break; return a }, trim: function (a) { return null == a ? "" : (a + "").replace(o, "") }, makeArray: function (a, b) { var c = b || []; return null != a && (s(Object(a)) ? n.merge(c, "string" == typeof a ? [a] : a) : g.call(c, a)), c }, inArray: function (a, b, c) { return null == b ? -1 : h.call(b, a, c) }, merge: function (a, b) { for (var c = +b.length, d = 0, e = a.length; c > d; d++)a[e++] = b[d]; return a.length = e, a }, grep: function (a, b, c) { for (var d, e = [], f = 0, g = a.length, h = !c; g > f; f++)d = !b(a[f], f), d !== h && e.push(a[f]); return e }, map: function (a, b, c) { var d, e, g = 0, h = []; if (s(a)) for (d = a.length; d > g; g++)e = b(a[g], g, c), null != e && h.push(e); else for (g in a) e = b(a[g], g, c), null != e && h.push(e); return f.apply([], h) }, guid: 1, proxy: function (a, b) { var c, d, f; return "string" == typeof b && (c = a[b], b = a, a = c), n.isFunction(a) ? (d = e.call(arguments, 2), f = function () { return a.apply(b || this, d.concat(e.call(arguments))) }, f.guid = a.guid = a.guid || n.guid++ , f) : void 0 }, now: Date.now, support: l }), "function" == typeof Symbol && (n.fn[Symbol.iterator] = c[Symbol.iterator]), n.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "), function (a, b) { i["[object " + b + "]"] = b.toLowerCase() }); function s(a) { var b = !!a && "length" in a && a.length, c = n.type(a); return "function" === c || n.isWindow(a) ? !1 : "array" === c || 0 === b || "number" == typeof b && b > 0 && b - 1 in a } var t = function (a) { var b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u = "sizzle" + 1 * new Date, v = a.document, w = 0, x = 0, y = ga(), z = ga(), A = ga(), B = function (a, b) { return a === b && (l = !0), 0 }, C = 1 << 31, D = {}.hasOwnProperty, E = [], F = E.pop, G = E.push, H = E.push, I = E.slice, J = function (a, b) { for (var c = 0, d = a.length; d > c; c++)if (a[c] === b) return c; return -1 }, K = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", L = "[\\x20\\t\\r\\n\\f]", M = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", N = "\\[" + L + "*(" + M + ")(?:" + L + "*([*^$|!~]?=)" + L + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + M + "))|)" + L + "*\\]", O = ":(" + M + ")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|" + N + ")*)|.*)\\)|)", P = new RegExp(L + "+", "g"), Q = new RegExp("^" + L + "+|((?:^|[^\\\\])(?:\\\\.)*)" + L + "+$", "g"), R = new RegExp("^" + L + "*," + L + "*"), S = new RegExp("^" + L + "*([>+~]|" + L + ")" + L + "*"), T = new RegExp("=" + L + "*([^\\]'\"]*?)" + L + "*\\]", "g"), U = new RegExp(O), V = new RegExp("^" + M + "$"), W = { ID: new RegExp("^#(" + M + ")"), CLASS: new RegExp("^\\.(" + M + ")"), TAG: new RegExp("^(" + M + "|[*])"), ATTR: new RegExp("^" + N), PSEUDO: new RegExp("^" + O), CHILD: new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + L + "*(even|odd|(([+-]|)(\\d*)n|)" + L + "*(?:([+-]|)" + L + "*(\\d+)|))" + L + "*\\)|)", "i"), bool: new RegExp("^(?:" + K + ")$", "i"), needsContext: new RegExp("^" + L + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + L + "*((?:-\\d)?\\d*)" + L + "*\\)|)(?=[^-]|$)", "i") }, X = /^(?:input|select|textarea|button)$/i, Y = /^h\d$/i, Z = /^[^{]+\{\s*\[native \w/, $ = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, _ = /[+~]/, aa = /'|\\/g, ba = new RegExp("\\\\([\\da-f]{1,6}" + L + "?|(" + L + ")|.)", "ig"), ca = function (a, b, c) { var d = "0x" + b - 65536; return d !== d || c ? b : 0 > d ? String.fromCharCode(d + 65536) : String.fromCharCode(d >> 10 | 55296, 1023 & d | 56320) }, da = function () { m() }; try { H.apply(E = I.call(v.childNodes), v.childNodes), E[v.childNodes.length].nodeType } catch (ea) { H = { apply: E.length ? function (a, b) { G.apply(a, I.call(b)) } : function (a, b) { var c = a.length, d = 0; while (a[c++] = b[d++]); a.length = c - 1 } } } function fa(a, b, d, e) { var f, h, j, k, l, o, r, s, w = b && b.ownerDocument, x = b ? b.nodeType : 9; if (d = d || [], "string" != typeof a || !a || 1 !== x && 9 !== x && 11 !== x) return d; if (!e && ((b ? b.ownerDocument || b : v) !== n && m(b), b = b || n, p)) { if (11 !== x && (o = $.exec(a))) if (f = o[1]) { if (9 === x) { if (!(j = b.getElementById(f))) return d; if (j.id === f) return d.push(j), d } else if (w && (j = w.getElementById(f)) && t(b, j) && j.id === f) return d.push(j), d } else { if (o[2]) return H.apply(d, b.getElementsByTagName(a)), d; if ((f = o[3]) && c.getElementsByClassName && b.getElementsByClassName) return H.apply(d, b.getElementsByClassName(f)), d } if (c.qsa && !A[a + " "] && (!q || !q.test(a))) { if (1 !== x) w = b, s = a; else if ("object" !== b.nodeName.toLowerCase()) { (k = b.getAttribute("id")) ? k = k.replace(aa, "\\$&") : b.setAttribute("id", k = u), r = g(a), h = r.length, l = V.test(k) ? "#" + k : "[id='" + k + "']"; while (h--) r[h] = l + " " + qa(r[h]); s = r.join(","), w = _.test(a) && oa(b.parentNode) || b } if (s) try { return H.apply(d, w.querySelectorAll(s)), d } catch (y) { } finally { k === u && b.removeAttribute("id") } } } return i(a.replace(Q, "$1"), b, d, e) } function ga() { var a = []; function b(c, e) { return a.push(c + " ") > d.cacheLength && delete b[a.shift()], b[c + " "] = e } return b } function ha(a) { return a[u] = !0, a } function ia(a) { var b = n.createElement("div"); try { return !!a(b) } catch (c) { return !1 } finally { b.parentNode && b.parentNode.removeChild(b), b = null } } function ja(a, b) { var c = a.split("|"), e = c.length; while (e--) d.attrHandle[c[e]] = b } function ka(a, b) { var c = b && a, d = c && 1 === a.nodeType && 1 === b.nodeType && (~b.sourceIndex || C) - (~a.sourceIndex || C); if (d) return d; if (c) while (c = c.nextSibling) if (c === b) return -1; return a ? 1 : -1 } function la(a) { return function (b) { var c = b.nodeName.toLowerCase(); return "input" === c && b.type === a } } function ma(a) { return function (b) { var c = b.nodeName.toLowerCase(); return ("input" === c || "button" === c) && b.type === a } } function na(a) { return ha(function (b) { return b = +b, ha(function (c, d) { var e, f = a([], c.length, b), g = f.length; while (g--) c[e = f[g]] && (c[e] = !(d[e] = c[e])) }) }) } function oa(a) { return a && "undefined" != typeof a.getElementsByTagName && a } c = fa.support = {}, f = fa.isXML = function (a) { var b = a && (a.ownerDocument || a).documentElement; return b ? "HTML" !== b.nodeName : !1 }, m = fa.setDocument = function (a) { var b, e, g = a ? a.ownerDocument || a : v; return g !== n && 9 === g.nodeType && g.documentElement ? (n = g, o = n.documentElement, p = !f(n), (e = n.defaultView) && e.top !== e && (e.addEventListener ? e.addEventListener("unload", da, !1) : e.attachEvent && e.attachEvent("onunload", da)), c.attributes = ia(function (a) { return a.className = "i", !a.getAttribute("className") }), c.getElementsByTagName = ia(function (a) { return a.appendChild(n.createComment("")), !a.getElementsByTagName("*").length }), c.getElementsByClassName = Z.test(n.getElementsByClassName), c.getById = ia(function (a) { return o.appendChild(a).id = u, !n.getElementsByName || !n.getElementsByName(u).length }), c.getById ? (d.find.ID = function (a, b) { if ("undefined" != typeof b.getElementById && p) { var c = b.getElementById(a); return c ? [c] : [] } }, d.filter.ID = function (a) { var b = a.replace(ba, ca); return function (a) { return a.getAttribute("id") === b } }) : (delete d.find.ID, d.filter.ID = function (a) { var b = a.replace(ba, ca); return function (a) { var c = "undefined" != typeof a.getAttributeNode && a.getAttributeNode("id"); return c && c.value === b } }), d.find.TAG = c.getElementsByTagName ? function (a, b) { return "undefined" != typeof b.getElementsByTagName ? b.getElementsByTagName(a) : c.qsa ? b.querySelectorAll(a) : void 0 } : function (a, b) { var c, d = [], e = 0, f = b.getElementsByTagName(a); if ("*" === a) { while (c = f[e++]) 1 === c.nodeType && d.push(c); return d } return f }, d.find.CLASS = c.getElementsByClassName && function (a, b) { return "undefined" != typeof b.getElementsByClassName && p ? b.getElementsByClassName(a) : void 0 }, r = [], q = [], (c.qsa = Z.test(n.querySelectorAll)) && (ia(function (a) { o.appendChild(a).innerHTML = "", a.querySelectorAll("[msallowcapture^='']").length && q.push("[*^$]=" + L + "*(?:''|\"\")"), a.querySelectorAll("[selected]").length || q.push("\\[" + L + "*(?:value|" + K + ")"), a.querySelectorAll("[id~=" + u + "-]").length || q.push("~="), a.querySelectorAll(":checked").length || q.push(":checked"), a.querySelectorAll("a#" + u + "+*").length || q.push(".#.+[+~]") }), ia(function (a) { var b = n.createElement("input"); b.setAttribute("type", "hidden"), a.appendChild(b).setAttribute("name", "D"), a.querySelectorAll("[name=d]").length && q.push("name" + L + "*[*^$|!~]?="), a.querySelectorAll(":enabled").length || q.push(":enabled", ":disabled"), a.querySelectorAll("*,:x"), q.push(",.*:") })), (c.matchesSelector = Z.test(s = o.matches || o.webkitMatchesSelector || o.mozMatchesSelector || o.oMatchesSelector || o.msMatchesSelector)) && ia(function (a) { c.disconnectedMatch = s.call(a, "div"), s.call(a, "[s!='']:x"), r.push("!=", O) }), q = q.length && new RegExp(q.join("|")), r = r.length && new RegExp(r.join("|")), b = Z.test(o.compareDocumentPosition), t = b || Z.test(o.contains) ? function (a, b) { var c = 9 === a.nodeType ? a.documentElement : a, d = b && b.parentNode; return a === d || !(!d || 1 !== d.nodeType || !(c.contains ? c.contains(d) : a.compareDocumentPosition && 16 & a.compareDocumentPosition(d))) } : function (a, b) { if (b) while (b = b.parentNode) if (b === a) return !0; return !1 }, B = b ? function (a, b) { if (a === b) return l = !0, 0; var d = !a.compareDocumentPosition - !b.compareDocumentPosition; return d ? d : (d = (a.ownerDocument || a) === (b.ownerDocument || b) ? a.compareDocumentPosition(b) : 1, 1 & d || !c.sortDetached && b.compareDocumentPosition(a) === d ? a === n || a.ownerDocument === v && t(v, a) ? -1 : b === n || b.ownerDocument === v && t(v, b) ? 1 : k ? J(k, a) - J(k, b) : 0 : 4 & d ? -1 : 1) } : function (a, b) { if (a === b) return l = !0, 0; var c, d = 0, e = a.parentNode, f = b.parentNode, g = [a], h = [b]; if (!e || !f) return a === n ? -1 : b === n ? 1 : e ? -1 : f ? 1 : k ? J(k, a) - J(k, b) : 0; if (e === f) return ka(a, b); c = a; while (c = c.parentNode) g.unshift(c); c = b; while (c = c.parentNode) h.unshift(c); while (g[d] === h[d]) d++; return d ? ka(g[d], h[d]) : g[d] === v ? -1 : h[d] === v ? 1 : 0 }, n) : n }, fa.matches = function (a, b) { return fa(a, null, null, b) }, fa.matchesSelector = function (a, b) { if ((a.ownerDocument || a) !== n && m(a), b = b.replace(T, "='$1']"), c.matchesSelector && p && !A[b + " "] && (!r || !r.test(b)) && (!q || !q.test(b))) try { var d = s.call(a, b); if (d || c.disconnectedMatch || a.document && 11 !== a.document.nodeType) return d } catch (e) { } return fa(b, n, null, [a]).length > 0 }, fa.contains = function (a, b) { return (a.ownerDocument || a) !== n && m(a), t(a, b) }, fa.attr = function (a, b) { (a.ownerDocument || a) !== n && m(a); var e = d.attrHandle[b.toLowerCase()], f = e && D.call(d.attrHandle, b.toLowerCase()) ? e(a, b, !p) : void 0; return void 0 !== f ? f : c.attributes || !p ? a.getAttribute(b) : (f = a.getAttributeNode(b)) && f.specified ? f.value : null }, fa.error = function (a) { throw new Error("Syntax error, unrecognized expression: " + a) }, fa.uniqueSort = function (a) { var b, d = [], e = 0, f = 0; if (l = !c.detectDuplicates, k = !c.sortStable && a.slice(0), a.sort(B), l) { while (b = a[f++]) b === a[f] && (e = d.push(f)); while (e--) a.splice(d[e], 1) } return k = null, a }, e = fa.getText = function (a) { var b, c = "", d = 0, f = a.nodeType; if (f) { if (1 === f || 9 === f || 11 === f) { if ("string" == typeof a.textContent) return a.textContent; for (a = a.firstChild; a; a = a.nextSibling)c += e(a) } else if (3 === f || 4 === f) return a.nodeValue } else while (b = a[d++]) c += e(b); return c }, d = fa.selectors = { cacheLength: 50, createPseudo: ha, match: W, attrHandle: {}, find: {}, relative: { ">": { dir: "parentNode", first: !0 }, " ": { dir: "parentNode" }, "+": { dir: "previousSibling", first: !0 }, "~": { dir: "previousSibling" } }, preFilter: { ATTR: function (a) { return a[1] = a[1].replace(ba, ca), a[3] = (a[3] || a[4] || a[5] || "").replace(ba, ca), "~=" === a[2] && (a[3] = " " + a[3] + " "), a.slice(0, 4) }, CHILD: function (a) { return a[1] = a[1].toLowerCase(), "nth" === a[1].slice(0, 3) ? (a[3] || fa.error(a[0]), a[4] = +(a[4] ? a[5] + (a[6] || 1) : 2 * ("even" === a[3] || "odd" === a[3])), a[5] = +(a[7] + a[8] || "odd" === a[3])) : a[3] && fa.error(a[0]), a }, PSEUDO: function (a) { var b, c = !a[6] && a[2]; return W.CHILD.test(a[0]) ? null : (a[3] ? a[2] = a[4] || a[5] || "" : c && U.test(c) && (b = g(c, !0)) && (b = c.indexOf(")", c.length - b) - c.length) && (a[0] = a[0].slice(0, b), a[2] = c.slice(0, b)), a.slice(0, 3)) } }, filter: { TAG: function (a) { var b = a.replace(ba, ca).toLowerCase(); return "*" === a ? function () { return !0 } : function (a) { return a.nodeName && a.nodeName.toLowerCase() === b } }, CLASS: function (a) { var b = y[a + " "]; return b || (b = new RegExp("(^|" + L + ")" + a + "(" + L + "|$)")) && y(a, function (a) { return b.test("string" == typeof a.className && a.className || "undefined" != typeof a.getAttribute && a.getAttribute("class") || "") }) }, ATTR: function (a, b, c) { return function (d) { var e = fa.attr(d, a); return null == e ? "!=" === b : b ? (e += "", "=" === b ? e === c : "!=" === b ? e !== c : "^=" === b ? c && 0 === e.indexOf(c) : "*=" === b ? c && e.indexOf(c) > -1 : "$=" === b ? c && e.slice(-c.length) === c : "~=" === b ? (" " + e.replace(P, " ") + " ").indexOf(c) > -1 : "|=" === b ? e === c || e.slice(0, c.length + 1) === c + "-" : !1) : !0 } }, CHILD: function (a, b, c, d, e) { var f = "nth" !== a.slice(0, 3), g = "last" !== a.slice(-4), h = "of-type" === b; return 1 === d && 0 === e ? function (a) { return !!a.parentNode } : function (b, c, i) { var j, k, l, m, n, o, p = f !== g ? "nextSibling" : "previousSibling", q = b.parentNode, r = h && b.nodeName.toLowerCase(), s = !i && !h, t = !1; if (q) { if (f) { while (p) { m = b; while (m = m[p]) if (h ? m.nodeName.toLowerCase() === r : 1 === m.nodeType) return !1; o = p = "only" === a && !o && "nextSibling" } return !0 } if (o = [g ? q.firstChild : q.lastChild], g && s) { m = q, l = m[u] || (m[u] = {}), k = l[m.uniqueID] || (l[m.uniqueID] = {}), j = k[a] || [], n = j[0] === w && j[1], t = n && j[2], m = n && q.childNodes[n]; while (m = ++n && m && m[p] || (t = n = 0) || o.pop()) if (1 === m.nodeType && ++t && m === b) { k[a] = [w, n, t]; break } } else if (s && (m = b, l = m[u] || (m[u] = {}), k = l[m.uniqueID] || (l[m.uniqueID] = {}), j = k[a] || [], n = j[0] === w && j[1], t = n), t === !1) while (m = ++n && m && m[p] || (t = n = 0) || o.pop()) if ((h ? m.nodeName.toLowerCase() === r : 1 === m.nodeType) && ++t && (s && (l = m[u] || (m[u] = {}), k = l[m.uniqueID] || (l[m.uniqueID] = {}), k[a] = [w, t]), m === b)) break; return t -= e, t === d || t % d === 0 && t / d >= 0 } } }, PSEUDO: function (a, b) { var c, e = d.pseudos[a] || d.setFilters[a.toLowerCase()] || fa.error("unsupported pseudo: " + a); return e[u] ? e(b) : e.length > 1 ? (c = [a, a, "", b], d.setFilters.hasOwnProperty(a.toLowerCase()) ? ha(function (a, c) { var d, f = e(a, b), g = f.length; while (g--) d = J(a, f[g]), a[d] = !(c[d] = f[g]) }) : function (a) { return e(a, 0, c) }) : e } }, pseudos: { not: ha(function (a) { var b = [], c = [], d = h(a.replace(Q, "$1")); return d[u] ? ha(function (a, b, c, e) { var f, g = d(a, null, e, []), h = a.length; while (h--) (f = g[h]) && (a[h] = !(b[h] = f)) }) : function (a, e, f) { return b[0] = a, d(b, null, f, c), b[0] = null, !c.pop() } }), has: ha(function (a) { return function (b) { return fa(a, b).length > 0 } }), contains: ha(function (a) { return a = a.replace(ba, ca), function (b) { return (b.textContent || b.innerText || e(b)).indexOf(a) > -1 } }), lang: ha(function (a) { return V.test(a || "") || fa.error("unsupported lang: " + a), a = a.replace(ba, ca).toLowerCase(), function (b) { var c; do if (c = p ? b.lang : b.getAttribute("xml:lang") || b.getAttribute("lang")) return c = c.toLowerCase(), c === a || 0 === c.indexOf(a + "-"); while ((b = b.parentNode) && 1 === b.nodeType); return !1 } }), target: function (b) { var c = a.location && a.location.hash; return c && c.slice(1) === b.id }, root: function (a) { return a === o }, focus: function (a) { return a === n.activeElement && (!n.hasFocus || n.hasFocus()) && !!(a.type || a.href || ~a.tabIndex) }, enabled: function (a) { return a.disabled === !1 }, disabled: function (a) { return a.disabled === !0 }, checked: function (a) { var b = a.nodeName.toLowerCase(); return "input" === b && !!a.checked || "option" === b && !!a.selected }, selected: function (a) { return a.parentNode && a.parentNode.selectedIndex, a.selected === !0 }, empty: function (a) { for (a = a.firstChild; a; a = a.nextSibling)if (a.nodeType < 6) return !1; return !0 }, parent: function (a) { return !d.pseudos.empty(a) }, header: function (a) { return Y.test(a.nodeName) }, input: function (a) { return X.test(a.nodeName) }, button: function (a) { var b = a.nodeName.toLowerCase(); return "input" === b && "button" === a.type || "button" === b }, text: function (a) { var b; return "input" === a.nodeName.toLowerCase() && "text" === a.type && (null == (b = a.getAttribute("type")) || "text" === b.toLowerCase()) }, first: na(function () { return [0] }), last: na(function (a, b) { return [b - 1] }), eq: na(function (a, b, c) { return [0 > c ? c + b : c] }), even: na(function (a, b) { for (var c = 0; b > c; c += 2)a.push(c); return a }), odd: na(function (a, b) { for (var c = 1; b > c; c += 2)a.push(c); return a }), lt: na(function (a, b, c) { for (var d = 0 > c ? c + b : c; --d >= 0;)a.push(d); return a }), gt: na(function (a, b, c) { for (var d = 0 > c ? c + b : c; ++d < b;)a.push(d); return a }) } }, d.pseudos.nth = d.pseudos.eq; for (b in { radio: !0, checkbox: !0, file: !0, password: !0, image: !0 }) d.pseudos[b] = la(b); for (b in { submit: !0, reset: !0 }) d.pseudos[b] = ma(b); function pa() { } pa.prototype = d.filters = d.pseudos, d.setFilters = new pa, g = fa.tokenize = function (a, b) { var c, e, f, g, h, i, j, k = z[a + " "]; if (k) return b ? 0 : k.slice(0); h = a, i = [], j = d.preFilter; while (h) { c && !(e = R.exec(h)) || (e && (h = h.slice(e[0].length) || h), i.push(f = [])), c = !1, (e = S.exec(h)) && (c = e.shift(), f.push({ value: c, type: e[0].replace(Q, " ") }), h = h.slice(c.length)); for (g in d.filter) !(e = W[g].exec(h)) || j[g] && !(e = j[g](e)) || (c = e.shift(), f.push({ value: c, type: g, matches: e }), h = h.slice(c.length)); if (!c) break } return b ? h.length : h ? fa.error(a) : z(a, i).slice(0) }; function qa(a) { for (var b = 0, c = a.length, d = ""; c > b; b++)d += a[b].value; return d } function ra(a, b, c) { var d = b.dir, e = c && "parentNode" === d, f = x++; return b.first ? function (b, c, f) { while (b = b[d]) if (1 === b.nodeType || e) return a(b, c, f) } : function (b, c, g) { var h, i, j, k = [w, f]; if (g) { while (b = b[d]) if ((1 === b.nodeType || e) && a(b, c, g)) return !0 } else while (b = b[d]) if (1 === b.nodeType || e) { if (j = b[u] || (b[u] = {}), i = j[b.uniqueID] || (j[b.uniqueID] = {}), (h = i[d]) && h[0] === w && h[1] === f) return k[2] = h[2]; if (i[d] = k, k[2] = a(b, c, g)) return !0 } } } function sa(a) { return a.length > 1 ? function (b, c, d) { var e = a.length; while (e--) if (!a[e](b, c, d)) return !1; return !0 } : a[0] } function ta(a, b, c) { for (var d = 0, e = b.length; e > d; d++)fa(a, b[d], c); return c } function ua(a, b, c, d, e) { for (var f, g = [], h = 0, i = a.length, j = null != b; i > h; h++)(f = a[h]) && (c && !c(f, d, e) || (g.push(f), j && b.push(h))); return g } function va(a, b, c, d, e, f) { return d && !d[u] && (d = va(d)), e && !e[u] && (e = va(e, f)), ha(function (f, g, h, i) { var j, k, l, m = [], n = [], o = g.length, p = f || ta(b || "*", h.nodeType ? [h] : h, []), q = !a || !f && b ? p : ua(p, m, a, h, i), r = c ? e || (f ? a : o || d) ? [] : g : q; if (c && c(q, r, h, i), d) { j = ua(r, n), d(j, [], h, i), k = j.length; while (k--) (l = j[k]) && (r[n[k]] = !(q[n[k]] = l)) } if (f) { if (e || a) { if (e) { j = [], k = r.length; while (k--) (l = r[k]) && j.push(q[k] = l); e(null, r = [], j, i) } k = r.length; while (k--) (l = r[k]) && (j = e ? J(f, l) : m[k]) > -1 && (f[j] = !(g[j] = l)) } } else r = ua(r === g ? r.splice(o, r.length) : r), e ? e(null, g, r, i) : H.apply(g, r) }) } function wa(a) { for (var b, c, e, f = a.length, g = d.relative[a[0].type], h = g || d.relative[" "], i = g ? 1 : 0, k = ra(function (a) { return a === b }, h, !0), l = ra(function (a) { return J(b, a) > -1 }, h, !0), m = [function (a, c, d) { var e = !g && (d || c !== j) || ((b = c).nodeType ? k(a, c, d) : l(a, c, d)); return b = null, e }]; f > i; i++)if (c = d.relative[a[i].type]) m = [ra(sa(m), c)]; else { if (c = d.filter[a[i].type].apply(null, a[i].matches), c[u]) { for (e = ++i; f > e; e++)if (d.relative[a[e].type]) break; return va(i > 1 && sa(m), i > 1 && qa(a.slice(0, i - 1).concat({ value: " " === a[i - 2].type ? "*" : "" })).replace(Q, "$1"), c, e > i && wa(a.slice(i, e)), f > e && wa(a = a.slice(e)), f > e && qa(a)) } m.push(c) } return sa(m) } function xa(a, b) { var c = b.length > 0, e = a.length > 0, f = function (f, g, h, i, k) { var l, o, q, r = 0, s = "0", t = f && [], u = [], v = j, x = f || e && d.find.TAG("*", k), y = w += null == v ? 1 : Math.random() || .1, z = x.length; for (k && (j = g === n || g || k); s !== z && null != (l = x[s]); s++) { if (e && l) { o = 0, g || l.ownerDocument === n || (m(l), h = !p); while (q = a[o++]) if (q(l, g || n, h)) { i.push(l); break } k && (w = y) } c && ((l = !q && l) && r-- , f && t.push(l)) } if (r += s, c && s !== r) { o = 0; while (q = b[o++]) q(t, u, g, h); if (f) { if (r > 0) while (s--) t[s] || u[s] || (u[s] = F.call(i)); u = ua(u) } H.apply(i, u), k && !f && u.length > 0 && r + b.length > 1 && fa.uniqueSort(i) } return k && (w = y, j = v), t }; return c ? ha(f) : f } return h = fa.compile = function (a, b) { var c, d = [], e = [], f = A[a + " "]; if (!f) { b || (b = g(a)), c = b.length; while (c--) f = wa(b[c]), f[u] ? d.push(f) : e.push(f); f = A(a, xa(e, d)), f.selector = a } return f }, i = fa.select = function (a, b, e, f) { var i, j, k, l, m, n = "function" == typeof a && a, o = !f && g(a = n.selector || a); if (e = e || [], 1 === o.length) { if (j = o[0] = o[0].slice(0), j.length > 2 && "ID" === (k = j[0]).type && c.getById && 9 === b.nodeType && p && d.relative[j[1].type]) { if (b = (d.find.ID(k.matches[0].replace(ba, ca), b) || [])[0], !b) return e; n && (b = b.parentNode), a = a.slice(j.shift().value.length) } i = W.needsContext.test(a) ? 0 : j.length; while (i--) { if (k = j[i], d.relative[l = k.type]) break; if ((m = d.find[l]) && (f = m(k.matches[0].replace(ba, ca), _.test(j[0].type) && oa(b.parentNode) || b))) { if (j.splice(i, 1), a = f.length && qa(j), !a) return H.apply(e, f), e; break } } } return (n || h(a, o))(f, b, !p, e, !b || _.test(a) && oa(b.parentNode) || b), e }, c.sortStable = u.split("").sort(B).join("") === u, c.detectDuplicates = !!l, m(), c.sortDetached = ia(function (a) { return 1 & a.compareDocumentPosition(n.createElement("div")) }), ia(function (a) { return a.innerHTML = "", "#" === a.firstChild.getAttribute("href") }) || ja("type|href|height|width", function (a, b, c) { return c ? void 0 : a.getAttribute(b, "type" === b.toLowerCase() ? 1 : 2) }), c.attributes && ia(function (a) { return a.innerHTML = "", a.firstChild.setAttribute("value", ""), "" === a.firstChild.getAttribute("value") }) || ja("value", function (a, b, c) { return c || "input" !== a.nodeName.toLowerCase() ? void 0 : a.defaultValue }), ia(function (a) { return null == a.getAttribute("disabled") }) || ja(K, function (a, b, c) { var d; return c ? void 0 : a[b] === !0 ? b.toLowerCase() : (d = a.getAttributeNode(b)) && d.specified ? d.value : null }), fa }(a); n.find = t, n.expr = t.selectors, n.expr[":"] = n.expr.pseudos, n.uniqueSort = n.unique = t.uniqueSort, n.text = t.getText, n.isXMLDoc = t.isXML, n.contains = t.contains; var u = function (a, b, c) { var d = [], e = void 0 !== c; while ((a = a[b]) && 9 !== a.nodeType) if (1 === a.nodeType) { if (e && n(a).is(c)) break; d.push(a) } return d }, v = function (a, b) { for (var c = []; a; a = a.nextSibling)1 === a.nodeType && a !== b && c.push(a); return c }, w = n.expr.match.needsContext, x = /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/, y = /^.[^:#\[\.,]*$/; function z(a, b, c) { if (n.isFunction(b)) return n.grep(a, function (a, d) { return !!b.call(a, d, a) !== c }); if (b.nodeType) return n.grep(a, function (a) { return a === b !== c }); if ("string" == typeof b) { if (y.test(b)) return n.filter(b, a, c); b = n.filter(b, a) } return n.grep(a, function (a) { return h.call(b, a) > -1 !== c }) } n.filter = function (a, b, c) { var d = b[0]; return c && (a = ":not(" + a + ")"), 1 === b.length && 1 === d.nodeType ? n.find.matchesSelector(d, a) ? [d] : [] : n.find.matches(a, n.grep(b, function (a) { return 1 === a.nodeType })) }, n.fn.extend({ find: function (a) { var b, c = this.length, d = [], e = this; if ("string" != typeof a) return this.pushStack(n(a).filter(function () { for (b = 0; c > b; b++)if (n.contains(e[b], this)) return !0 })); for (b = 0; c > b; b++)n.find(a, e[b], d); return d = this.pushStack(c > 1 ? n.unique(d) : d), d.selector = this.selector ? this.selector + " " + a : a, d }, filter: function (a) { return this.pushStack(z(this, a || [], !1)) }, not: function (a) { return this.pushStack(z(this, a || [], !0)) }, is: function (a) { return !!z(this, "string" == typeof a && w.test(a) ? n(a) : a || [], !1).length } }); var A, B = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, C = n.fn.init = function (a, b, c) { var e, f; if (!a) return this; if (c = c || A, "string" == typeof a) { if (e = "<" === a[0] && ">" === a[a.length - 1] && a.length >= 3 ? [null, a, null] : B.exec(a), !e || !e[1] && b) return !b || b.jquery ? (b || c).find(a) : this.constructor(b).find(a); if (e[1]) { if (b = b instanceof n ? b[0] : b, n.merge(this, n.parseHTML(e[1], b && b.nodeType ? b.ownerDocument || b : d, !0)), x.test(e[1]) && n.isPlainObject(b)) for (e in b) n.isFunction(this[e]) ? this[e](b[e]) : this.attr(e, b[e]); return this } return f = d.getElementById(e[2]), f && f.parentNode && (this.length = 1, this[0] = f), this.context = d, this.selector = a, this } return a.nodeType ? (this.context = this[0] = a, this.length = 1, this) : n.isFunction(a) ? void 0 !== c.ready ? c.ready(a) : a(n) : (void 0 !== a.selector && (this.selector = a.selector, this.context = a.context), n.makeArray(a, this)) }; C.prototype = n.fn, A = n(d); var D = /^(?:parents|prev(?:Until|All))/, E = { children: !0, contents: !0, next: !0, prev: !0 }; n.fn.extend({ has: function (a) { var b = n(a, this), c = b.length; return this.filter(function () { for (var a = 0; c > a; a++)if (n.contains(this, b[a])) return !0 }) }, closest: function (a, b) { for (var c, d = 0, e = this.length, f = [], g = w.test(a) || "string" != typeof a ? n(a, b || this.context) : 0; e > d; d++)for (c = this[d]; c && c !== b; c = c.parentNode)if (c.nodeType < 11 && (g ? g.index(c) > -1 : 1 === c.nodeType && n.find.matchesSelector(c, a))) { f.push(c); break } return this.pushStack(f.length > 1 ? n.uniqueSort(f) : f) }, index: function (a) { return a ? "string" == typeof a ? h.call(n(a), this[0]) : h.call(this, a.jquery ? a[0] : a) : this[0] && this[0].parentNode ? this.first().prevAll().length : -1 }, add: function (a, b) { return this.pushStack(n.uniqueSort(n.merge(this.get(), n(a, b)))) }, addBack: function (a) { return this.add(null == a ? this.prevObject : this.prevObject.filter(a)) } }); function F(a, b) { while ((a = a[b]) && 1 !== a.nodeType); return a } n.each({ parent: function (a) { var b = a.parentNode; return b && 11 !== b.nodeType ? b : null }, parents: function (a) { return u(a, "parentNode") }, parentsUntil: function (a, b, c) { return u(a, "parentNode", c) }, next: function (a) { return F(a, "nextSibling") }, prev: function (a) { return F(a, "previousSibling") }, nextAll: function (a) { return u(a, "nextSibling") }, prevAll: function (a) { return u(a, "previousSibling") }, nextUntil: function (a, b, c) { return u(a, "nextSibling", c) }, prevUntil: function (a, b, c) { return u(a, "previousSibling", c) }, siblings: function (a) { return v((a.parentNode || {}).firstChild, a) }, children: function (a) { return v(a.firstChild) }, contents: function (a) { return a.contentDocument || n.merge([], a.childNodes) } }, function (a, b) { n.fn[a] = function (c, d) { var e = n.map(this, b, c); return "Until" !== a.slice(-5) && (d = c), d && "string" == typeof d && (e = n.filter(d, e)), this.length > 1 && (E[a] || n.uniqueSort(e), D.test(a) && e.reverse()), this.pushStack(e) } }); var G = /\S+/g; function H(a) { var b = {}; return n.each(a.match(G) || [], function (a, c) { b[c] = !0 }), b } n.Callbacks = function (a) { a = "string" == typeof a ? H(a) : n.extend({}, a); var b, c, d, e, f = [], g = [], h = -1, i = function () { for (e = a.once, d = b = !0; g.length; h = -1) { c = g.shift(); while (++h < f.length) f[h].apply(c[0], c[1]) === !1 && a.stopOnFalse && (h = f.length, c = !1) } a.memory || (c = !1), b = !1, e && (f = c ? [] : "") }, j = { add: function () { return f && (c && !b && (h = f.length - 1, g.push(c)), function d(b) { n.each(b, function (b, c) { n.isFunction(c) ? a.unique && j.has(c) || f.push(c) : c && c.length && "string" !== n.type(c) && d(c) }) }(arguments), c && !b && i()), this }, remove: function () { return n.each(arguments, function (a, b) { var c; while ((c = n.inArray(b, f, c)) > -1) f.splice(c, 1), h >= c && h-- }), this }, has: function (a) { return a ? n.inArray(a, f) > -1 : f.length > 0 }, empty: function () { return f && (f = []), this }, disable: function () { return e = g = [], f = c = "", this }, disabled: function () { return !f }, lock: function () { return e = g = [], c || (f = c = ""), this }, locked: function () { return !!e }, fireWith: function (a, c) { return e || (c = c || [], c = [a, c.slice ? c.slice() : c], g.push(c), b || i()), this }, fire: function () { return j.fireWith(this, arguments), this }, fired: function () { return !!d } }; return j }, n.extend({ Deferred: function (a) { var b = [["resolve", "done", n.Callbacks("once memory"), "resolved"], ["reject", "fail", n.Callbacks("once memory"), "rejected"], ["notify", "progress", n.Callbacks("memory")]], c = "pending", d = { state: function () { return c }, always: function () { return e.done(arguments).fail(arguments), this }, then: function () { var a = arguments; return n.Deferred(function (c) { n.each(b, function (b, f) { var g = n.isFunction(a[b]) && a[b]; e[f[1]](function () { var a = g && g.apply(this, arguments); a && n.isFunction(a.promise) ? a.promise().progress(c.notify).done(c.resolve).fail(c.reject) : c[f[0] + "With"](this === d ? c.promise() : this, g ? [a] : arguments) }) }), a = null }).promise() }, promise: function (a) { return null != a ? n.extend(a, d) : d } }, e = {}; return d.pipe = d.then, n.each(b, function (a, f) { var g = f[2], h = f[3]; d[f[1]] = g.add, h && g.add(function () { c = h }, b[1 ^ a][2].disable, b[2][2].lock), e[f[0]] = function () { return e[f[0] + "With"](this === e ? d : this, arguments), this }, e[f[0] + "With"] = g.fireWith }), d.promise(e), a && a.call(e, e), e }, when: function (a) { var b = 0, c = e.call(arguments), d = c.length, f = 1 !== d || a && n.isFunction(a.promise) ? d : 0, g = 1 === f ? a : n.Deferred(), h = function (a, b, c) { return function (d) { b[a] = this, c[a] = arguments.length > 1 ? e.call(arguments) : d, c === i ? g.notifyWith(b, c) : --f || g.resolveWith(b, c) } }, i, j, k; if (d > 1) for (i = new Array(d), j = new Array(d), k = new Array(d); d > b; b++)c[b] && n.isFunction(c[b].promise) ? c[b].promise().progress(h(b, j, i)).done(h(b, k, c)).fail(g.reject) : --f; return f || g.resolveWith(k, c), g.promise() } }); var I; n.fn.ready = function (a) { return n.ready.promise().done(a), this }, n.extend({ isReady: !1, readyWait: 1, holdReady: function (a) { a ? n.readyWait++ : n.ready(!0) }, ready: function (a) { (a === !0 ? --n.readyWait : n.isReady) || (n.isReady = !0, a !== !0 && --n.readyWait > 0 || (I.resolveWith(d, [n]), n.fn.triggerHandler && (n(d).triggerHandler("ready"), n(d).off("ready")))) } }); function J() { d.removeEventListener("DOMContentLoaded", J), a.removeEventListener("load", J), n.ready() } n.ready.promise = function (b) { return I || (I = n.Deferred(), "complete" === d.readyState || "loading" !== d.readyState && !d.documentElement.doScroll ? a.setTimeout(n.ready) : (d.addEventListener("DOMContentLoaded", J), a.addEventListener("load", J))), I.promise(b) }, n.ready.promise(); var K = function (a, b, c, d, e, f, g) { var h = 0, i = a.length, j = null == c; if ("object" === n.type(c)) { e = !0; for (h in c) K(a, b, h, c[h], !0, f, g) } else if (void 0 !== d && (e = !0, n.isFunction(d) || (g = !0), j && (g ? (b.call(a, d), b = null) : (j = b, b = function (a, b, c) { return j.call(n(a), c) })), b)) for (; i > h; h++)b(a[h], c, g ? d : d.call(a[h], h, b(a[h], c))); return e ? a : j ? b.call(a) : i ? b(a[0], c) : f }, L = function (a) { return 1 === a.nodeType || 9 === a.nodeType || !+a.nodeType }; function M() { this.expando = n.expando + M.uid++ } M.uid = 1, M.prototype = { register: function (a, b) { var c = b || {}; return a.nodeType ? a[this.expando] = c : Object.defineProperty(a, this.expando, { value: c, writable: !0, configurable: !0 }), a[this.expando] }, cache: function (a) { if (!L(a)) return {}; var b = a[this.expando]; return b || (b = {}, L(a) && (a.nodeType ? a[this.expando] = b : Object.defineProperty(a, this.expando, { value: b, configurable: !0 }))), b }, set: function (a, b, c) { var d, e = this.cache(a); if ("string" == typeof b) e[b] = c; else for (d in b) e[d] = b[d]; return e }, get: function (a, b) { return void 0 === b ? this.cache(a) : a[this.expando] && a[this.expando][b] }, access: function (a, b, c) { var d; return void 0 === b || b && "string" == typeof b && void 0 === c ? (d = this.get(a, b), void 0 !== d ? d : this.get(a, n.camelCase(b))) : (this.set(a, b, c), void 0 !== c ? c : b) }, remove: function (a, b) { var c, d, e, f = a[this.expando]; if (void 0 !== f) { if (void 0 === b) this.register(a); else { n.isArray(b) ? d = b.concat(b.map(n.camelCase)) : (e = n.camelCase(b), b in f ? d = [b, e] : (d = e, d = d in f ? [d] : d.match(G) || [])), c = d.length; while (c--) delete f[d[c]] } (void 0 === b || n.isEmptyObject(f)) && (a.nodeType ? a[this.expando] = void 0 : delete a[this.expando]) } }, hasData: function (a) { var b = a[this.expando]; return void 0 !== b && !n.isEmptyObject(b) } }; var N = new M, O = new M, P = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, Q = /[A-Z]/g; function R(a, b, c) { var d; if (void 0 === c && 1 === a.nodeType) if (d = "data-" + b.replace(Q, "-$&").toLowerCase(), c = a.getAttribute(d), "string" == typeof c) { try { c = "true" === c ? !0 : "false" === c ? !1 : "null" === c ? null : +c + "" === c ? +c : P.test(c) ? n.parseJSON(c) : c; } catch (e) { } O.set(a, b, c) } else c = void 0; return c } n.extend({ hasData: function (a) { return O.hasData(a) || N.hasData(a) }, data: function (a, b, c) { return O.access(a, b, c) }, removeData: function (a, b) { O.remove(a, b) }, _data: function (a, b, c) { return N.access(a, b, c) }, _removeData: function (a, b) { N.remove(a, b) } }), n.fn.extend({ data: function (a, b) { var c, d, e, f = this[0], g = f && f.attributes; if (void 0 === a) { if (this.length && (e = O.get(f), 1 === f.nodeType && !N.get(f, "hasDataAttrs"))) { c = g.length; while (c--) g[c] && (d = g[c].name, 0 === d.indexOf("data-") && (d = n.camelCase(d.slice(5)), R(f, d, e[d]))); N.set(f, "hasDataAttrs", !0) } return e } return "object" == typeof a ? this.each(function () { O.set(this, a) }) : K(this, function (b) { var c, d; if (f && void 0 === b) { if (c = O.get(f, a) || O.get(f, a.replace(Q, "-$&").toLowerCase()), void 0 !== c) return c; if (d = n.camelCase(a), c = O.get(f, d), void 0 !== c) return c; if (c = R(f, d, void 0), void 0 !== c) return c } else d = n.camelCase(a), this.each(function () { var c = O.get(this, d); O.set(this, d, b), a.indexOf("-") > -1 && void 0 !== c && O.set(this, a, b) }) }, null, b, arguments.length > 1, null, !0) }, removeData: function (a) { return this.each(function () { O.remove(this, a) }) } }), n.extend({ queue: function (a, b, c) { var d; return a ? (b = (b || "fx") + "queue", d = N.get(a, b), c && (!d || n.isArray(c) ? d = N.access(a, b, n.makeArray(c)) : d.push(c)), d || []) : void 0 }, dequeue: function (a, b) { b = b || "fx"; var c = n.queue(a, b), d = c.length, e = c.shift(), f = n._queueHooks(a, b), g = function () { n.dequeue(a, b) }; "inprogress" === e && (e = c.shift(), d--), e && ("fx" === b && c.unshift("inprogress"), delete f.stop, e.call(a, g, f)), !d && f && f.empty.fire() }, _queueHooks: function (a, b) { var c = b + "queueHooks"; return N.get(a, c) || N.access(a, c, { empty: n.Callbacks("once memory").add(function () { N.remove(a, [b + "queue", c]) }) }) } }), n.fn.extend({ queue: function (a, b) { var c = 2; return "string" != typeof a && (b = a, a = "fx", c--), arguments.length < c ? n.queue(this[0], a) : void 0 === b ? this : this.each(function () { var c = n.queue(this, a, b); n._queueHooks(this, a), "fx" === a && "inprogress" !== c[0] && n.dequeue(this, a) }) }, dequeue: function (a) { return this.each(function () { n.dequeue(this, a) }) }, clearQueue: function (a) { return this.queue(a || "fx", []) }, promise: function (a, b) { var c, d = 1, e = n.Deferred(), f = this, g = this.length, h = function () { --d || e.resolveWith(f, [f]) }; "string" != typeof a && (b = a, a = void 0), a = a || "fx"; while (g--) c = N.get(f[g], a + "queueHooks"), c && c.empty && (d++ , c.empty.add(h)); return h(), e.promise(b) } }); var S = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source, T = new RegExp("^(?:([+-])=|)(" + S + ")([a-z%]*)$", "i"), U = ["Top", "Right", "Bottom", "Left"], V = function (a, b) { return a = b || a, "none" === n.css(a, "display") || !n.contains(a.ownerDocument, a) }; function W(a, b, c, d) { var e, f = 1, g = 20, h = d ? function () { return d.cur() } : function () { return n.css(a, b, "") }, i = h(), j = c && c[3] || (n.cssNumber[b] ? "" : "px"), k = (n.cssNumber[b] || "px" !== j && +i) && T.exec(n.css(a, b)); if (k && k[3] !== j) { j = j || k[3], c = c || [], k = +i || 1; do f = f || ".5", k /= f, n.style(a, b, k + j); while (f !== (f = h() / i) && 1 !== f && --g) } return c && (k = +k || +i || 0, e = c[1] ? k + (c[1] + 1) * c[2] : +c[2], d && (d.unit = j, d.start = k, d.end = e)), e } var X = /^(?:checkbox|radio)$/i, Y = /<([\w:-]+)/, Z = /^$|\/(?:java|ecma)script/i, $ = { option: [1, ""], thead: [1, "", "
"], col: [2, "", "
"], tr: [2, "", "
"], td: [3, "", "
"], _default: [0, "", ""] }; $.optgroup = $.option, $.tbody = $.tfoot = $.colgroup = $.caption = $.thead, $.th = $.td; function _(a, b) { var c = "undefined" != typeof a.getElementsByTagName ? a.getElementsByTagName(b || "*") : "undefined" != typeof a.querySelectorAll ? a.querySelectorAll(b || "*") : []; return void 0 === b || b && n.nodeName(a, b) ? n.merge([a], c) : c } function aa(a, b) { for (var c = 0, d = a.length; d > c; c++)N.set(a[c], "globalEval", !b || N.get(b[c], "globalEval")) } var ba = /<|&#?\w+;/; function ca(a, b, c, d, e) { for (var f, g, h, i, j, k, l = b.createDocumentFragment(), m = [], o = 0, p = a.length; p > o; o++)if (f = a[o], f || 0 === f) if ("object" === n.type(f)) n.merge(m, f.nodeType ? [f] : f); else if (ba.test(f)) { g = g || l.appendChild(b.createElement("div")), h = (Y.exec(f) || ["", ""])[1].toLowerCase(), i = $[h] || $._default, g.innerHTML = i[1] + n.htmlPrefilter(f) + i[2], k = i[0]; while (k--) g = g.lastChild; n.merge(m, g.childNodes), g = l.firstChild, g.textContent = "" } else m.push(b.createTextNode(f)); l.textContent = "", o = 0; while (f = m[o++]) if (d && n.inArray(f, d) > -1) e && e.push(f); else if (j = n.contains(f.ownerDocument, f), g = _(l.appendChild(f), "script"), j && aa(g), c) { k = 0; while (f = g[k++]) Z.test(f.type || "") && c.push(f) } return l } !function () { var a = d.createDocumentFragment(), b = a.appendChild(d.createElement("div")), c = d.createElement("input"); c.setAttribute("type", "radio"), c.setAttribute("checked", "checked"), c.setAttribute("name", "t"), b.appendChild(c), l.checkClone = b.cloneNode(!0).cloneNode(!0).lastChild.checked, b.innerHTML = "", l.noCloneChecked = !!b.cloneNode(!0).lastChild.defaultValue }(); var da = /^key/, ea = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, fa = /^([^.]*)(?:\.(.+)|)/; function ga() { return !0 } function ha() { return !1 } function ia() { try { return d.activeElement } catch (a) { } } function ja(a, b, c, d, e, f) { var g, h; if ("object" == typeof b) { "string" != typeof c && (d = d || c, c = void 0); for (h in b) ja(a, h, c, d, b[h], f); return a } if (null == d && null == e ? (e = c, d = c = void 0) : null == e && ("string" == typeof c ? (e = d, d = void 0) : (e = d, d = c, c = void 0)), e === !1) e = ha; else if (!e) return a; return 1 === f && (g = e, e = function (a) { return n().off(a), g.apply(this, arguments) }, e.guid = g.guid || (g.guid = n.guid++)), a.each(function () { n.event.add(this, b, e, d, c) }) } n.event = { global: {}, add: function (a, b, c, d, e) { var f, g, h, i, j, k, l, m, o, p, q, r = N.get(a); if (r) { c.handler && (f = c, c = f.handler, e = f.selector), c.guid || (c.guid = n.guid++), (i = r.events) || (i = r.events = {}), (g = r.handle) || (g = r.handle = function (b) { return "undefined" != typeof n && n.event.triggered !== b.type ? n.event.dispatch.apply(a, arguments) : void 0 }), b = (b || "").match(G) || [""], j = b.length; while (j--) h = fa.exec(b[j]) || [], o = q = h[1], p = (h[2] || "").split(".").sort(), o && (l = n.event.special[o] || {}, o = (e ? l.delegateType : l.bindType) || o, l = n.event.special[o] || {}, k = n.extend({ type: o, origType: q, data: d, handler: c, guid: c.guid, selector: e, needsContext: e && n.expr.match.needsContext.test(e), namespace: p.join(".") }, f), (m = i[o]) || (m = i[o] = [], m.delegateCount = 0, l.setup && l.setup.call(a, d, p, g) !== !1 || a.addEventListener && a.addEventListener(o, g)), l.add && (l.add.call(a, k), k.handler.guid || (k.handler.guid = c.guid)), e ? m.splice(m.delegateCount++, 0, k) : m.push(k), n.event.global[o] = !0) } }, remove: function (a, b, c, d, e) { var f, g, h, i, j, k, l, m, o, p, q, r = N.hasData(a) && N.get(a); if (r && (i = r.events)) { b = (b || "").match(G) || [""], j = b.length; while (j--) if (h = fa.exec(b[j]) || [], o = q = h[1], p = (h[2] || "").split(".").sort(), o) { l = n.event.special[o] || {}, o = (d ? l.delegateType : l.bindType) || o, m = i[o] || [], h = h[2] && new RegExp("(^|\\.)" + p.join("\\.(?:.*\\.|)") + "(\\.|$)"), g = f = m.length; while (f--) k = m[f], !e && q !== k.origType || c && c.guid !== k.guid || h && !h.test(k.namespace) || d && d !== k.selector && ("**" !== d || !k.selector) || (m.splice(f, 1), k.selector && m.delegateCount-- , l.remove && l.remove.call(a, k)); g && !m.length && (l.teardown && l.teardown.call(a, p, r.handle) !== !1 || n.removeEvent(a, o, r.handle), delete i[o]) } else for (o in i) n.event.remove(a, o + b[j], c, d, !0); n.isEmptyObject(i) && N.remove(a, "handle events") } }, dispatch: function (a) { a = n.event.fix(a); var b, c, d, f, g, h = [], i = e.call(arguments), j = (N.get(this, "events") || {})[a.type] || [], k = n.event.special[a.type] || {}; if (i[0] = a, a.delegateTarget = this, !k.preDispatch || k.preDispatch.call(this, a) !== !1) { h = n.event.handlers.call(this, a, j), b = 0; while ((f = h[b++]) && !a.isPropagationStopped()) { a.currentTarget = f.elem, c = 0; while ((g = f.handlers[c++]) && !a.isImmediatePropagationStopped()) a.rnamespace && !a.rnamespace.test(g.namespace) || (a.handleObj = g, a.data = g.data, d = ((n.event.special[g.origType] || {}).handle || g.handler).apply(f.elem, i), void 0 !== d && (a.result = d) === !1 && (a.preventDefault(), a.stopPropagation())) } return k.postDispatch && k.postDispatch.call(this, a), a.result } }, handlers: function (a, b) { var c, d, e, f, g = [], h = b.delegateCount, i = a.target; if (h && i.nodeType && ("click" !== a.type || isNaN(a.button) || a.button < 1)) for (; i !== this; i = i.parentNode || this)if (1 === i.nodeType && (i.disabled !== !0 || "click" !== a.type)) { for (d = [], c = 0; h > c; c++)f = b[c], e = f.selector + " ", void 0 === d[e] && (d[e] = f.needsContext ? n(e, this).index(i) > -1 : n.find(e, this, null, [i]).length), d[e] && d.push(f); d.length && g.push({ elem: i, handlers: d }) } return h < b.length && g.push({ elem: this, handlers: b.slice(h) }), g }, props: "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), fixHooks: {}, keyHooks: { props: "char charCode key keyCode".split(" "), filter: function (a, b) { return null == a.which && (a.which = null != b.charCode ? b.charCode : b.keyCode), a } }, mouseHooks: { props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "), filter: function (a, b) { var c, e, f, g = b.button; return null == a.pageX && null != b.clientX && (c = a.target.ownerDocument || d, e = c.documentElement, f = c.body, a.pageX = b.clientX + (e && e.scrollLeft || f && f.scrollLeft || 0) - (e && e.clientLeft || f && f.clientLeft || 0), a.pageY = b.clientY + (e && e.scrollTop || f && f.scrollTop || 0) - (e && e.clientTop || f && f.clientTop || 0)), a.which || void 0 === g || (a.which = 1 & g ? 1 : 2 & g ? 3 : 4 & g ? 2 : 0), a } }, fix: function (a) { if (a[n.expando]) return a; var b, c, e, f = a.type, g = a, h = this.fixHooks[f]; h || (this.fixHooks[f] = h = ea.test(f) ? this.mouseHooks : da.test(f) ? this.keyHooks : {}), e = h.props ? this.props.concat(h.props) : this.props, a = new n.Event(g), b = e.length; while (b--) c = e[b], a[c] = g[c]; return a.target || (a.target = d), 3 === a.target.nodeType && (a.target = a.target.parentNode), h.filter ? h.filter(a, g) : a }, special: { load: { noBubble: !0 }, focus: { trigger: function () { return this !== ia() && this.focus ? (this.focus(), !1) : void 0 }, delegateType: "focusin" }, blur: { trigger: function () { return this === ia() && this.blur ? (this.blur(), !1) : void 0 }, delegateType: "focusout" }, click: { trigger: function () { return "checkbox" === this.type && this.click && n.nodeName(this, "input") ? (this.click(), !1) : void 0 }, _default: function (a) { return n.nodeName(a.target, "a") } }, beforeunload: { postDispatch: function (a) { void 0 !== a.result && a.originalEvent && (a.originalEvent.returnValue = a.result) } } } }, n.removeEvent = function (a, b, c) { a.removeEventListener && a.removeEventListener(b, c) }, n.Event = function (a, b) { return this instanceof n.Event ? (a && a.type ? (this.originalEvent = a, this.type = a.type, this.isDefaultPrevented = a.defaultPrevented || void 0 === a.defaultPrevented && a.returnValue === !1 ? ga : ha) : this.type = a, b && n.extend(this, b), this.timeStamp = a && a.timeStamp || n.now(), void (this[n.expando] = !0)) : new n.Event(a, b) }, n.Event.prototype = { constructor: n.Event, isDefaultPrevented: ha, isPropagationStopped: ha, isImmediatePropagationStopped: ha, isSimulated: !1, preventDefault: function () { var a = this.originalEvent; this.isDefaultPrevented = ga, a && !this.isSimulated && a.preventDefault() }, stopPropagation: function () { var a = this.originalEvent; this.isPropagationStopped = ga, a && !this.isSimulated && a.stopPropagation() }, stopImmediatePropagation: function () { var a = this.originalEvent; this.isImmediatePropagationStopped = ga, a && !this.isSimulated && a.stopImmediatePropagation(), this.stopPropagation() } }, n.each({ mouseenter: "mouseover", mouseleave: "mouseout", pointerenter: "pointerover", pointerleave: "pointerout" }, function (a, b) { n.event.special[a] = { delegateType: b, bindType: b, handle: function (a) { var c, d = this, e = a.relatedTarget, f = a.handleObj; return e && (e === d || n.contains(d, e)) || (a.type = f.origType, c = f.handler.apply(this, arguments), a.type = b), c } } }), n.fn.extend({ on: function (a, b, c, d) { return ja(this, a, b, c, d) }, one: function (a, b, c, d) { return ja(this, a, b, c, d, 1) }, off: function (a, b, c) { var d, e; if (a && a.preventDefault && a.handleObj) return d = a.handleObj, n(a.delegateTarget).off(d.namespace ? d.origType + "." + d.namespace : d.origType, d.selector, d.handler), this; if ("object" == typeof a) { for (e in a) this.off(e, b, a[e]); return this } return b !== !1 && "function" != typeof b || (c = b, b = void 0), c === !1 && (c = ha), this.each(function () { n.event.remove(this, a, c, b) }) } }); var ka = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi, la = /\s*$/g; function pa(a, b) { return n.nodeName(a, "table") && n.nodeName(11 !== b.nodeType ? b : b.firstChild, "tr") ? a.getElementsByTagName("tbody")[0] || a.appendChild(a.ownerDocument.createElement("tbody")) : a } function qa(a) { return a.type = (null !== a.getAttribute("type")) + "/" + a.type, a } function ra(a) { var b = na.exec(a.type); return b ? a.type = b[1] : a.removeAttribute("type"), a } function sa(a, b) { var c, d, e, f, g, h, i, j; if (1 === b.nodeType) { if (N.hasData(a) && (f = N.access(a), g = N.set(b, f), j = f.events)) { delete g.handle, g.events = {}; for (e in j) for (c = 0, d = j[e].length; d > c; c++)n.event.add(b, e, j[e][c]) } O.hasData(a) && (h = O.access(a), i = n.extend({}, h), O.set(b, i)) } } function ta(a, b) { var c = b.nodeName.toLowerCase(); "input" === c && X.test(a.type) ? b.checked = a.checked : "input" !== c && "textarea" !== c || (b.defaultValue = a.defaultValue) } function ua(a, b, c, d) { b = f.apply([], b); var e, g, h, i, j, k, m = 0, o = a.length, p = o - 1, q = b[0], r = n.isFunction(q); if (r || o > 1 && "string" == typeof q && !l.checkClone && ma.test(q)) return a.each(function (e) { var f = a.eq(e); r && (b[0] = q.call(this, e, f.html())), ua(f, b, c, d) }); if (o && (e = ca(b, a[0].ownerDocument, !1, a, d), g = e.firstChild, 1 === e.childNodes.length && (e = g), g || d)) { for (h = n.map(_(e, "script"), qa), i = h.length; o > m; m++)j = e, m !== p && (j = n.clone(j, !0, !0), i && n.merge(h, _(j, "script"))), c.call(a[m], j, m); if (i) for (k = h[h.length - 1].ownerDocument, n.map(h, ra), m = 0; i > m; m++)j = h[m], Z.test(j.type || "") && !N.access(j, "globalEval") && n.contains(k, j) && (j.src ? n._evalUrl && n._evalUrl(j.src) : n.globalEval(j.textContent.replace(oa, ""))) } return a } function va(a, b, c) { for (var d, e = b ? n.filter(b, a) : a, f = 0; null != (d = e[f]); f++)c || 1 !== d.nodeType || n.cleanData(_(d)), d.parentNode && (c && n.contains(d.ownerDocument, d) && aa(_(d, "script")), d.parentNode.removeChild(d)); return a } n.extend({ htmlPrefilter: function (a) { return a.replace(ka, "<$1>") }, clone: function (a, b, c) { var d, e, f, g, h = a.cloneNode(!0), i = n.contains(a.ownerDocument, a); if (!(l.noCloneChecked || 1 !== a.nodeType && 11 !== a.nodeType || n.isXMLDoc(a))) for (g = _(h), f = _(a), d = 0, e = f.length; e > d; d++)ta(f[d], g[d]); if (b) if (c) for (f = f || _(a), g = g || _(h), d = 0, e = f.length; e > d; d++)sa(f[d], g[d]); else sa(a, h); return g = _(h, "script"), g.length > 0 && aa(g, !i && _(a, "script")), h }, cleanData: function (a) { for (var b, c, d, e = n.event.special, f = 0; void 0 !== (c = a[f]); f++)if (L(c)) { if (b = c[N.expando]) { if (b.events) for (d in b.events) e[d] ? n.event.remove(c, d) : n.removeEvent(c, d, b.handle); c[N.expando] = void 0 } c[O.expando] && (c[O.expando] = void 0) } } }), n.fn.extend({ domManip: ua, detach: function (a) { return va(this, a, !0) }, remove: function (a) { return va(this, a) }, text: function (a) { return K(this, function (a) { return void 0 === a ? n.text(this) : this.empty().each(function () { 1 !== this.nodeType && 11 !== this.nodeType && 9 !== this.nodeType || (this.textContent = a) }) }, null, a, arguments.length) }, append: function () { return ua(this, arguments, function (a) { if (1 === this.nodeType || 11 === this.nodeType || 9 === this.nodeType) { var b = pa(this, a); b.appendChild(a) } }) }, prepend: function () { return ua(this, arguments, function (a) { if (1 === this.nodeType || 11 === this.nodeType || 9 === this.nodeType) { var b = pa(this, a); b.insertBefore(a, b.firstChild) } }) }, before: function () { return ua(this, arguments, function (a) { this.parentNode && this.parentNode.insertBefore(a, this) }) }, after: function () { return ua(this, arguments, function (a) { this.parentNode && this.parentNode.insertBefore(a, this.nextSibling) }) }, empty: function () { for (var a, b = 0; null != (a = this[b]); b++)1 === a.nodeType && (n.cleanData(_(a, !1)), a.textContent = ""); return this }, clone: function (a, b) { return a = null == a ? !1 : a, b = null == b ? a : b, this.map(function () { return n.clone(this, a, b) }) }, html: function (a) { return K(this, function (a) { var b = this[0] || {}, c = 0, d = this.length; if (void 0 === a && 1 === b.nodeType) return b.innerHTML; if ("string" == typeof a && !la.test(a) && !$[(Y.exec(a) || ["", ""])[1].toLowerCase()]) { a = n.htmlPrefilter(a); try { for (; d > c; c++)b = this[c] || {}, 1 === b.nodeType && (n.cleanData(_(b, !1)), b.innerHTML = a); b = 0 } catch (e) { } } b && this.empty().append(a) }, null, a, arguments.length) }, replaceWith: function () { var a = []; return ua(this, arguments, function (b) { var c = this.parentNode; n.inArray(this, a) < 0 && (n.cleanData(_(this)), c && c.replaceChild(b, this)) }, a) } }), n.each({ appendTo: "append", prependTo: "prepend", insertBefore: "before", insertAfter: "after", replaceAll: "replaceWith" }, function (a, b) { n.fn[a] = function (a) { for (var c, d = [], e = n(a), f = e.length - 1, h = 0; f >= h; h++)c = h === f ? this : this.clone(!0), n(e[h])[b](c), g.apply(d, c.get()); return this.pushStack(d) } }); var wa, xa = { HTML: "block", BODY: "block" }; function ya(a, b) { var c = n(b.createElement(a)).appendTo(b.body), d = n.css(c[0], "display"); return c.detach(), d } function za(a) { var b = d, c = xa[a]; return c || (c = ya(a, b), "none" !== c && c || (wa = (wa || n("", link: linkFunction }; function linkFunction(scope, element, attrs) { element.bind('click', function () { scope.showExport = false; scope.$digest(); $timeout(function () { scope.showExport = true; }, 200); }); } return directive; } angular.module('bizPart').directive('bizValidation', bizValidation); bizValidation.$inject = ["bizCoreService"] function bizValidation(bizCoreService) { var validationKeys = [{ Key: "TEST", Name: "Test validator", Regex: "test", Flags: "i", Message: "This is some testing validation" }]; var validationKeyRequest = null; var directive = { restrict: "A", require: "ngModel", link: linkFunction }; function linkFunction(scope, element, attrs, ngModel) { var validationKey = attrs.bizValidation; if (!validationKeys.length) GetValidationKeys(); var validator = validationKeys.GetItemByValue("Key", validationKey); ngModel.$validators.bizValidation = function (modelValue) { if (!modelValue || !validator) return false; var regex = new RegExp(validator.Regex, validator.Flags); return !!modelValue.match(regex); }; function GetValidationKeys() { if (!validationKeyRequest) validationKeyRequest = bizCoreService.GetPortalsetting("FIELD_VALIDATORS"); validationKeyRequest.then(GetPortalsettingCallback); function GetPortalsettingCallback(response) { var result = BizPartCoreHelpers.getResponseValue(response, "[]"); validationKeys = JSON.parse(result); validator = validationKeys.GetItemByValue("Key", validationKey); //TODO: Somehow add the "Message" to the form control } } } return directive; } angular.module('bizPart').directive('bizOverflowClass', bizOverflowClass); bizOverflowClass.$inject = ["$timeout"]; function bizOverflowClass($timeout) { var directive = { restrict: "A", link: linkFunction }; function linkFunction(scope, elem, attrs) { var contentsWidth = 0; $timeout(function () { elem.children().each(function () { contentsWidth += $(this).outerWidth(true); }); checkOverflow(); }); $(window).resize(checkOverflow); function checkOverflow() { var elemWidth = elem.width(); if (contentsWidth > elemWidth) elem.addClass(attrs.bizOverflowClass); else elem.removeClass(attrs.bizOverflowClass); } } return directive; } angular.module('bizPart').directive('bizHeightClass', bizHeightClass); bizHeightClass.$inject = ["$timeout"]; function bizHeightClass($timeout) { var directive = { restrict: "A", scope: { heightLt: "=", heightGt: "=" }, link: linkFunction }; function linkFunction(scope, elem, attrs) { var timeout = null; $timeout(checkHeight); $(window).resize(function () { if (timeout) $timeout.cancel(timeout); timeout = $timeout(checkHeight, 250); }); function checkHeight() { var elemHeight = elem.height(); if (scope.heightLt) angular.forEach(scope.heightLt, checkLt); if (scope.heightGt) angular.forEach(scope.heightGt, checkGt); function checkLt(height, cssClass) { if (elemHeight < height) { elem.addClass(cssClass); } else { elem.removeClass(cssClass); } } function checkGt(height, cssClass) { if (elemHeight > height) { elem.addClass(cssClass); } else { elem.removeClass(cssClass); } } } } return directive; } angular.module('bizPart').directive('bizRecompile', bizRecompile); bizRecompile.$inject = ["$timeout"]; function bizRecompile($timeout) { var directive = { restrict: "AE", transclude: true, scope: { watch: "=" }, template: "
", link: linkFunction }; function linkFunction(scope, element, attrs) { scope.$watchCollection('watch', debounce(reload, 100)); function reload() { scope.Render = false; $timeout(function () { scope.Render = true; }) } } return directive; } angular.module('bizPart').directive('bizMatch', bizMatch); function bizMatch() { var directive = { restrict: "A", require: "ngModel", scope: { "otherModelValue": "=bizMatch" }, link: linkFunction, }; function linkFunction(scope, element, attrs, ngModel) { ngModel.$validators.match = function (modelValue) { return attrs.bizMatchDisabled === "true" || modelValue === scope.otherModelValue; }; scope.$watch("otherModelValue", function () { ngModel.$validate(); }); scope.$watch(function () { return attrs.bizMatchDisabled; }, function () { ngModel.$validate(); }) } return directive; } angular.module('bizPart').directive('bizMaxlength', bizMaxlengthDirective); bizMaxlengthDirective.$inject = []; function bizMaxlengthDirective() { var directive = { restrict: "A", link: bizMaxlengthLink }; function bizMaxlengthLink(scope, elem, attr) { } return directive; } angular.module('bizPart').directive('bizSelected', bizSelectedDirective); function bizSelectedDirective() { var directive = { restrict: "A", require: "select", link: bizSelectedLink }; function bizSelectedLink(scope, elem, attrs, ngModel) { attrs.$observe('ngModel', function (value) { scope.$watch(value, function (newValue) { if (newValue) { var options = elem.find("option"); for (var i = 0; i < options.length; i++) { var option = $(options[i]) if (option.val() == newValue.$$hashKey) option.addClass("selected"); else option.removeClass("selected"); } } }) }); } return directive; } angular.module('bizPart').directive('bizPlaceholders', bizPlaceholdersDirective); bizPlaceholdersDirective.$inject = []; function bizPlaceholdersDirective() { var directive = { restrict: "A", controller: bizPlaceholdersController }; bizPlaceholdersController.$inject = ["$scope", "$element", "$compile", "$rootScope"]; function bizPlaceholdersController($scope, $element, $compile, $rootScope) { var urlPattern = /(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/gi; var handleHtmlWatch = $scope.$watch(function () { return $element.html(); }, function (newVal, oldVal) { if (newVal != oldVal && newVal) { var newHtml = HandleHtml(newVal); $element.html(newHtml); } }); function HandleHtml(html) { //var newHtml = html.replace(urlPattern, '$&'); //This causes infinite recursion var newHtml = html; var newHtml = newHtml.replace(/##ICON-(.*?)-ICON##/gmi, ''); var newHtml = newHtml.replace(/##ICON-(.*?)##/gmi, ''); var newHtml = newHtml.replace(/##B-(.*?)-B##/gmi, '$1'); var newHtml = newHtml.replace(/##B-(.*?)##/gmi, '$1'); var newHtml = newHtml.replace(/##I-(.*?)##/gmi, '$1'); var newHtml = newHtml.replace(/##C(.*?)-(.*?)##/gmi, '$2'); var newHtml = newHtml.replace(/##LINK\$(.*?)\$(.*?)##(.*?)##LINK##/gmi, '$3'); var newHtml = newHtml.replace(/\r?\n/g, '
'); //var newHtml = newHtml.replace(/##TITLE##/gmi, 'Blogtitle'); //Header tags (SEO) var newHtml = newHtml.replace(/##H1-(.*?)-H1##/gmi, '

$1

'); var newHtml = newHtml.replace(/##H2-(.*?)-H2##/gmi, '

$1

'); var newHtml = newHtml.replace(/##H3-(.*?)-H3##/gmi, '

$1

'); var newHtml = newHtml.replace(/##H4-(.*?)-H4##/gmi, '

$1

'); var newHtml = newHtml.replace(/##H5-(.*?)-H5##/gmi, '
$1
'); var newHtml = newHtml.replace(/##H6-(.*?)-H6##/gmi, '
$1
'); if ($rootScope.LoggedInUser && $rootScope.LoggedInUser.Id > 0) { var newHtml = newHtml.replace(/##EXPERIENCE##/gmi, $rootScope.LoggedInUser.DefaultExperiencePoints); var newHtml = newHtml.replace(/##FULLNAME##/gmi, $rootScope.LoggedInUser.FullName); var newHtml = newHtml.replace(/##FIRSTNAME##/gmi, $rootScope.LoggedInUser.FirstName); var newHtml = newHtml.replace(/##LASTNAME##/gmi, $rootScope.LoggedInUser.LastName); if ($rootScope.LoggedInUser.DefaultLevel) { var newHtml = newHtml.replace(/##LEVEL##/gmi, $rootScope.LoggedInUser.DefaultLevel.Id); } } return newHtml; } } return directive; } angular.module('bizPart').directive('bizPlaceholdersEdit', bizPlaceholdersEditDirective); bizPlaceholdersEditDirective.$inject = ["$compile"]; function bizPlaceholdersEditDirective($compile) { var directive = { restrict: "A", link: bizPlaceholdersEditLink, controller: bizPlaceholdersEditController } function bizPlaceholdersEditLink(scope, elem) { var html = "" + "
" + "Experience" + "Full name" + "First name" + "Last name" + "Level" + "H1" + "H2" + "Bold" + "
"; elem.wrap('
'); elem.parent().append($compile(html)(scope)); //"Title" + } bizPlaceholdersEditController.$inject = ["$rootScope", "$scope", "$element"]; function bizPlaceholdersEditController($rootScope, $scope, $element) { $scope.AddPlaceholder = AddPlaceholder; $scope.AddMarkdown = AddMarkdown; function AddPlaceholder(placeholder) { var element = $element[0]; if (document.selection) { element.focus(); var sel = document.selection.createRange(); sel.text = placeholder; element.focus(); } else if (element.selectionStart || element.selectionStart === 0) { var startPos = element.selectionStart; var endPos = element.selectionEnd; var scrollTop = element.scrollTop; element.value = element.value.substring(0, startPos) + placeholder + element.value.substring(endPos, element.value.length); element.focus(); element.selectionStart = startPos + placeholder.length; element.selectionEnd = startPos + placeholder.length; element.scrollTop = scrollTop; } else { element.value += placeholder; element.focus(); } $(element).trigger('input'); } function AddMarkdown(markdown) { var markdownEnd = ""; switch (markdown) { case "##ICON-": markdownEnd = "-ICON##"; break; case "##B-": markdownEnd = "-B##"; break; break; case "##H1-": markdownEnd = "-H1##"; break; case "##H2-": markdownEnd = "-H2##"; break; default: markdownEnd = ""; } var element = $element[0]; if (document.selection) { element.focus(); var sel = document.selection.createRange(); sel.text = (markdown + " Text here " + markdownEnd); element.focus(); } else if (element.selectionStart || element.selectionStart === 0) { var startPos = element.selectionStart; var endPos = element.selectionEnd; var scrollTop = element.scrollTop; var selectedVal = element.value.substring(startPos, endPos); element.value = element.value.substring(0, startPos) + markdown + selectedVal + markdownEnd + element.value.substring(endPos, element.value.length); element.focus(); element.selectionStart = startPos + markdown.length; element.selectionEnd = startPos + markdown.length; element.scrollTop = scrollTop; } else { element.value += (markdown + " Text here " + markdownEnd); element.focus(); } $(element).trigger('input'); } } return directive; } angular.module('bizPart').directive('bizTooltip', bizTooltip); function bizTooltip() { var directive = { restrict: "A", link: linkFunction, }; function linkFunction(scope, element, attrs) { var stop = attrs.$observe('bizTooltip', function (value) { element.attr('data-toggle', 'tooltip'); if (value) { element.attr('title', value); element.tooltip(); stop(); }; }); } return directive; } angular.module('bizPart').directive('bizCopyUrl', bizCopyUrl); bizCopyUrl.$inject = ["bizCore"]; function bizCopyUrl(bizCoreProvider) { var directive = { restrict: "E", scope: { url: "=", urlCopyPrefix: "@", disabled: "@?" }, templateUrl: bizCoreProvider.getView('core.directives.bizcopyurl', "Js/AngularModules/BizPart/views/bizCopyUrl.html"), link: function (scope, element) { scope.copyUrl = function () { var input = element.find('input')[0]; var textToCopy = scope.urlCopyPrefix + input.value; navigator.clipboard.writeText(textToCopy).then( () => { console.log('Copying', textToCopy); }, () => { console.error('Error copying to clipboard'); } ); }; }, }; return directive; } angular.module('bizPart').directive('bizHighlight', bizHighlight); function bizHighlight() { var directive = { restrict: "A", scope: { bizHighlight: "@", bizHighlightText: "@", bizHighlightClass: "@?" }, link: linkFunction }; function linkFunction(scope, element, attrs) { scope.$watch(function () { return scope.bizHighlight }, function () { if (!scope.bizHighlightText) return; if (!scope.bizHighlight) { element.html(scope.bizHighlightText); return; } var className = scope.bizHighlightClass || "biz-highlight"; element.html(scope.bizHighlightText.replace(new RegExp(scope.bizHighlight, "gi"), function (match) { return '' + match + ''; })); }); } return directive; } angular.module('bizPart').directive('bizBackground', bizBackground); bizBackground.$inject = ['bizLazyLoadService', '$filter', '$rootScope']; function bizBackground(bizLazyLoadService, $filter, $rootScope) { var directive = { restrict: "A", link: linkFunction, }; function linkFunction(scope, element, attrs) { bizLazyLoadService.OnLazyLoadEnabledChange(function (enabled) { if (enabled) return; // TODO: consider moving size,position, repeat to css for cleaner output attrs.$observe('bizBackground', function (value) { if (value) { const url = value.split(" ").join("%20"); element.css({ 'background-image': `url("${url}")` }); element.css({ 'background-size': attrs.bizBackgroundSize || 'cover' }); element.css({ 'background-position': attrs.bizBackgroundPosition || 'center' }); element.css({ 'background-repeat': attrs.bizBackgroundRepeat || 'no-repeat' }); } else { element.css({ 'background-image': 'none' }); } element.addClass('loaded'); }); }, scope); var imageSrc = attrs.bizBackground; scope.loadBackground = function (changes) { imageSrc = attrs.bizBackground; if (!imageSrc) { scope.elem.style.backgroundImage = 'none'; return; } changes.forEach(function (change) { if (!change.isIntersecting) return; var url = imageSrc.split(" ").join("%20"); var extension = url.substring(url.lastIndexOf(".")); url = url.substring(0, url.lastIndexOf(".")); var scalableExtensions = [".jpg", ".png"]; if (url.toLowerCase().indexOf("mediabank/files") >= 0 && scalableExtensions.indexOf(extension) > -1) { if (change.target.offsetWidth <= 300) { url = url + "_Sm"; } //MOBILE else if (change.target.offsetWidth <= 960) { url = url + "_Mobile"; } //PAD else if (change.target.offsetWidth <= 1280) { url = url + "_Pad"; } } const bgUrl = attrs.bizBackground.split(" ").join("%20"); change.target.style.backgroundImage = `url("${bgUrl}")` change.target.style.backgroundSize = attrs.bizBackgroundSize || 'cover'; change.target.style.backgroundPosition = attrs.bizBackgroundPosition || 'center'; change.target.style.backgroundRepeat = attrs.bizBackgroundRepeat || 'no-repeat'; SetUrlFromMediaLinkObjects(change.target, attrs); change.target.classList.add('loaded'); }); }; attrs.$observe('bizBackground', function (value) { if (!value) { element.css({ 'background-image': 'none' }); return; } if ('IntersectionObserver' in window && 'IntersectionObserverEntry' in window && 'intersectionRatio' in window.IntersectionObserverEntry.prototype) { scope.observer = new IntersectionObserver(scope.loadBackground); scope.elem = angular.element(element)[0]; scope.observer.observe(scope.elem); } else { const url = value.split(" ").join("%20"); element.css({ 'background-image': `url("${url}")` }); element.css({ 'background-size': attrs.bizBackgroundSize || 'cover' }); element.css({ 'background-position': attrs.bizBackgroundPosition || 'center' }); element.css({ 'background-repeat': attrs.bizBackgroundRepeat || 'no-repeat' }); } }); function SetUrlFromMediaLinkObjects(element, attrs) { const mediaLinkId = parseInt(attrs.bizBackgroundMediaLinkId); if (mediaLinkId > 0) { const mediaLinkObjects = JSON.parse(getLocalStorage('MediaObjectLinks')); let file = mediaLinkObjects?.find(x => x.ObjectId === mediaLinkId)?.MediaBankFile; if (!file) return; if (typeof CustomHandleBizBackgroundUrlFn === 'function') { fileUrl = CustomHandleBizBackgroundUrlFn(file, attrs?.bizBgWidth, attrs?.bizBgHeight, attrs?.bizBgTransform); } else fileUrl = $filter('siteroot')(fileUrl); if (typeof element.css === 'function') element.css({ 'background-image': `url("${fileUrl}")` }); else element.style.backgroundImage = `url("${fileUrl}")`; } } var unbind = $rootScope.$on('mediaLinkObjectLoaded', function (e, data) { if (parseInt(attrs.bizBackgroundMediaLinkId) > 0) { SetUrlFromMediaLinkObjects(element, attrs); } }); scope.$on('$destroy', unbind); } return directive; } angular.module('bizPart').directive('bizBackgroundSquare', bizBackgroundSquare); function bizBackgroundSquare() { var directive = { restrict: "A", link: linkFunction, }; function linkFunction(scope, element, attrs) { var stop = attrs.$observe('bizBackgroundSquare', function (value) { if (value) { element.css({ 'background-image': 'url(' + value.split(" ").join("%20") + ')' }); element.css({ 'background-size': 'contain' }); element.css({ 'background-position': 'center' }); element.css({ 'background-repeat': 'no-repeat' }); element.css({ 'padding-top': '100%' }); stop(); }; }); } return directive; } angular.module('bizPart').directive('bizPhrase', bizPhraseDirective); bizPhraseDirective.$inject = ["$translate", "bizPhraseLogService", "$rootScope"]; function bizPhraseDirective($translate, bizPhraseLogService, $rootScope) { var directive = { restrict: "A", scope: { bizPhrase: "@", bizPhrasePlaceholders: "=", bizPhraseEditable: "@", }, link: linkFunction }; function linkFunction(scope, element, attrs) { $translate(scope.bizPhrase).then(function (translation) { var text = translation.toString(); if (!bizPhraseLogService.Phrases.GetItemByValue('Key', attrs.bizPhrase)) { bizPhraseLogService.LogPhrase(attrs.bizPhrase, text, $translate.use()); bizPhraseLogService.Phrases.push({ Key: attrs.bizPhrase }); } if (scope.bizPhrasePlaceholders) { angular.forEach(scope.bizPhrasePlaceholders, function (value, key) { var regex = new RegExp(key, 'g'); text = text.replace(regex, value); }); } element.text(text); }, function () { //console.warn(String.format("bizPhrase | Phrase not found for current culture ({0}): {1}", $translate.use(), attrs.bizPhrase)); }); //if (scope.bizPhraseEditable !== undefined) { // console.log('Editable...', scope.bizPhrase); // if ($rootScope.LoggedInUser) { // And has permissions to edit... // console.log($rootScope.LoggedInUser); // } // element.addClass('bizFrontendEditPermitted'); //} } return directive; } angular.module('bizPart').directive('bizPhraseAlt', bizPhraseAltDirective); function bizPhraseAltDirective($translate, bizPhraseLogService, $rootScope) { var directive = { restrict: "A", scope: { bizPhraseAlt: "@", }, link: linkFunction }; function linkFunction(scope, element, attrs) { console.log("phrase alt", attrs.bizPhraseAlt) $translate(scope.bizPhraseAlt).then(function (translation) { var text = translation.toString(); //console.log("phrase alt text", text) if (!bizPhraseLogService.Phrases.GetItemByValue('Key', attrs.bizPhraseAlt)) { bizPhraseLogService.LogPhrase(attrs.bizPhraseAlt, text, $translate.use()); bizPhraseLogService.Phrases.push({ Key: attrs.bizPhraseAlt }); } element[0].setAttribute('alt', text); }, function () { //console.warn(String.format("bizPhraseAlt | Phrase not found for current culture ({0}): {1}", $translate.use(), attrs.bizPhraseAlt)); }); } return directive; } angular.module('bizPart').directive('bizPhraseAriaLabel', bizPhraseAriaLabelDirective); function bizPhraseAriaLabelDirective($translate, bizPhraseLogService, $rootScope) { var directive = { restrict: "A", scope: { bizPhraseAriaLabel: "@", }, link: linkFunction }; function linkFunction(scope, element, attrs) { //console.log("bizPhraseAriaLabel", attrs.bizPhraseAriaLabel) $translate(scope.bizPhraseAriaLabel).then(function (translation) { var text = translation.toString(); //console.log("bizPhraseAriaLabel", text) if (!bizPhraseLogService.Phrases.GetItemByValue('Key', attrs.bizPhraseAriaLabel)) { bizPhraseLogService.LogPhrase(attrs.bizPhraseAriaLabel, text, $translate.use()); bizPhraseLogService.Phrases.push({ Key: attrs.bizPhraseAriaLabel }); } element[0].setAttribute('aria-label', text); }, function () { //console.warn(String.format("bizPhraseAriaLabel | Phrase not found for current culture ({0}): {1}", $translate.use(), attrs.bizPhrase)); }); } return directive; } angular.module('bizPart').directive('bizPhrasePlaceholder', bizPhrasePlaceholderDirective); function bizPhrasePlaceholderDirective() { var directive = { restrict: "A", link: linkFunction, scope: { bizPhrasePlaceholder: '@' } }; function linkFunction(scope, element, attrs) { var phrase = BizPart.Client.Core.CurrentTab.GetPhrase(scope.bizPhrasePlaceholder); if (phrase) element[0].placeholder = phrase; } return directive; } angular.module('bizPart').directive('bizGo', bizGoDirective); function bizGoDirective() { var directive = { restrict: "A", link: bizGoLink }; function bizGoLink(scope, element, attrs) { var path = ""; attrs.$observe('bizGo', function (val) { path = val; }); element.bind('click', function () { if (path && path != "") { window.location.href = path; } }); } return directive; } angular.module('bizPart').directive('bizBackButton', bizBackButton); function bizBackButton() { var directive = { restrict: "E", scope: { href: '@' }, bindToController: true, controllerAs: 'vm', controller: bizBackButtonController }; bizBackButtonController.$inject = ["$scope", "$compile"]; function bizBackButtonController($scope, $compile) { var vm = this; vm.GoBack = GoBack; function GoBack() { if (vm.href) window.location.href = $rootScope.BackUrl; else window.history.back(); } var element = angular.element('.biz-back-button'); if (!element.length) angular.element(document.body).append($compile('')($scope)); } return directive; } angular.module('bizPart').directive('bizVideoModuleEvents', bizVideoModuleEventsDirective); bizVideoModuleEventsDirective.$inject = ["bizCoreService"]; function bizVideoModuleEventsDirective(bizCoreService) { var directive = { restrict: "A", link: linkFunction, scope: { onEnded: "&", onPlay: "&?" } }; function linkFunction(scope, element, attrs) { element[0].onended = function () { scope.$apply(scope.onEnded()); } element[0].onplay = function () { if (scope.onPlay) { scope.$apply(scope.onPlay()); } } } return directive; } angular.module('bizPart').directive('bizLoader', bizLoader); bizLoader.$inject = ["bizLoaderService", "$timeout"]; function bizLoader(bizLoaderService, $timeout) { var directive = { restrict: "E", link: linkFunction, template: '
' //template: "
" }; function linkFunction(scope, element, attrs) { scope.progressIcon = siteRootPath + bizLoaderService.LoaderIcon; scope.radius = attrs.radius; scope.loadertype = getLoader('sonar'); var delayShow = attrs.delay || 1500; $timeout(function () { scope.loaded = true; }, delayShow); } return directive; } angular.module('bizPart').directive('bizStateUrl', bizStateUrl); bizStateUrl.$inject = ["$state", "$compile"]; function bizStateUrl($state, $compile) { var allStates = $state.get(); var directive = { restrict: "A", scope: { bizStateUrl: "@", bizStateUrlParams: "=" }, link: linkFunction } function linkFunction(scope, elem, attrs) { attrs.$observe("bizStateUrl", function (stateUrl) { if (!stateUrl) return; if (scope.bizStateUrlParams) { for (var prop in scope.bizStateUrlParams) { stateUrl = stateUrl + "/:" + prop; } } var state = allStates.GetItemByValue("url", stateUrl); if (!state) return; elem.unbind('click'); elem.css("cursor", "pointer"); elem.bind('click', function (event) { $state.go(state.name, scope.bizStateUrlParams); }); }); } return directive; } angular.module('bizPart').directive('bizFullPageLoader', bizFullPageLoader); function bizFullPageLoader() { var directive = { restrict: "E", template: '
Page loading
', controller: bizFullPageLoaderController, controllerAs: "vm" }; bizFullPageLoaderController.$inject = ["bizLoaderService"] function bizFullPageLoaderController(bizLoaderService) { var vm = this; vm.ShowLoader = ShowLoader; vm.ProgressIcon = siteRootPath + bizLoaderService.LoaderIcon function ShowLoader() { return bizLoaderService.FullPageLoaderRequests > 0; } } return directive; } angular.module('bizPart').directive('bizBackgroundImage', bizBackgroundImageDirective); bizBackgroundImageDirective.$inject = ["bizCoreService"]; function bizBackgroundImageDirective(bizCoreService) { var directive = { restrict: "A", link: linkFunction }; function linkFunction(scope, element) { bizCoreService.GetPortalsetting('bizBackgroundImage').success(getPortalsettingCallback); function getPortalsettingCallback(response) { if (response.d != "") { setElementAttributes(response.d); } } function setElementAttributes(backgroundImage) { backgroundImage = siteRootPath + backgroundImage; angular.element(element).css('background', 'url(' + backgroundImage + ')'); angular.element(element).css('background-size', 'cover'); } setElementAttributes('images/common/background.jpg'); } return directive; } angular.module('bizPart').directive('bizVideoEvents', bizVideoEventsDirective); bizVideoEventsDirective.$inject = ["bizCoreService"]; function bizVideoEventsDirective(bizCoreService) { var directive = { restrict: "A", link: linkFunction }; function linkFunction(scope, element, attrs) { element.ready(function () { element[0].onplay = function () { bizCoreService.EventStart(scope.$eval(attrs.bizVideoEvents).Id, attrs.bizVideoEventsStart); }; element[0].onended = function () { bizCoreService.EventEnd(scope.$eval(attrs.bizVideoEvents).Id, attrs.bizVideoEventsEnd); }; }); } return directive; } angular.module('bizPart').directive('afterRender', afterRender); afterRender.$inject = ["$timeout"]; function afterRender($timeout) { return { restrict: 'A', terminal: true, transclude: false, link: function (scope, element, attrs) { if (attrs.afterRender) { $timeout(scope.$eval(attrs.afterRender), 500); //Calling a scoped method } } }; } angular.module('bizPart').directive('onFinishRender', onFinishRender); onFinishRender.$inject = ["$timeout"]; function onFinishRender($timeout) { return { restrict: 'A', link: function (scope, element, attr) { if (scope.$last) { $timeout(function () { scope.$eval(attr.onFinishRender); }) } } } } angular.module('bizPart').directive('bizClickOutside', bizClickOutside); bizClickOutside.$inject = ['$document', '$timeout']; function bizClickOutside($document, $timeout) { return { link: function postLink(scope, element, attrs) { var onClick = function (event) { var isChild = element[0].contains(event.target); var isSelf = element[0] == event.target; var isInside = isChild || isSelf; if (!isInside) { scope.$apply(attrs.bizClickOutside) } } var timeoutPromise; if(attrs.bizClickOutsideActive === undefined) { $document.bind('click', onClick); } scope.$watch(function () { return attrs.bizClickOutsideActive }, function (newValue, oldValue) { $timeout.cancel(timeoutPromise); timeoutPromise = $timeout(function() { if (newValue !== oldValue && newValue == "true") { $document.bind('click', onClick); } else if (newValue !== oldValue && newValue == "false") { $document.unbind('click', onClick); } }, 150); }); } }; }; angular.module('bizPart').directive('fadeIn', fadeIn); fadeIn.$inject = ["$timeout"]; function fadeIn($timeout) { return { restrict: 'A', link: function (scope, element, attrs) { if (attrs.fadeIn) { element.ready(function () { $timeout(function () { $(attrs.fadeIn).toggleClass("shown"); }, attrs.fadeInTime || 0); }); } else { element.ready(function () { $timeout(function () { $(element).toggleClass("shown"); }, attrs.fadeInTime || 0); }); } } } } angular.module('bizPart').directive('refreshSlickOnLoad', refreshSlickOnLoad); refreshSlickOnLoad.$inject = ["$timeout"]; function refreshSlickOnLoad($timeout) { return { restrict: 'A', link: function (scope, element, attrs) { element.ready(function () { if (attrs.refreshSlickOnLoad) { $timeout(function () { $(attrs.refreshSlickOnLoad + ' .slick-slider')[0].slick.refresh(); }, 16); } else { $timeout(function () { $(".slick-slider")[0].slick.refresh(); }, 16); } $('.slick-dots').find('li button').attr('disabled', true); }); } } } angular.module('bizPart').directive('getVideoDuration', getVideoDuration); function getVideoDuration() { return { restrict: 'A', link: function (scope, element, attrs) { element.ready(function () { $(element)[0].addEventListener('loadedmetadata', function () { var vlength = $(element)[0].duration; var sec_num = parseInt(vlength, 10); var minutes = Math.floor(sec_num / 60); var seconds = sec_num - (minutes * 60); if (minutes < 10) { minutes = "0" + minutes; } if (seconds < 10) { seconds = "0" + seconds; } var time = minutes + ':' + seconds; $(element).parent().parent().find('.video-length').text(time); }); }); } } } angular.module('bizPart').directive('bizVideoLength', bizVideoLength); bizVideoLength.$inject = ["$parse"]; function bizVideoLength($parse) { return { restrict: 'A', link: function (scope, element, attrs) { element.ready(function () { element[0].addEventListener('loadedmetadata', function () { scope.$apply(function () { $parse(attrs.bizVideoLength).assign(scope.$parent, element[0].duration); }) }); }); } } } angular.module('bizPart').directive('fitYoutubeVideo', fitYoutubeVideo); function fitYoutubeVideo() { return { restrict: 'A', link: function (scope, element, attrs) { element.ready(function () { setTimeout(function () { var video = element.find('iframe[src*=youtube]'); if (video.length) { var wrapper = angular.element('
'); wrapper.insertBefore(video); video.attr('style', 'position:absolute;top:0;left:0;height:100%;width:100%'); wrapper.append(video); } }); }); } } } angular.module('bizPart').directive('bizCheckboxList', bizCheckboxList); bizCheckboxList.$inject = ["$compile"]; function bizCheckboxList($compile) { var directive = { restrict: 'E', scope: { ngModel: "=", options: "@" }, template: '', link: linkFunction, controllerAs: 'vm', bindToController: true, controller: bizCheckboxListController }; function linkFunction(scope, elem, attrs) { if (!attrs.options) { console.error("bizCheckboxList: No options expression supplied"); return; } var regex = new RegExp(/(.*?) as (.*?) for (.*?) in (.*)/, 'i'); var groups = attrs.options.match(regex); if (!groups) { console.error("bizCheckboxList: Invalid options expression. Must be in the format (.*?) as (.*?) for (.*?) in (.*)"); return; } var html = '{{' + groups[2] + '}}'; elem.html(html); $compile(elem.contents())(scope); } bizCheckboxListController.$inject = ["$scope"]; function bizCheckboxListController($scope) { var vm = this; vm.toggled = toggled; vm.toggle = toggle; function toggled(value) { return vm.ngModel && vm.ngModel.indexOf(value) > -1; } function toggle(value) { if (!vm.ngModel) vm.ngModel = []; if (vm.toggled(value)) vm.ngModel.Remove(value); else vm.ngModel.push(value); } } return directive; } angular.module('bizPart').directive('bizTranslateBind', bizTranslateBind); function bizTranslateBind() { var directive = { restrict: "A", scope: { Translations: "=bizTranslateBind" }, link: linkFunction }; function linkFunction(scope, elem, attr) { if(scope.Translations) { var translatedObj = scope.Translations.GetItemByValue('CultureId', currentCultureId); if (translatedObj && translatedObj.Value) { elem.html(translatedObj.Value); } } } return directive; } angular.module('bizPart').directive('bizTranslate', bizTranslate); bizTranslate.$inject = ["$rootScope"]; function bizTranslate($rootScope) { var directive = { restrict: "A", scope: { Translations: "=bizTranslateItems", Culture: "=bizTranslateCulture", Type: "@?bizTranslateType", OnChange: "&?bizTranslateChange", Model: "=?ngModel", setDirty: "@?" }, link: linkFunction }; return directive; function linkFunction(scope, element, attrs) { scope.$watch(function () { return scope.Translations; }, handleTranslations(true) ); scope.$watch(function () { return scope.Culture; }, handleTranslations(false) ); scope.$watch(function () { return scope.Model; }, handleModelUpdate); element.on('propertychange keyup input cut paste', function () { if (scope.CurrentTranslation) { scope.CurrentTranslation.Value = this.value; if (scope.OnChange) { scope.OnChange({ $value: scope.CurrentTranslation.Value }); } SetDirty(); } }); function handleModelUpdate(newValue, oldValue) { if (!scope.disableNextOnChange && newValue && newValue != oldValue && scope.CurrentTranslation && scope.Model !== undefined) { scope.CurrentTranslation.Value = scope.Model; if (scope.OnChange) { scope.OnChange({ $value: scope.CurrentTranslation.Value }); } } scope.disableNextOnChange = false; } function handleTranslations(triggerOnChange) { return function () { if (!scope.Culture) return; if (!scope.Translations) scope.Translations = []; var translations = scope.Translations; if (scope.Type) translations = translations.GetItemsByValue('Type', scope.Type); scope.CurrentTranslation = translations.GetItemByValue('CultureId', scope.Culture.Id); if (!scope.CurrentTranslation) { scope.CurrentTranslation = { CultureId: scope.Culture.Id, Type: ~~scope.Type, Value: "" } scope.Translations.push(scope.CurrentTranslation); } element.val(scope.CurrentTranslation.Value); scope.disableNextOnChange = !triggerOnChange; scope.Model = scope.CurrentTranslation.Value; } } function SetDirty() { if (scope.setDirty) { $rootScope.$broadcast('PAGE_DIRTY', true); } } } } angular.module('bizPart').directive('bizAutofocus', bizAutofocus); function bizAutofocus() { return { restrict: 'A', link: function (scope, element, attributes) { element[0].focus(); } } } angular.module('bizPart').directive('bizFocusIf', bizFocusIf); bizFocusIf.$inject = ["$timeout"] function bizFocusIf($timeout) { return { restrict: 'A', scope: { bizFocusIf: '=' }, link: function (scope, element) { scope.$watch('bizFocusIf', function (value) { if (value === true) { $timeout(function () { element[0].focus(); }); } }); } }; } angular.module('bizPart').directive('bizSelectOnFocus', bizSelectOnFocus); bizSelectOnFocus.$inject = ["$window"]; function bizSelectOnFocus($window) { return { restrict: 'A', link: function (scope, element, attrs) { element.on('focus', function () { if (!$window.getSelection().toString()) { this.setSelectionRange(0, this.value.length) } }); } }; } angular.module('bizPart').directive('bizDotdotdot', dotdotdotDirective); function dotdotdotDirective() { return { restrict: 'A', link: function (scope, element, attributes) { setTimeout(function () { if (element.dotdotdot) element.dotdotdot({ watch: true }); }) } } } angular.module('bizPart').directive('bizToggleTrueHeight', bizToggleTrueHeight); bizToggleTrueHeight.$inject = ["$timeout"] function bizToggleTrueHeight($timeout) { return { restrict: 'A', scope: { showTrueHeight: '=', baseHeight: '@?' }, link: function (scope, element, attributes) { const baseHeight = scope.baseHeight || '0'; function Init() { if (scope.showTrueHeight) { $timeout(function () { var height = element[0].scrollHeight; element.css('height', height + 'px'); }); } else { element.css('height', baseHeight + 'px'); } } scope.$watch('showTrueHeight', function (value) { Init(); }); Init(); } } } angular.module('bizPart').directive('bizLineLimit', bizLineLimit); bizLineLimit.$inject = ["$timeout", "$window", "$compile", "$interpolate", "$filter"] function bizLineLimit($timeout, $window, $compile, $interpolate, $filter) { return { restrict: 'A', transclude: true, scope: { bizLineLimit: '=', bizLineLimitTruncated: "=?", disableTakeUnnecessarySpace: "=?", ngBind: '=?', ngBindHtml: '=?' }, link: function (scope, element, attrs, ctrl, transclude) { var lineHeight = 0; var initialized = false; var lineCount = 1; if (Array.isArray(scope.bizLineLimit)) { if ($(window).width() < 960) lineCount = scope.bizLineLimit[0]; //Mobile else lineCount = scope.bizLineLimit[1]; //Desktop } else { lineCount = scope.bizLineLimit; } scope.$watch('ngBind', function (value) { if (initialized) { element.html(StripHtml(value)); } }) scope.$watch('ngBindHtml', function (value) { if (initialized) { element.html(StripHtml(value)); } }) function Init() { if (!element.is(':visible')) return HandleInvisibleElement(); LimitLines(); if(!scope.ngBind && !scope.ngBindHtml) { transclude(function (clone) { if (clone.length) { element.html(clone); } }); } $timeout(function () { element.dotdotdot({ watch: 'window', callback: Truncated }); }); } function HandleInvisibleElement() { var cancel = scope.$watch(function () { return element.is(':visible'); }, function (visible) { if (!visible) return; Init(); cancel(); }); } function Truncated(isTruncated) { scope.bizLineLimitTruncated = isTruncated; } function StripHtml(content) { return content; if (content && content.indexOf('<') >= 0) { content = $filter('stripHtml')(content); } return content; } function LimitLines() { element.html(' '); if (!lineHeight || ~~lineHeight <= 0) lineHeight = element.height(); if (scope.ngBind) element.html(StripHtml(scope.ngBind)); if (scope.ngBindHtml) element.html(StripHtml(scope.ngBindHtml)); var newHeight = lineHeight * lineCount; if (scope.disableTakeUnnecessarySpace == undefined || scope.disableTakeUnnecessarySpace == false) { element.css('height', newHeight + 'px'); } else { element.css('text-overflow', 'ellipsis'); element.css('display', '-webkit-box'); element.css('max-height', newHeight); element.css('-webkit-line-clamp', lineCount); element.css('-webkit-box-orient', 'vertical'); } element.css('line-height', lineHeight + 'px'); element.css('overflow', 'hidden'); if (element.css('display') == 'inline') //Can't have hidden overflow in an inline element element.css('display', 'block'); initialized = true; } Init(); } } } angular.module('bizPart').directive('bizContainerLimit', bizContainerLimit); function bizContainerLimit() { return { restrict: 'A', link: function (scope, element, attrs) { element.css('white-space', 'nowrap'); setTimeout(function () { ContainerLimit(); if (element.dotdotdot) element.dotdotdot({ watch: true }); }) function ContainerLimit() { var containerHeight = element.outerHeight(); element.css('max-height', containerHeight); } } } } angular.module('bizPart').directive('bizLoadingValue', bizLoadingValue); bizLoadingValue.$inject = ["$timeout"]; function bizLoadingValue($timeout) { return { restrict: 'A', transclude: true, scope: { ngBind: '=?', }, link: function (scope, element, attrs, ctrl, transclude) { var w = scope.$watch('ngBind', function (value) { if (value !== undefined) { $timeout(function () { element.html(value); w(); }) } }); function Init() { $timeout(function () { element.html(''); }); } Init(); } } } angular.module('bizPart').directive('bizCollapse', collapseDirective); function collapseDirective() { return { restrict: 'A', link: function (scope, element, attrs) { element.ready(function () { if (attrs.bizCollapse) { element.bind('click', function () { $(attrs.bizCollapse).toggleClass('collapsed') $(element).toggleClass('plus') }); } }); } } } angular.module('bizPart').directive('stopEvent', stopEvent); function stopEvent() { return { restrict: 'A', link: function (scope, element, attrs) { element.bind('click', function (e) { e.stopPropagation(); }); } } } angular.module('bizPart').directive('toggleClass', toggleClass); function toggleClass() { return { restrict: 'A', link: function (scope, element, attrs) { if (attrs.toggleClass) { element.bind('click', function () { element.toggleClass(attrs.toggleClass); }); } } } } angular.module('bizPart').directive('bizExpand', expandDirective); function expandDirective() { return { restrict: 'A', scope: { expand: "=" }, link: function (scope, element, attributes) { var expandButton = angular.element('
Expand
'); expandButton.insertAfter(element); $(".expandButton").click(function () { element.dotdotdot({ watch: true, ellipsis: '' }); element.trigger("isTruncated", function (isTruncated) { if (isTruncated) { element.trigger("destroy"); element.removeClass('expandMaxHeight'); } else { element.addClass('expandMaxHeight'); } }); }); }, controller: function ($scope, $element, $timeout) { $scope.$watch("expand", function () { $timeout(function () { $element.dotdotdot({ watch: true, ellipsis: '' }); }, 0); }, true); } } } angular.module('bizPart').directive('bizQueryClass', bizQueryClassDirective); function bizQueryClassDirective() { return { restrict: 'A', scope: { bizQueryClass: "=" }, link: function (scope, element) { if (scope.bizQueryClass) { if (scope.bizQueryClass.Name && scope.bizQueryClass.Value && scope.bizQueryClass.Class) { if (getParameterByName(scope.bizQueryClass.Name) == scope.bizQueryClass.Value) element.addClass(scope.bizQueryClass.Class); } } } } } angular.module('bizPart').directive('bizExpandIf', bizExpandIfDirective); function bizExpandIfDirective() { return { restrict: 'A', link: function (scope, element, attrs) { var expanded = false; element.hide(); scope.$watch(attrs.bizExpandIf, function (value) { if (expanded == value) return; if (value) element.slideDown('fast'); else element.slideUp('fast'); expanded = value; }); } } } angular.module('bizPart').directive('bizContractIf', bizContractIfDirective); function bizContractIfDirective() { return { restrict: 'A', scope: { bizContractIf: "=" }, link: function (scope, element) { if (scope.bizContractIf) { element.css('display', 'none'); } scope.$watch(function () { return scope.bizContractIf }, function (oldValue, newValue) { if (oldValue != newValue) { if (newValue) element.slideDown('fast'); else element.slideUp('fast'); } }); } } } angular.module('bizPart').directive('bizProgressCircle', bizProgressCircle); bizProgressCircle.$inject = ['$timeout']; function bizProgressCircle($timeout) { return { restrict: 'E', scope: { progress: '@' }, template: '', link: linkFunction }; function linkFunction(scope, elem, attrs) { var circle = elem.find('circle')[0]; function CalculateCircle(value) { value = ~~value; if (value > 100) value = 100; else if (value < 0) value = 0; var radius = circle.r.baseVal.value; var circumference = radius * 2 * Math.PI; circle.style.strokeDasharray = circumference + " " + circumference; circle.style.strokeDashoffset = "" + circumference; const offset = circumference - (value || 0) / 100 * circumference; circle.style.strokeDashoffset = offset; scope.initialized = true; } CalculateCircle(100); scope.$watch('progress', function (newVal, oldVal) { if (newVal && (newVal != oldVal || newVal !== scope.currentValue)) { $timeout(function () { try { CalculateCircle(newVal); } catch(e) { console.error("error calculating the progress", e); } }, 500); } }); } } angular.module('bizPart').directive('scrollToBottom', scrollToBottom); function scrollToBottom() { return { restrict: 'A', scope: { scrollToBottom: "=" }, link: function (scope, element, attributes) { var initializing = true; scope.$watchCollection('scrollToBottom', function (newValue) { if (newValue && newValue.length > 0 && !$(element).is(':animated')) { setTimeout(function () { if (initializing) { $(element).animate({ scrollTop: $(element).prop("scrollHeight") }, 400); initializing = false; } else { $(element).animate({ scrollTop: $(element).prop("scrollHeight") }, 400); } }, 1); } }); } } } angular.module('bizPart').directive('keyboardEnter', keyboardEnter); function keyboardEnter() { return { restrict: 'A', link: function (scope, element, attributes) { element.bind("keydown keypress", function (event) { if (event.keyCode == 13 && !event.shiftKey) { //Checking phase so apply won't generate script-errors. if (!scope.$$phase) { scope.$apply(function () { if (scope.$$childHead && scope.$$childHead.$mdAutocompleteCtrl) scope.$$childHead.$mdAutocompleteCtrl.hidden = true; scope.$eval(attributes.keyboardEnter); }); } event.preventDefault(); } }); } } } angular.module('bizPart').directive('hideButton', hideButtonDirective); hideButtonDirective.$inject = ["$window", "$timeout"]; function hideButtonDirective($window, $timeout) { var directive = { restrict: "A", link: linkFunction }; function linkFunction($scope, element, attr) { $scope.Hide = function () { if (attr.hideButton == "true") angular.element(element).addClass('hide-button-0'); else angular.element(element).addClass('hide-button-20'); }; $scope.Show = function () { if (attr.hideButton == "true") angular.element(element).removeClass('hide-button-0'); else angular.element(element).removeClass('hide-button-20'); }; $scope.HideButton = function () { $scope.HidingButton = $timeout(function () { $scope.Hide(); }, 2500); }; $scope.OnScroll = function () { $timeout.cancel($scope.HidingButton); $scope.Show(); $scope.HideButton(); }; $scope.OnClick = function () { $timeout.cancel($scope.HidingButton); $scope.Show(); $scope.HideButton(); }; angular.element($window).bind('scroll', $scope.OnScroll); angular.element($window).bind('click', $scope.OnClick); $scope.HideButton(); } return directive; } angular.module('bizPart').directive('bizIsFullscreen', bizIsFullscreen); function bizIsFullscreen() { var directive = { restrict: "A", scope: { bizIsFullscreen: '=' }, link: linkFunction }; function linkFunction(scope, element, attrs) { element.on('webkitfullscreenchange mozfullscreenchange fullscreenchange', function (e) { var fs = document.fullScreenElement; var wfs = document.webkitFullscreenElement; var mfs = document.mozFullScreenElement; var msfs = document.msFullscreenElement; if (fs || wfs || mfs || msfs) { scope.bizIsFullscreen = true; } else { scope.bizIsFullscreen = false; } scope.$apply(); }); } return directive; } angular.module('bizPart').directive('fallbackSrc', fallbackSrc); function fallbackSrc() { var directive = { restrict: "A", link: linkFunction }; function linkFunction(scope, element, attrs) { if(element[0].src == "") { element[0].src = attrs.fallbackSrc; } element.bind('error', function () { angular.element(this).attr('src', attrs.fallbackSrc); }); } return directive; } angular.module('bizPart').directive('fitImage', fitImage); function fitImage() { var directive = { restrict: "A", link: linkFunction }; return directive; function linkFunction(scope, element, attrs) { $(element).css('overflow', 'hidden'); $(element).find("img").on('load', function () { var limit = 100; if (attrs.fitImage != "") limit = ~~attrs.fitImage; if (this.width == this.height) { this.width = limit; this.height = limit; } else if (this.width > this.height) { this.height = limit; var offset = (this.width - limit) / 2; $(this).css("margin-left", "-" + offset + "px"); } else if (this.height > this.width) { this.width = limit; var offset = (this.height - limit) / 2; $(this).css("margin-top", "-" + offset + "px"); } }); } } angular.module('bizPart').directive('bizColorFill', bizColorFill); function bizColorFill() { var directive = { restrict: "A", link: linkFunction }; return directive; function linkFunction(scope, element, attrs) { var canvas = element[0]; var image = new Image(); image.src = attrs.bizColorFill; image.onload = function () { var ratio = canvas.width / image.width; canvas.height = image.height * ratio; var ctx = canvas.getContext("2d"); ctx.drawImage(image, 0, 0, canvas.width, canvas.height); ctx.globalCompositeOperation = "source-in"; ctx.fillStyle = "#CCCCCC"; ctx.fillRect(0, 0, canvas.width, canvas.height); } } } angular.module('bizPart').directive('bizOnLoad', bizOnLoad); bizOnLoad.$inject = ["$timeout"]; function bizOnLoad($timeout) { var directive = { restrict: "A", scope: { bizOnLoad: "&" }, link: linkFunction }; return directive; function linkFunction(scope, element, attrs) { if (element[0].onload != undefined) { element[0].onload = function () { if (scope.bizOnLoad) scope.bizOnLoad(); } } else if (scope.bizOnLoad) { $timeout(scope.bizOnLoad, 100); } } } angular.module('bizPart').directive('bizOn', bizOn); bizOn.$inject = ["$timeout"]; function bizOn($timeout) { var directive = { restrict: "A", scope: { bizOn: "&" }, link: linkFunction }; return directive; function linkFunction(scope, element, attrs) { if (!attrs.bizOnEvent) return; element.on(attrs.bizOnEvent, scope.bizOn); } } angular.module('bizPart').directive('bizSticky', bizSticky); bizSticky.$inject = ["$window"]; function bizSticky($window) { var directive = { restrict: "A", link: linkFunction }; return directive; function linkFunction(scope, element, attrs) { function setSticky() { scope.prevWidth = scope.parent.width(); scope.isSticky = true; scope.parent.css("padding-top", element.height()); element.addClass("sticky"); element.css("position", "fixed"); element.css("width", scope.prevWidth); element.css("max-width", "100%"); element.css("top", "0"); element.css("z-index", "8000"); } function removeSticky() { scope.isSticky = false; scope.parent.css("padding-top", "0px"); element.removeClass("sticky"); element.css("position", "static"); } function checkWidth() { if (scope.prevWidth != scope.parent.width()) { scope.prevWidth = scope.parent.width(); element.css("width", scope.prevWidth); } } function checkScroll() { var top = angular.element($window).scrollTop(); scope.bottom = element.offset().top; if (scope.bottom < top && !scope.isSticky) { setSticky(); scope.stickyBottom = scope.bottom; } else if (scope.stickyBottom > top && scope.isSticky) removeSticky(); } function init() { scope.parent = element.parent(); scope.bottom = element.offset().top; } scope.$watch(function () { return attrs.bizSticky; }, function () { init(); if (attrs.bizSticky == "true") { angular.element($window).bind('scroll', checkScroll); angular.element($window).bind('resize', checkWidth); } else { angular.element($window).unbind('scroll', checkScroll); angular.element($window).unbind('resize', checkWidth); removeSticky(); } }) } } angular.module('bizPart').directive('bizProgressBar', bizProgressBar); function bizProgressBar() { var directive = { restrict: "E", template: '
' + '
' + '
{{getLabel()}}
' + '
', scope: { current: "=current", total: "=total" }, link: linkFunction }; function linkFunction(scope, element, attr) { scope.getLabel = function () { if (scope.current < 0 || scope.total <= 0) return "N/A"; return Math.round((scope.current / scope.total) * 100) + '%' } scope.getPercentage = function () { if (scope.current < 0 || scope.total <= 0) return '0%'; return Math.round((scope.current / scope.total) * 100) + '%' } } return directive; } angular.module('bizPart').directive('bizBlogSearch', bizBlogSearch); bizBlogSearch.$inject = []; function bizBlogSearch() { var directive = { restrict: "E", templateUrl: siteRootPath + "Js/AngularModules/BizPart/views/bizBlogSearch.html", scope: { blogMoiId: "@blogMoiId", categoryIds: "@categoryIds", focusMe: "=focusMe" }, controller: loginController, controllerAs: "vm", bindToController: true, link: function (scope, element, attr) { scope.toggleSelect = function () { scope.vm.ShowSearchResult = !scope.vm.ShowSearchResult; } $(document).bind('click', function (event) { var isClickedElementChildOfPopup = element .find(event.target) .length > 0; if (isClickedElementChildOfPopup) { return; } scope.$apply(function () { scope.vm.ShowSearchResult = false; }); }); } }; loginController.$inject = ["blogSearchService"]; function loginController(blogSearchService) { var vm = this; vm.ShowSearchResult = false; vm.SearchTerm = ''; vm.SearchResult = []; //Search vm.KeyEnter = function () { vm.SearchResult = []; var promise = blogSearchService.GetBlogPostsSearch(vm.blogMoiId, vm.categoryIds, vm.SearchTerm); promise.success(BlogPostSearchCallback); } function BlogPostSearchCallback(response) { vm.ShowSearchResult = true; vm.SearchResult = response.d; angular.forEach(vm.SearchResult, function (item, index) { item.ImagePathToUse = item.ImageUrl; item.FullFriendlyUrl = siteRootPath + item.CategoryFriendlyUrlName + item.UrlRewrite if (item.ImageUrlFirstOfContent == "") { item.ImagePathToUse = item.ImageUrlFirstOfContent; } if (item.ImagePathToUse != "") { item.ImagePathToUse = siteRootPath + item.ImagePathToUse; } }); } } return directive; } //angular.module('bizPart').directive('bizLogin', bizLoginDirective); //bizLoginDirective.$inject = []; //function bizLoginDirective() { // var directive = { // restrict: "E", // templateUrl: siteRootPath + "Js/AngularModules/BizPart/views/login.html", // scope: { // showRegister: "=", // loggedIn: "=" // }, // controller: loginController, // controllerAs: "vm", // bindToController: true // }; // loginController.$inject = ["loginService", "$timeout"]; // function loginController(loginService, $timeout) { // var vm = this; // vm.LoginDetails = { // UserName: "", // Password: "" // }; // vm.LoginError = false; // vm.AllowingOpenRegistration = false; // vm.Login = Login; // vm.Register = Register; // vm.AllowOpenRegistration = AllowOpenRegistration; // function Login() { // loginService.AuthorizeUser(vm.LoginDetails.UserName, vm.LoginDetails.Password, true).then(AuthorizeUserCallback); // function AuthorizeUserCallback(response) { // if (response.d.Result == true && ~~response.d.ResultMessage > 0) { // //We are logged in.... // loginService.GetLoggedInUser().success(GetLoggedInUserCallback); // } // else { // vm.LoginError = true; // $timeout(function () { // vm.LoginError = false; // }, 5000); // } // } // function GetLoggedInUserCallback(response) { // BizPart.Client.Core.CurrentUser.Initialize(response.d); // vm.loggedIn = true; // } // } // function Register() { // loginService.CreateUser(vm.Register.FirstName, vm.Register.LastName, vm.Register.Username, vm.Register.Password, vm.Register.Email).then(RegisterCallback); // function RegisterCallback(response) { // if (~~response.d > 0) // vm.Signup = false; // } // } // function AllowOpenRegistration() { // loginService.AllowOpenRegistration().then(AllowOpenRegistrationCallback); // function AllowOpenRegistrationCallback(response) { // vm.AllowingOpenRegistration = response.d; // } // } // vm.AllowOpenRegistration(); // } // return directive; //} angular.module('bizPart').directive('bizLogin', bizLoginDirective); bizLoginDirective.$inject = ["bizCore"]; function bizLoginDirective(bizCoreProvider) { var directive = { restrict: "E", templateUrl: bizCoreProvider.getView('core.directives.login', "Js/AngularModules/BizPart/views/login.html"), scope: { showRegister: "=", loggedIn: "=", openIdProviderId: "@?" }, controller: loginController, controllerAs: "vm", bindToController: true }; loginController.$inject = ["loginService", "$timeout", "$state", "$window", "$rootScope"]; function loginController(loginService, $timeout, $state, $window, $rootScope) { var vm = this; vm.LoginError = false; vm.Login = Login; vm.Hide = Hide; vm.Init = Init; if (vm.showRegister === undefined) vm.showRegister = true; function Hide() { $rootScope.$broadcast('HIDE-LOGIN-DIRECTIVE'); } function Login() { loginService.Login(vm.UserName, vm.Password).then(LoginCallback); function LoginCallback(response) { if (response.data.Token && response.data.Token != "") { deleteStorage("BizPartAuthToken"); setBizPartAuthToken(response.data.Token, response.data.Id); } if (response.data.Id > -1 && response.data.Name == "User") $window.location.reload(); else if (response.data.Id > -1 && response.data.Name == "Admin") { $state.go("admin.home"); $window.location.reload(); } else { vm.LoginError = true; } } } function Init() { } vm.$onInit = vm.Init; } return directive; } angular.module('bizPart').directive('bizTree', recurveDirective); function recurveDirective() { return { template: ' {{tree.Name}}' + '
' + '
' + '{{leaf.Name}}' + '
' + '
' + '
' + '
' + '' + '
' + '
', scope: { tree: '=', childProperty: '@', leafProperty: '@' }, } } angular.module('bizPart').directive('bizRecursive', bizRecursive); function bizRecursive() { return { template: '
' + '
' + '' + '
' + '
', scope: { root: '=', filter: '&?', itemClick: '&?', itemMouseenter: '&?', itemMouseleave: '&?', itemDragover: '&?', childProperty: '@' }, link: function (scope, element, attrs) { scope.ItemClick = ItemClick; scope.MouseEnter = MouseEnter; scope.MouseLeave = MouseLeave; scope.GetFilter = GetFilter; function GetFilter(child) { if (scope.filter) return scope.filter()(child); else return true; } function ItemClick(e) { if (scope.itemClick) { scope.itemClick()(scope.root); } e.stopPropagation(); e.preventDefault(); } function MouseEnter() { if (scope.itemMouseenter) scope.itemMouseenter()(scope.root); } function MouseLeave() { if (scope.itemMouseleave) scope.itemMouseleave()(scope.root); } } } } angular.module('bizPart').directive('bizEnter', enterDirective); function enterDirective() { return function (scope, element, attrs) { element.bind("keydown keypress", function (event) { if (event.which === 13) { scope.$apply(function () { scope.$eval(attrs.bizEnter, { 'event': event }); }); event.preventDefault(); } }); }; } /** * @name bizArrowValueChange * @element input * @description * Changes value for input when using arrow up/down or shift + up/down for +/-10 units. * @param {boolean} [allownegative] Use attribute allownegative for allowing negative numbers. * @example * * * */ angular.module('bizPart').directive('bizArrowValueChange', arrowValueChangeDirective); function arrowValueChangeDirective() { return { restrict: "A", scope: {}, require: '?ngModel', link: function (scope, element, attrs, ngModel) { element.bind("keydown keypress", function (event) { if (event.key == 'ArrowUp' || event.key == 'ArrowDown') { changeValue(event); } }); function changeValue(event) { var suffix = ''; var newValue = ngModel.$modelValue; var currentNumberValue = parseInt(ngModel.$modelValue); var allowNegativeNumbers = (attrs.allownegative == "" || attrs.allownegative == "true"); var result = ngModel.$modelValue.match(/[a-z|%].*/i); if (result != null && result.length > 0) suffix = result[0]; if (isNaN(currentNumberValue)) currentNumberValue = 0; if (event.key == 'ArrowUp') { newValue = (currentNumberValue + (event.shiftKey ? 10 : 1)); } else if (event.key == 'ArrowDown') { if (currentNumberValue > 0 || (currentNumberValue <= 0 && allowNegativeNumbers)) newValue = (currentNumberValue - (event.shiftKey ? 10 : 1)); if (!allowNegativeNumbers && newValue < 0 || newValue == "") newValue = 0; } ngModel.$setViewValue(parseInt(newValue) + suffix); ngModel.$render(); event.preventDefault(); } } } } angular.module('bizPart').directive('bizCkeditor', ckeditorDirective); function ckeditorDirective() { return { require: '?ngModel', link: function (scope, element, attrs, ngModel) { var ck = CKEDITOR.replace(element[0]); ck.on('pasteState', function () { scope.$apply(function () { ngModel.$setViewValue(ck.getData()); }) }) ngModel.$render = function (value) { ck.setData(ngModel.$modelValue); } } } } angular.module('bizPart').directive('bizTagView', bizTagView); bizTagView.$inject = ["bizCore"]; function bizTagView(bizCoreProvider) { var directive = { restrict: "E", templateUrl: bizCoreProvider.getView('bizTagView', 'Js/AngularModules/BizPart/views/bizTagView.html'), scope: { item: "=", hideTitle: "@?" }, controller: bizTagViewController, controllerAs: "vm", bindToController: true }; function bizTagViewController() { var vm = this; } return directive; } angular.module('bizPart').directive('bizTagCloud', bizTagCloud); bizTagCloud.$inject = ["bizCore"]; function bizTagCloud(bizCoreProvider) { var directive = { restrict: "E", templateUrl: bizCoreProvider.getView('bizTagCloud', 'js/AngularModules/BizPart/views/tagcloud-clean.html'), scope: { sourceType: "@", state: "@", selectedTag: "=", showDialog: "@", expandIfSelectedTag: "=?", categoryId: "=?" }, controller: tagCloudController, controllerAs: "vm", bindToController: true }; tagCloudController.$inject = ["tagCloudService", "$state", "$cookies", "$window", "$scope", "$timeout", "$rootScope"]; function tagCloudController(tagCloudService, $state, $cookies, $window, $scope, $timeout, $rootScope) { var vm = this; vm.Init = Init; vm.RedirectToProvidedState = RedirectToProvidedState; vm.GetAllTagsWithOccurrenceBySource = GetAllTagsWithOccurrenceBySource; vm.ShowDialog = ShowDialog; vm.SetCookie = SetCookie; vm.ScrollTop = ScrollTop; vm.Tags = []; vm.ExpandCloud = false; $scope.$watch('vm.selectedTag', function (newVal, oldVal) { if (newVal != oldVal && newVal) { if (vm.expandIfSelectedTag == true && vm.selectedTag > 0) { vm.ExpandCloud = true; } } }); function ShowDialog() { var showDialogCookie = getLocalStorage('tagCloudDialogCookieShown'); if (showDialogCookie) return false; else return true; } function ScrollTop() { $window.scrollTo(0, 0); } function SetCookie() { var dialogCookieShown = getLocalStorage('tagCloudDialogCookieShown'); if (!dialogCookieShown) setLocalStorage('tagCloudDialogCookieShown', 'true'); } function GetAllTagsWithOccurrenceBySource() { tagCloudService.GetAllTagsWithOccurenceForItemsByType(vm.sourceType, vm.categoryId).then(GetAllTagsWithOccurenceForItemsByTypeSuccess); function GetAllTagsWithOccurenceForItemsByTypeSuccess(response) { vm.Tags = response.data; } } function RedirectToProvidedState(tag) { var originalState = getSessionStorage("tag.cloud.original.state"); if (tag && tag.Id == vm.selectedTag && originalState) { $state.go(originalState); setSessionStorage('tag.cloud.setexpand', true); } else { if ($state.$current.name == vm.state) { vm.selectedTag = tag && tag.Id > 0 ? tag.Id : undefined; const params = { sourceType: vm.sourceType, tag: tag }; $rootScope.$broadcast('selected-tag-changed', params); return; } if ($state.$current.name !== vm.state) { setSessionStorage('tag.cloud.original.state', $state.$current.name); } vm.selectedTag = tag.Id; $state.go(vm.state, { tagSystemName: tag.SystemName }); } } function Init() { var expand = getSessionStorage("tag.cloud.setexpand"); if (expand) { deleteSessionStorage("tag.cloud.setexpand"); vm.ExpandCloud = true; } vm.GetAllTagsWithOccurrenceBySource(); if (vm.ShowDialog()) { $timeout(() => { vm.SetCookie(); }, 5000); } } vm.$onInit = vm.Init; if (angular.version.major === 1 && angular.version.minor < 5) { vm.$onInit(); } } return directive; } angular.module('bizPart').directive('bizLikeActions', bizLikeActions); bizLikeActions.$inject = ["bizCore"]; function bizLikeActions(bizCoreProvider) { var directive = { restrict: "E", templateUrl: bizCoreProvider.getView('bizLikeActions', 'Js/AngularModules/BizPart/views/bizLikeActions.html'), scope: { likeActions: "=", item: "=", likeKey: "@", showActions: "=?", showHeader: "=?", allowComment: "=?" }, controller: bizLikeActionsController, controllerAs: "vm", bindToController: true }; bizLikeActionsController.$inject = ["bizLikeActionsService", "$state", "$scope", "$rootScope", "bizUser", "$timeout"]; function bizLikeActionsController(bizLikeActionsService, $state, $scope, $rootScope, bizUser, $timeout) { var vm = this; vm.ShowCommentInput = false; vm.SuccessfulLikeActionId = -1; vm.SuccessfulCommentAction = false; vm.HasUserLiked = false; vm.Init = Init; vm.PerformLikeAction = PerformLikeAction; vm.UpdateComment = UpdateComment; vm.IsImage = IsImage; vm.FilterImages = FilterImages; vm.FilterIcons = FilterIcons; function IsImage(action) { if (!action.Icon) return false; if (action.Icon.indexOf('/') >= 0 && action.Icon.indexOf('.') >= 0) return true; return false; } function FilterImages(action) { return vm.IsImage(action.Action); } function FilterIcons(action) { return !vm.IsImage(action.Action); } function PerformLikeAction(object, action) { action.Submitting = true; bizLikeActionsService.PerformLikeAction(object.CreatedByUserId, object.Id, action.Action.Id, vm.likeKey, vm.comment).then(function (response) { $timeout(function () { action.Submitting = false; }, 1000); vm.SuccessfulLikeActionId = BizPartCoreHelpers.getResponseValue(response); if (vm.SuccessfulLikeActionId > 0 || vm.SuccessfulLikeActionId === true) { action.LikeActionPerformedByUser = true; action.Count++; var totalCount = 0; var totalValue = 0; for (var i = 0; i < object.LikeActions.length; i++) { totalCount += object.LikeActions[i].Count; totalValue += object.LikeActions[i].Action.Value * object.LikeActions[i].Count; } object.AverageLikeValue = totalValue / totalCount; vm.HasUserLiked = true; } }); } function UpdateComment() { if (vm.SuccessfulLikeActionId > 0 && vm.SuccessfulCommentAction === false) { bizLikeActionsService.UpdateCommentForLikeAction(vm.SuccessfulLikeActionId, vm.comment).then(function (response) { vm.SuccessfulCommentAction = BizPartCoreHelpers.getResponseValue(response); }); } } function Init() { vm.IsAllowedForCurrentUser = $rootScope.MiniSettings["LikeActions"]["ForRolesOnly"].length == 0 || HasRequiredRole(); function HasRequiredRole() { vm.LoggedInUser = bizUser.getLoggedInUser(); console.log("via bizuser", vm.LoggedInUser); if (vm.LoggedInUser && vm.LoggedInUser.Roles) { var allowedRoles = $rootScope.MiniSettings["LikeActions"]["ForRolesOnly"]; for (var i = 0; i < allowedRoles.length; i++) { var x = vm.LoggedInUser.Roles.GetItemByValue('SystemName', allowedRoles[i]); if (x) { return true; } } } return false; } } $scope.$watch('vm.item', function (newVal, oldVal) { if (newVal != oldVal) { if (vm.item.LikeActions.GetItemByValue('LikeActionPerformedByUser', true)) { vm.HasUserLiked = true; vm.showRatingIcons = true; } } }); vm.$onInit = vm.Init; if (angular.version.major === 1 && angular.version.minor < 5) { vm.$onInit(); } } return directive; } angular.module('bizPart').directive('bizLikeView', bizLikeView); bizLikeView.$inject = ["bizCore"]; function bizLikeView(bizCoreProvider) { var directive = { restrict: "E", templateUrl: bizCoreProvider.getView('bizLikeView', 'Js/AngularModules/BizPart/views/bizLikeView.html'), scope: { item: "=" }, controller: bizLikeViewController, controllerAs: "vm", bindToController: true }; function bizLikeViewController() { } return directive; } angular.module('bizPart').directive('bizItemType', bizItemType); bizItemType.$inject = ["bizCore", "$rootScope"]; function bizItemType(bizCoreProvider, $rootScope) { var directive = { restrict: "E", templateUrl: bizCoreProvider.getView('bizItemType', 'Js/AngularModules/BizPart/views/bizItemType.html'), scope: { item: "=", type: "@", name: "=", icon: "=", id: "=" }, controller: bizItemTypeController, controllerAs: "vm", bindToController: true }; bizItemTypeController.$inject = ["$rootScope", "$state"]; function bizItemTypeController($rootScope, $state) { var vm = this; vm.OverrideName = ''; vm.Init = Init; function Init() { if (vm.name && vm.name.length > 0) { vm.OverrideName = vm.name; return; } if ($rootScope.showFirstTagForTypes && $rootScope.showFirstTagForTypes.indexOf(vm.type) >= 0) { if (vm.item && vm.item.Tags && vm.item.Tags.length > 0 && vm.item.Tags[0].Name.length > 0) { vm.OverrideName = vm.item.Tags[0].Name; return; } } vm.OverrideName = ''; } vm.$onInit = vm.Init; if (angular.version.major === 1 && angular.version.minor < 5) { vm.$onInit(); } } return directive; } angular.module('bizPart').directive('bizItemNotFound', bizItemNotFound); bizItemNotFound.$inject = ["bizCore", "$rootScope"]; function bizItemNotFound(bizCoreProvider, $rootScope) { var directive = { restrict: "E", templateUrl: bizCoreProvider.getView('bizItemNotFound', 'Js/AngularModules/BizPart/views/bizItemNotFound.html'), scope: { type: "@?", image: "=?" }, controller: bizItemNotFoundController, controllerAs: "vm", bindToController: true }; bizItemNotFoundController.$inject = ["$rootScope"]; function bizItemNotFoundController($rootScope) { var vm = this; //vm.Init = Init; //function Init() { //} //vm.$onInit = vm.Init; } return directive; } angular.module('bizPart').directive('bizContainerModulesList', bizContainerModulesList); bizContainerModulesList.$inject = []; function bizContainerModulesList() { var directive = { restrict: "E", templateUrl: siteRootPath + "Js/AngularModules/BizPart/views/bizContainerModulesList.html?v=" + bizPartVersion, scope: { adminType: "@" }, controller: bizContainerModulesListController, controllerAs: "vm", bindToController: true }; bizContainerModulesListController.$inject = ["bizContainerService", "$rootScope", "$mdDialog", "bizCoreService"]; function bizContainerModulesListController(bizContainerService, $rootScope, $mdDialog, bizCoreService) { var vm = this; vm.Init = Init; vm.GetAllContainerModuleAbstracts = GetAllContainerModuleAbstracts; vm.UpdateContainerModules = UpdateContainerModules; vm.ToggleModules = ToggleModules; vm.ContainerModuleAbstracts = []; vm.CurrentModules = []; vm.Setting = { Key: 'ACTIVE_CONTAINER_MODULES', Value: '', ObjectId: 0 }; function GetAllContainerModuleAbstracts() { var abstractFolders = ['~/Modules/BizPart.BizContainer/CMS/GUI/Modules', '~/Modules/BizPart.BizContainer/CMS/GUI/Modules/Product', '~/Modules/BizPart.BizContainer/Campaign/GUI/Modules', '~/Modules/BizPart.BizContainer/OnlineEducation/GUI/Modules', '~/Modules/BizPart.BizContainer/Layout/GUI/Modules']; if ($rootScope.PortalCustomerName) { abstractFolders.push('~/Customers/BizContainerCustomModules/' + $rootScope.PortalCustomerName + '/CMS'); abstractFolders.push('~/Customers/BizContainerCustomModules/' + $rootScope.PortalCustomerName + '/Campaign'); abstractFolders.push('~/Customers/BizContainerCustomModules/' + $rootScope.PortalCustomerName + '/OnlineEducation'); abstractFolders.push('~/Customers/BizContainerCustomModules/' + $rootScope.PortalCustomerName + '/Layout'); } bizContainerService.GetAllModuleAbstracts(abstractFolders).then(GetAllModuleAbstractsSuccess); function GetAllModuleAbstractsSuccess(response) { vm.ContainerModuleAbstracts = response.data; bizCoreService.Admin.GetGenericSetting(vm.adminType, 'ACTIVE_CONTAINER_MODULES', 0).then(GetGenericSettingSuccess); } } function ToggleModules(module) { vm.CurrentModules.indexOf(module.SystemName) > -1 ? vm.CurrentModules.splice(vm.CurrentModules.indexOf(module.SystemName), 1) : vm.CurrentModules.push(module.SystemName); } function UpdateContainerModules() { var confirm = $mdDialog.confirm({ title: 'Are you sure you want to update the modules used in the admin?', content: 'The modules accessible in this admin will be updated', ok: "Yes", cancel: "No", parent: angular.element(document.body) }); $mdDialog.show(confirm).then(okSave); function okSave() { vm.Setting.Value = JSON.stringify(vm.CurrentModules); vm.Setting.Type = vm.adminType; bizCoreService.Admin.UpdateGenericSetting(vm.Setting).then(okSaveSuccess); function okSaveSuccess(response) { } } } function Init() { vm.GetAllContainerModuleAbstracts(); } function GetGenericSettingSuccess(response) { if (!response.data) { //for (var i = 0; i < vm.ContainerModuleAbstracts.length; i++) { // vm.CurrentModules.push(vm.ContainerModuleAbstracts[i].Name); //} } else vm.CurrentModules = JSON.parse(response.data.Value); } vm.$onInit = vm.Init; if (angular.version.major === 1 && angular.version.minor < 5) { vm.$onInit(); } } return directive; } angular.module('bizPart').directive('bizXp', bizXp); bizXp.$inject = ["bizCore"]; function bizXp(bizCoreProvider) { var directive = { restrict: "E", scope: { points: '=?', // points to give (recommended to use, only use the ones below if really needed) givePoints: '=?', //for when there is a boolean variable that decides if points should be given or not type: '@?', // not really used, but could in theory be used to tell the directive to set a + char in front of the point value (using type 'add') object: '=?', // for legacy support, needed to send the entire object so different properties can be used in new and old core objectType: '@?' // type of object, so the proper property can be selected for the points value }, templateUrl: bizCoreProvider.getView('core.directives.xp', "Js/AngularModules/BizPart/views/bizExperiencePoints.html"), bindToController: true, controller: bizXPController, controllerAs: "vm", replace:true } function bizXPController() { var vm = this; vm.Init = Init; function Init() { if (typeof vm.givePoints === 'undefined') { vm.givePoints = true; } if (vm.objectType == 'blog') { vm.points = vm.object.ExperienceGive; } else if (vm.objectType == 'integer') { vm.points = vm.object; } } vm.$onInit = vm.Init; } return directive; } angular.module('bizPart').directive('bizCurrency', bizCurrency); bizCurrency.$inject = ["bizCore"]; function bizCurrency(bizCoreProvider) { var directive = { restrict: "E", scope: { currency: '=?', // currency value to give (recommended to use, only use the ones below if really needed) giveCurrency: '=?', //for when there is a boolean variable that decides if currency should be given or not type: '@?', // not really used, but could in theory be used to tell the directive to set a + char in front of the currency value (using type 'add') objectType: '@?', // for legacy support, needed to send the entire object so different properties can be used in new and old core object: '=' // type of object, so the proper property can be selected for the currency value }, templateUrl: bizCoreProvider.getView('core.directives.currency', "Js/AngularModules/BizPart/views/bizCurrency.html"), bindToController: true, controller: bizCurrencyController, controllerAs: "vm" } function bizCurrencyController() { var vm = this; vm.Init = Init; function Init() { if (typeof vm.giveCurrency === 'undefined') { vm.giveCurrency = true; } if (vm.objectType == 'blog') { vm.currency = vm.object.VirtualCurrencyGive; } else if (vm.objectType == 'integer') { vm.currency = vm.object; } } vm.$onInit = vm.Init; } return directive; } angular.module('bizPart').directive('bizUnitLogo', bizUnitLogo); bizUnitLogo.$inject = ["bizCore"]; function bizUnitLogo(bizCoreProvider) { var directive = { restrict: "E", scope: { }, templateUrl: bizCoreProvider.getView('core.directives.unitlogo', "Js/AngularModules/BizPart/views/bizUnitLogo.html"), //bindToController: true, controller: bizUnitLogoController, controllerAs: "vm" } bizUnitLogoController.$inject = ["bizCoreService", "$window"]; function bizUnitLogoController(bizCoreService, $window) { var vm = this; vm.logoAlt = ''; vm.Init = Init; function Init() { vm.logoAlt = $window.portalName + ' logotype' if (!portalSettings.IsUnitEnabled) { vm.Logo = portalSettings['logo']; } else { bizCoreService.GetUnitLogoForLoggedInUser().then(GetUnitLogoCallback); function GetUnitLogoCallback(response) { vm.Logo = BizPartCoreHelpers.getResponseValue(response) //Fallback to portal logo if the unit doesn't have a logo. if (!vm.Logo || vm.Logo === "") { vm.Logo = portalSettings['logo']; } } } } vm.$onInit = vm.Init; } return directive; } angular.module("bizPart").directive("bizSaveBtn", bizSaveBtn); function bizSaveBtn() { var directive = { restrict: 'E', scope: { status: "=", isLead: "=?", isDisabled: "=?", saveText: "@?", savingText: "@?", savedText: "@?", errorText: "=?", initialIcon: "@?", customClass: "@?" }, templateUrl: siteRootPath + 'Js/AngularModules/BizPart/views/save-btn.html?v=' + bizPartVersion, bindToController: true, controllerAs: 'vm', controller: bizSaveBtnController }; bizSaveBtnController.$inject = ["$rootScope", "$scope", "$timeout"]; function bizSaveBtnController($rootScope, $scope, $timeout) { var vm = this; vm.Initialize = Initialize; function Initialize() { if (!vm.status) { vm.status = 'INITIAL'; } $scope.$watch('vm.status', function (newValue, oldValue) { if (newValue === 'SAVED' && oldValue !== 'SAVED') { $timeout(function () { if (vm.status === 'SAVED') { vm.status = "INITIAL"; } }, 2000); } else if (newValue === 'ERROR' && oldValue !== 'ERROR') { $timeout(function () { if (vm.status === 'ERROR') { vm.status = "INITIAL"; } }, 3000); } }); } $rootScope.Initialized.then(vm.Initialize); } return directive; } angular.module("bizPart").directive("bizAlertBanner", bizAlertBanner); bizAlertBanner.$inject = ["bizCore"]; function bizAlertBanner(bizCoreProvider) { var directive = { restrict: 'E', scope: { }, templateUrl: bizCoreProvider.getView('core.directives.bizalertbanner', "Js/AngularModules/BizPart/views/bizAlertBanner.html"), bindToController: true, controllerAs: 'vm', controller: bizAlertBannerController }; bizAlertBannerController.$inject = ["$rootScope", "$http"]; function bizAlertBannerController($rootScope, $http) { var vm = this; var previousEtag = null; vm.Show = false; vm.Messages = []; vm.Initialize = Initialize; function Initialize() { if (portalSettings['IsAlertBannerActive'] === true) { GetAlertBannerData(); setInterval(GetAlertBannerData, 30000); } } function GetAlertBannerData() { var config = undefined; if (previousEtag != null) { config = { headers: { 'If-None-Match': previousEtag } }; } $http.get(siteRootPath + "api/alertbanner/GetAlertBanners", config).then( function (response) { if (response.status === 304) { console.log("Data has not been modified."); } else { GetDataSuccess(response); } }).catch(function (error) {}); } function GetDataSuccess(response) { if (response) { previousEtag = response.headers('ETag'); let msgs = response.data.Object; if (msgs.length > 0) { vm.Show = true; vm.Messages = msgs; } else { vm.Show = false; vm.Messages = []; } } } $rootScope.Initialized.then(vm.Initialize); } return directive; } angular.module("bizPart").directive("bizImageFocus", bizImageFocus); bizImageFocus.$inject = ["$rootScope"]; function bizImageFocus($rootScope) { return { restrict: 'E', template: `
Reset focus
`, scope: { src: '@', focusX: '=', focusY: '=', setDirty: '@?' }, link: function (scope, element) { scope.hasFocusSet = function () { if (scope.focusX && scope.focusX > 0 && scope.focusX !== 50 || scope.focusY && scope.focusY > 0 && scope.focusY !== 50) return true; return false; } scope.resetFocus = function (setDirty) { scope.focusX = 50; scope.focusY = 50; if (setDirty) SetDirty(); } scope.setImageSize = function () { // Set initial position in pixels based on percentages if (hasFocusSet() === false) { resetFocus(); } }; scope.setFocus = function (event) { const imgElement = element.find('img')[0]; const rect = imgElement.getBoundingClientRect(); const x = event.clientX - rect.left; const y = event.clientY - rect.top; // Update the focus percentages scope.focusX = parseInt((x / rect.width) * 100); scope.focusY = parseInt((y / rect.height) * 100); SetDirty(); }; function SetDirty () { if (scope.setDirty) $rootScope.$broadcast('PAGE_DIRTY', true); } } }; } angular.module("bizPart").directive("bizDictionary", bizDictionary); bizDictionary.$inject = []; function bizDictionary() { var directive = { restrict: "E", templateUrl: siteRootPath + "Js/AngularModules/BizPart/Views/bizDictionary.html?v=" + bizPartVersion, controller: bizDictionaryController, bindToController: true, controllerAs: "vm", scope: { categories: '@', filter: '@?', resultCount: '=' } } bizDictionaryController.$inject = ["$rootScope", '$scope', 'modules.dictionary.service']; function bizDictionaryController($rootScope, $scope, dictionaryService) { var vm = this; vm.Initialized = false; vm.Items = []; vm.FilteredItems = []; vm.Init = Init; function Init() { dictionaryService.GetAllEntriesWCategories(vm.categories).then(GetDataSuccess); } function GetDataSuccess(response) { var items = BizPartCoreHelpers.getResponseValue(response); for (var i = 0; i < items.length; i++) { items[i].Name = items[i].Word; items[i].Text = items[i].Description; items[i].Open = false; } vm.Items = items; applyFilter(); vm.Initialized = true; } function applyFilter() { if (vm.filter) { const catArray = vm.filter.split(',').map(c => parseInt(c.trim(), 10)); vm.FilteredItems = vm.Items.filter(f => f.GenericCategoryIds.some(gc => catArray.includes(gc))); } else { vm.FilteredItems = vm.Items; } vm.resultCount = vm.FilteredItems.length; } $scope.$watch("vm.filter", function (newValue, oldValue) { if (oldValue && newValue && oldValue !== newValue) { applyFilter(); } }); vm.$onInit = vm.Init; } return directive; } })(window.angular); // By Luis Perez // From blog post: http://www.simplygoodcode.com/2014/04/angularjs-getting-around-ngapp-limitations-with-ngmodule/ (function () { function initNgModules(element) { var elements = [element], moduleElements = [], modules = [], names = ['ng:module', 'ng-module', 'x-ng-module', 'data-ng-module', 'ng:modules', 'ng-modules', 'x-ng-modules', 'data-ng-modules'], NG_MODULE_CLASS_REGEXP = /\sng[:\-]module[s](:\s*([\w\d_]+);?)?\s/; function append(element) { element && elements.push(element); } for (var i = 0; i < names.length; i++) { var name = names[i]; append(document.getElementById(name)); name = name.replace(':', '\\:'); if (element.querySelectorAll) { var elements2; elements2 = element.querySelectorAll('.' + name); for (var j = 0; j < elements2.length; j++) append(elements2[j]); elements2 = element.querySelectorAll('.' + name + '\\:'); for (var j = 0; j < elements2.length; j++) append(elements2[j]); elements2 = element.querySelectorAll('[' + name + ']'); for (var j = 0; j < elements2.length; j++) append(elements2[j]); } } for (var i = 0; i < elements.length; i++) { var element = elements[i]; var className = ' ' + element.className + ' '; var match = NG_MODULE_CLASS_REGEXP.exec(className); if (match) { moduleElements.push(element); modules.push((match[2] || '').replace(/\s+/g, ',')); } else { if (element.attributes) { for (var j = 0; j < element.attributes.length; j++) { var attr = element.attributes[j]; if (names.indexOf(attr.name) != -1) { moduleElements.push(element); modules.push(attr.value); } } } } } for (var i = 0; i < moduleElements.length; i++) { var moduleElement = moduleElements[i]; var module = modules[i].replace(/ /g, '').split(","); angular.bootstrap(moduleElement, module); } } angular.element(document).ready(function () { initNgModules(document); }); angular.module('bizPart').value('bizApiControllerUrls', { FormsUser: "api/FormsUser/", FormsAdmin: "api/FormsAdmin/", GenericTag: "api/GenericTag/", MediabankUser: "api/MediabankUser/" }); })(); angular.module('bizPart').directive('bizJourney', bizJourneyDirective); angular.module('bizPart').directive('bizJourneyShowOne', bizJourneyShowOneDirective); angular.module('bizPart').directive('bizJourneyShowOneGrid', bizJourneyShowOneGridDirective); angular.module('bizPart').directive('bizJourneyShowOneCarousel', bizJourneyShowOneCarouselDirective); angular.module('bizPart').directive('bizJourneyGridSlick', bizJourneyGridSlickDirective); angular.module('bizPart').directive('bizJourneyButtons', bizJourneyButtonsDirective); angular.module('bizPart').service('bizJourneyService', bizJourneyService); bizJourneyDirective.$inject = []; bizJourneyShowOneDirective.$inject = []; bizJourneyShowOneGridDirective.$inject = []; bizJourneyShowOneCarouselDirective.$inject = []; bizJourneyGridSlickDirective.$inject = []; bizJourneyService.$inject = ["$http", "$state"]; function bizJourneyDirective() { var directive = { restrict: "E", scope: { itemsPerRow: "=?", hideFavorites: "=?", miniSettings: "=?", item: "=?", typeName: "@?", }, templateUrl: siteRootPath + "Js/AngularModules/BizPart/views/bizJourney.html", controller: bizJourneyController, controllerAs: "vm", bindToController: true }; bizJourneyController.$inject = ["$rootScope", "bizJourneyService", "$state"]; function bizJourneyController($rootScope, bizJourneyService, $state) { var vm = this; vm.Journeys = []; vm.GetItemWidth = GetItemWidth; vm.Description; function GetItemWidth() { return 100 / vm.itemsPerRow; } $rootScope.$watch('HideFavoritesForUser', function (newVal, oldVal) { if (newVal && newVal != oldVal) { if ($rootScope.HideFavoritesForUser !== undefined && $rootScope.HideFavoritesForUser === true) { vm.hideFavorites = true; } } }); function Init() { //console.log("journey init"); if (!vm.itemsPerRow) vm.itemsPerRow = 4; if (vm.miniSettings) { vm.JourneyDisplayType = 'STANDARD'; } else { vm.JourneyDisplayType = 'CAROUSEL'; } if (vm.miniSettings && vm.miniSettings.ShowTags !== undefined) { vm.hideFavorites = !vm.miniSettings.ShowTags; } vm.hideFavorites = true;//favs not used in journey right now if (!vm.hideFavorites && ($rootScope.HideFavoritesForUser !== undefined && $rootScope.HideFavoritesForUser === true)) { vm.hideFavorites = true; } if (vm.item && vm.item.Id > 0 && (vm.item.EngageObjectType > -1 || vm.typeName)) { //console.log('vm.item.EngageObjectType', vm.item.EngageObjectType); } SetMainJourneyDescription(); $rootScope.JourneysInitialized.then(InitJourneys); function InitJourneys() { var journeys = FilterJourneyList($rootScope.Journeys); vm.Journeys = journeys; } function SetMainJourneyDescription() { bizJourneyService.GetJourneyDescription().then(function (response) { vm.Description = response.data; }); } function FilterJourneyList(jList) { if (!vm.miniSettings) return jList; if (!vm.item || vm.item.Id <= 0) return jList; var filteredList = []; for (var i = 0; i < jList.length; i++) { var itemIsInJourney = false; for (var j = 0; j < jList[i].EngageObjects.length; j++) { var eo = jList[i].EngageObjects[j]; if (eo.Id === vm.item.Id && eo.EngageObjectType === vm.item.EngageObjectType) { itemIsInJourney = true; } } if (itemIsInJourney) { filteredList.push(jList[i]); } } return filteredList; } } this.$onInit = Init; $rootScope.$on('favorites.change', Init); } return directive; } function bizJourneyShowOneDirective() { var directive = { restrict: "E", scope: { journey: "=", itemsPerRow: "=?", miniSettings: '=?', item: "=?", typeName: "=?", }, templateUrl: siteRootPath + "Js/AngularModules/BizPart/views/bizJourneyShowOne.html", controller: bizJourneyShowOneController, controllerAs: "vm", bindToController: true }; bizJourneyShowOneController.$inject = ["$state", "bizJourneyService", "bizCoreService", "$scope", "$rootScope", "$timeout"]; function bizJourneyShowOneController($state, bizJourneyService, bizCoreService, $scope, $rootScope, $timeout) { var vm = this; vm.journeyToShow = {}; vm.isSpecificJourneyEnabled = false; vm.GetDirection = GetDirection; vm.Init = Init; vm.GetItemIcon = bizJourneyService.GetItemIcon; vm.GoToEngageItem = bizJourneyService.GoToEngageItem; vm.GetItemWidth = GetItemWidth; vm.HasPrevEobj = HasPrevEobj; vm.HasMoreEobj = HasMoreEobj; vm.IsCurrentItem = IsCurrentItem; vm.GetJourneySettings = GetJourneySettings; function GetJourneySettings() { bizJourneyService.GetJourneySettings().then(GetJourneySettingsCallback); function GetJourneySettingsCallback(response) { vm.JourneySettings = response.data; } } function IsCurrentItem(item) { if (vm.mini && vm.item && vm.item.Id !== undefined) { if (vm.item.EngageObjectType < 1 && vm.typeName) vm.item.EngageObjectType = bizJourneyService.GetItemIdByName(vm.typeName); if (item.Id == vm.item.Id && item.EngageObjectType == vm.item.EngageObjectType) return true; } return false; } function HasMoreEobj(item) { if (vm.mini && item && vm.journeyToShow.EngageObjects[vm.journeyToShow.EngageObjects.length - 1].Id != item.Id) { return true; } return false; } function HasPrevEobj(item) { if (vm.mini && item && vm.journeyToShow.EngageObjects[0].Id != item.Id) { return true; } return false; } function GetItemWidth() { return 100 / vm.itemsPerRow; } function GetDirection(index) { if(index >= 1 || vm.mini) return "top"; else return "bottom"; } function HandleJourneyData() { vm.journeyToShow = angular.copy(vm.journey); if (vm.miniSettings && vm.miniSettings.ShowOwnTypeOnly) { var objectType = bizJourneyService.GetItemIdByName(vm.miniSettings.ItemType); vm.journeyToShow.EngageObjects = vm.journeyToShow.EngageObjects.GetItemsByValue('EngageObjectType', objectType); } vm.journeyToShow.EngageObjectsDone = []; if(!vm.isSpecificJourneyEnabled) { for(var x = 0; x < vm.journeyToShow.EngageObjects.length; x++) { if(vm.journeyToShow.EngageObjects[x].Status == 3) { vm.journeyToShow.EngageObjectsDone.push(angular.copy(vm.journeyToShow.EngageObjects[x])); vm.journeyToShow.EngageObjects.splice(x, 1); x--; } } } var counter = 0; var index = 0; vm.journeyToShow.EObjects = []; if(!vm.isSpecificJourneyEnabled) { for(var x = 0; x < vm.journeyToShow.EngageObjectsDone.length; x++) { if(counter % vm.itemsPerRow == 0) { index = counter / vm.itemsPerRow; if(!vm.journeyToShow.EObjects[index]) { vm.journeyToShow.EObjects[index] = []; } } vm.journeyToShow.EngageObjectsDone[x].Index = counter + 1; vm.journeyToShow.EObjects[index].push(vm.journeyToShow.EngageObjectsDone[x]); counter++; } } var hasFoundFirstUnfinishedObject = false; var firstUnfinishedObjectIndex = -1; for(var x = 0; x < vm.journeyToShow.EngageObjects.length; x++) { if(counter % vm.itemsPerRow == 0) { index = counter / vm.itemsPerRow; if(!vm.journeyToShow.EObjects[index]) { vm.journeyToShow.EObjects[index] = []; } } if(!hasFoundFirstUnfinishedObject && vm.journeyToShow.EngageObjects[x].Status != 3) { vm.journeyToShow.EngageObjects[x].ShowProgressIndicator = true; hasFoundFirstUnfinishedObject = true; firstUnfinishedObjectIndex = x; } vm.journeyToShow.EngageObjects[x].Index = counter + 1; vm.journeyToShow.EObjects[index].push(vm.journeyToShow.EngageObjects[x]); counter++; } if (vm.mini && vm.journeyToShow.EngageObjects.length) { if (firstUnfinishedObjectIndex < 0) { firstUnfinishedObjectIndex = 0; for (var i = 0; i < vm.journeyToShow.EngageObjects.length; i++) { if (IsCurrentItem(vm.journeyToShow.EngageObjects[i])) { firstUnfinishedObjectIndex = i; } } } var miniList = [vm.journeyToShow.EngageObjects[firstUnfinishedObjectIndex]]; //console.log(firstUnfinishedObjectIndex); //console.log(miniList); var shift = 1; while (miniList.length < vm.itemsPerRow && miniList.length < vm.journeyToShow.EngageObjects.length) { var previous = firstUnfinishedObjectIndex - shift; var next = firstUnfinishedObjectIndex + shift; if (previous >= 0) miniList.unshift(vm.journeyToShow.EngageObjects[previous]); if (next < vm.journeyToShow.EngageObjects.length) miniList.push(vm.journeyToShow.EngageObjects[next]); shift++; } vm.journeyToShow.EObjects = [miniList]; } if ($rootScope.mobile && !vm.mini && firstUnfinishedObjectIndex > 0) { vm.scrollTo = 'journey-item-' + vm.journeyToShow.EngageObjects[firstUnfinishedObjectIndex].Id; } } function Init() { if (!vm.itemsPerRow) vm.itemsPerRow = 4; if (vm.miniSettings && vm.miniSettings.ItemCount) { vm.itemsPerRow = vm.miniSettings.ItemCount; } vm.mini = vm.miniSettings !== undefined; bizCoreService.GetPortalsetting("IsSpecificJourneyEnabled").then(GetPortalsettingSuccess); vm.GetJourneySettings(); } function GetPortalsettingSuccess(response) { vm.isSpecificJourneyEnabled = (response.data == 'True' || response.data === true ? true : false); HandleJourneyData(); } vm.$onInit = vm.Init; $scope.$on('engageobject.finished', function (event, params) { if (params) { for (var i = 0; i < vm.journey.EngageObjects.length; i++) { if (vm.journey.EngageObjects[i].Id === params.objectId && vm.journey.EngageObjects[i].EngageObjectType === params.objectType) { vm.journey.EngageObjects[i].Status = params.status; } } } vm.Init(); }); } return directive; } function bizJourneyShowOneGridDirective() { var directive = { restrict: "E", scope: { journey: "=" }, templateUrl: siteRootPath + "Js/AngularModules/BizPart/views/bizJourneyShowOneGrid.html", controller: bizJourneyShowOneGridController, controllerAs: "vm", bindToController: true }; bizJourneyShowOneGridController.$inject = ["$filter"]; function bizJourneyShowOneGridController($filter) { var vm = this; function Init() { vm.OnlineEducations = $filter('filter')(vm.journey.EngageObjects, {EngageObjectType: 1}, true); vm.Blogs = $filter('filter')(vm.journey.EngageObjects, {EngageObjectType: 2}, true); vm.Videos = $filter('filter')(vm.journey.EngageObjects, {EngageObjectType: 3}, true); //DO WE WANT HTML5 AND SCORM EDUCATIONS IN SAME OR SPLIT? var scormEducations = $filter('filter')(vm.journey.EngageObjects, {EngageObjectType: 4}, true); if(scormEducations.length > 0) vm.OnlineEducations.push(scormEducations); } vm.$onInit = Init; } return directive; } function bizJourneyShowOneCarouselDirective() { var directive = { restrict: "E", scope: { journey: "=" }, templateUrl: siteRootPath + "Js/AngularModules/BizPart/views/bizJourneyShowOneCarousel.html", controller: bizJourneyShowOneCarouselController, controllerAs: "vm", bindToController: true }; bizJourneyShowOneCarouselController.$inject = ["bizJourneyService", "$timeout"]; function bizJourneyShowOneCarouselController(bizJourneyService, $timeout) { var vm = this; vm.GetItemIcon = bizJourneyService.GetItemIcon; vm.GoToEngageItem = bizJourneyService.GoToEngageItem; vm.GoToFirstNew = GoToFirstNew; vm.Round = Round; function Round(i) { return Math.round(i); } function GoToFirstNew() { var firstNewIndex = -1; for (var i = 0; i < vm.journey.EngageObjects.length; i++) { if (vm.journey.EngageObjects[i].Status !== 3) { firstNewIndex = i; break; } } if (firstNewIndex < 0) firstNewIndex = vm.journey.EngageObjects.length - 1; if (firstNewIndex > 0) { $timeout(function () { $(vm.slickId).slick('slickGoTo', firstNewIndex); }, 1000); } } function Init() { vm.SlickSettings = { arrows: true, dots: false, infinite: false, slidesToShow: 6.5, slidesToScroll: 5, method: {}, customPaging: function () { return ''; }, responsive: [{ breakpoint: 960, settings: { slidesToShow: 2.2, slidesToScroll: 2 } }] } vm.slickId = "#journey-" + vm.journey.Id + "-slick"; $timeout(function () { vm.SlickDataLoaded = true; vm.GoToFirstNew(); }); } vm.$onInit = Init; } return directive; } function bizJourneyGridSlickDirective() { var directive = { restrict: "E", scope: { engageObjects: "=", typeName: "@?" }, templateUrl: siteRootPath + "Js/AngularModules/BizPart/views/bizJourneyGridSlick.html", controller: bizJourneyGridSlickController, controllerAs: "vm", bindToController: true }; bizJourneyGridSlickController.$inject = ["$state", "bizJourneyService"]; function bizJourneyGridSlickController($state, bizJourneyService) { var vm = this; vm.GetItemIcon = bizJourneyService.GetItemIcon; vm.GoToEngageItem = bizJourneyService.GoToEngageItem; function Init() { vm.SlickSettings = { arrows: true, dots: false, infinite: false, slidesToShow: 5, slidesToScroll: 5, customPaging: function () { return ''; }, responsive: [{ breakpoint: 960, settings: { slidesToShow: 2, slidesToScroll: 2 } }] } } vm.$onInit = Init; } return directive; } function bizJourneyButtonsDirective() { var directive = { restrict: "E", scope: { typeName: "@?", item: "=" }, templateUrl: siteRootPath + "Js/AngularModules/BizPart/views/bizJourneyNextOrPrev.html", controller: bizJourneyButtonsController, controllerAs: "vm", bindToController: true }; bizJourneyButtonsController.$inject = ["$rootScope", "bizJourneyService", "$scope", "$location", "anchorSmoothScroll", "$timeout"]; function bizJourneyButtonsController($rootScope, bizJourneyService, $scope, $location, anchorSmoothScroll, $timeout) { var vm = this; vm.Journeys = []; vm.ItemIdProperty = 'Id'; vm.ShowPrevButton = false; vm.ShowNextButton = false; vm.JourneyIsFinished = false; vm.IsInitialized = false; vm.GetItemIdProperty = GetItemIdProperty; vm.SetCurrentEOItemAndJourney = SetCurrentEOItemAndJourney; vm.GoToNextEngageItem = GoToNextEngageItem; vm.GoToPrevEngageItem = GoToPrevEngageItem; vm.EngageObjectFinishedEvent = EngageObjectFinishedEvent; vm.UpdateJourneyFinishedStatus = UpdateJourneyFinishedStatus; vm.UpdateEngageObjectStatusToFinished = UpdateEngageObjectStatusToFinished; vm.ShowFeedbackLink = ShowFeedbackLink; vm.SetNextJourney = SetNextJourney; vm.GoToNextJourney = GoToNextJourney; function GetItemIdProperty() { if (vm.typeName === 'Speedquiz') { return 'PluginInstanceId'; } return 'Id'; } function SetCurrentEOItemAndJourney() { if (!vm.item) return; var itemIdProperty = vm.GetItemIdProperty(); for (var i = 0; i < vm.Journeys.length; i++) { for (var j = 0; j < vm.Journeys[i].EngageObjects.length; j++) { if (vm.Journeys[i].EngageObjects[j].Id === vm.item[itemIdProperty]) { vm.CurrentEOItem = vm.Journeys[i].EngageObjects[j]; vm.CurrentJourney = vm.Journeys[i]; } } } } function GoToPrevEngageItem() { bizJourneyService.GoToNextEngageItem(vm.CurrentEOItem, vm.CurrentJourney.EngageObjects, false); } function GoToNextEngageItem() { bizJourneyService.GoToNextEngageItem(vm.CurrentEOItem, vm.CurrentJourney.EngageObjects, true, false); } function GoToNextJourney() { $rootScope.SetCurrentJourney(vm.NextJourney.Id, true); } var w = $scope.$watch('vm.item', function (newVal, oldVal) { if (newVal && newVal != oldVal) { if (newVal && newVal[vm.GetItemIdProperty()]) { vm.SetCurrentEOItemAndJourney(); HandleButtons(); } } }); function HandleButtons() { if (vm.item && vm.CurrentEOItem && vm.CurrentEOItem.Id > 0 && (vm.item.EngageObjectType > -1 || vm.typeName)) { w(); if (vm.item && vm.item.EngageObjectType < 1 && vm.typeName) vm.item.EngageObjectType = bizJourneyService.GetItemIdByName(vm.typeName); // Next btn var lastEo = vm.CurrentJourney.EngageObjects[vm.CurrentJourney.EngageObjects.length - 1]; if (lastEo.Id == vm.CurrentEOItem.Id && lastEo.EngageObjectType == vm.item.EngageObjectType) { } else { vm.ShowNextButton = true; } // Prev btn var firstEo = vm.CurrentJourney.EngageObjects[0]; if (firstEo.Id == vm.CurrentEOItem.Id && firstEo.EngageObjectType == vm.item.EngageObjectType) { } else { vm.ShowPrevButton = true; } vm.UpdateJourneyFinishedStatus(); if (!vm.ShowNextButton) { vm.SetNextJourney(); } } else { console.log('EngageObjectType cant be determined for', vm.item); } } function SetNextJourney() { var unfinishedJourneysAll = []; var unfinishedJourneysWHigherOrder = []; for (var i = 0; i < vm.Journeys.length; i++) { if (vm.Journeys[i].TotalProgress < 100 && vm.Journeys[i].Id !== vm.CurrentJourney.Id) { unfinishedJourneysAll.push(vm.Journeys[i]); if (vm.Journeys[i].Order > vm.CurrentJourney.Order) { unfinishedJourneysWHigherOrder.push(vm.Journeys[i]); } } } if (unfinishedJourneysWHigherOrder.length > 0) { vm.NextJourney = unfinishedJourneysWHigherOrder[0];//first one after } else if (unfinishedJourneysAll.length > 0) { vm.NextJourney = unfinishedJourneysAll[unfinishedJourneysAll.length - 1];//first one before...maybe not the best, but seems better than to always send to first } //saved in case needed later //var notStartedJourneys = []; //var startedJourneys = []; //var otherFinishedJourneys = []; ////console.log("journeys", vm.Journeys); //for (var i = 0; i < vm.Journeys.length; i++) { // var journey = vm.Journeys[i]; // if (!vm.CurrentJourney || vm.CurrentJourney.Id !== journey.Id) { // var anyStarted = false; // var anyNotFinished = false; // for (var j = 0; j < journey.EngageObjects.length; j++) { // var eoStatus = journey.EngageObjects[j].Status; // if (eoStatus >= 1) { // anyStarted = true; // } // if (eoStatus !== 3) { // anyNotFinished = true; // } // } // if (anyNotFinished == false) { // otherFinishedJourneys.push(journey); // } else if (anyStarted) { // startedJourneys.push(journey); // } else { // notStartedJourneys.push(journey); // } // } //} //vm.NotStartedJourneys = notStartedJourneys; //vm.StartedJourneys = startedJourneys; //vm.OtherFinishedJourneys = otherFinishedJourneys; //console.log("vm.NotStartedJourneys", vm.NotStartedJourneys) //console.log("vm.StartedJourneys", vm.StartedJourneys) //console.log("vm.OtherFinishedJourneys", vm.OtherFinishedJourneys) } function Init() { $rootScope.JourneysInitialized.then(InitJourneys); function InitJourneys() { vm.Journeys = $rootScope.Journeys; if (vm.Journeys.length > 0) { vm.SetCurrentEOItemAndJourney(); if (vm.CurrentEOItem && vm.CurrentEOItem.Id !== undefined) { HandleButtons(); vm.IsInitialized = true; } } } } function ShowFeedbackLink(afterFinishedEvent, stateChanged) { //bizJourneyService.GetJourneySettings().then(GetJourneySettingsCallback); //function GetJourneySettingsCallback(response) { // var journeySettings = response.data; // vm.FeedbackLink = journeySettings.FeedbackPage; // if (afterFinishedEvent && vm.item.EngageObjectType === 3) { // $location.hash('bizjourneybuttons'); // anchorSmoothScroll.scrollTo('bizjourneybuttons', 600, 1000); // } //} } function UpdateJourneyFinishedStatus(afterFinishedEvent) { if (!vm.Journeys || !vm.Journeys.length || !vm.CurrentJourney || !vm.CurrentJourney.EngageObjects) return false; if (vm.ShowNextButton) return;//if the current item is not the last one, none of this is needed var allFinished = true; for (var i = 0; i < vm.CurrentJourney.EngageObjects.length; i++) { if (vm.CurrentJourney.EngageObjects[i].Status !== 3) { allFinished = false; } } if (allFinished) { var stateChangedToFinished = allFinished && !vm.JourneyIsFinished; vm.JourneyIsFinished = allFinished; vm.ShowFeedbackLink(afterFinishedEvent, stateChangedToFinished) } } function UpdateEngageObjectStatusToFinished(objectId, objectType) { if (!vm.Journeys || !vm.Journeys.length || !vm.CurrentJourney || !vm.CurrentJourney.EngageObjects) return false; for (var i = 0; i < vm.CurrentJourney.EngageObjects.length; i++) { var eo = vm.CurrentJourney.EngageObjects[i]; if (eo.Id === objectId && eo.EngageObjectType === objectType) { eo.Status = 3; } } } function EngageObjectFinishedEvent(e, p) { if (!p.passed) return; vm.UpdateEngageObjectStatusToFinished(p.objectId, p.objectType); vm.UpdateJourneyFinishedStatus(true); } vm.$onInit = Init; $rootScope.$on('favorites.change', Init); $rootScope.$on('engageobject.finished', vm.EngageObjectFinishedEvent); } return directive; } function bizJourneyService($http, $state) { this.GetEngageJourneys = function() { return $http.get(siteRootPath + "api/engage/GetEngageJourneys?deepload=true"); }; this.GetEngageJourneysByFavoriteTags = function() { return $http.get(siteRootPath + "api/engage/GetEngageJourneysByFavoriteTags?deepload=true"); }; this.GetJourneySettings = function () { return $http.get(siteRootPath + "api/engage/GetGeneralJourneySettings"); }; this.GetJourneyDescription = function () { return $http.get(siteRootPath + "api/engage/GetJourneyDescription"); }; this.SetCurrentJourney = function (id) { return $http.post(siteRootPath + "api/engage/SetCurrentJourney", id); }; this.GoToNextEngageItem = function (currentItem, engageobjects, next, onlyUnfinished) { var goToItem = null; for (var i = 0; i < engageobjects.length; i++) { var currentEo = engageobjects[i]; if (currentItem.Id == currentEo.Id && currentItem.EngageObjectType == currentEo.EngageObjectType) { if (next && engageobjects.length > i) { goToItem = engageobjects[i + 1]; } else if (!next && i > 0) { goToItem = engageobjects[i - 1]; } this.GoToEngageItem(goToItem); break; } } }; this.GetItemIdByName = function (itemName) { switch (itemName) { case "HTML5": return 1; case "Blog": return 2; case "MediabankFile": return 3; case "SCORM": return 4; case "Speedquiz": return 5; case "Certification": return 6; case "Mission": return 7; } } this.GetItemIcon = function(item) { switch(item.EngageObjectType) { case 1: return "fa-graduation-cap" case 2: return "fa-newspaper-o" case 3: return "fa-play-circle-o" case 4: return "fa-graduation-cap" case 5: return "fas fa-gamepad" case 6: return "far fa-file-certificate"; case 7: return "fas fa-gamepad" } }; this.GoToEngageItem = function(item) { switch(item.EngageObjectType) { case 1: //console.log("going to education", item); $state.go('base.modules.html5education', { id: item.UrlRewrite || item.Id}); break; case 2: $state.go('base.modules.blogtitle', {title: item.UrlRewrite}); break; case 3: $state.go('base.modules.mediafile', {id: item.UrlRewrite || item.Id}); break; case 4: window.open(siteRootPath + 'scorm/' + item.Id); break; case 5: $state.go('base.modules.speedquizone', {urlRewrite: item.UrlRewrite, pluginInstanceId: item.Id}); break; case 6: $state.go('base.modules.certifications'); break; case 7: $state.go('base.modules.missionsview', {id: item.Id}); break; } }; } var htmlEnDeCode = (function() { var charToEntityRegex, entityToCharRegex, charToEntity, entityToChar; function resetCharacterEntities() { charToEntity = {}; entityToChar = {}; // add the default set addCharacterEntities({ '&' : '&', '>' : '>', '<' : '<', '"' : '"', ''' : "'" }); } function addCharacterEntities(newEntities) { var charKeys = [], entityKeys = [], key, echar; for (key in newEntities) { echar = newEntities[key]; entityToChar[key] = echar; charToEntity[echar] = key; charKeys.push(echar); entityKeys.push(key); } charToEntityRegex = new RegExp('(' + charKeys.join('|') + ')', 'g'); entityToCharRegex = new RegExp('(' + entityKeys.join('|') + '|&#[0-9]{1,5};' + ')', 'g'); } function htmlEncode(value){ var htmlEncodeReplaceFn = function(match, capture) { return charToEntity[capture]; }; return (!value) ? value : String(value).replace(charToEntityRegex, htmlEncodeReplaceFn); } function htmlDecode(value) { var htmlDecodeReplaceFn = function(match, capture) { return (capture in entityToChar) ? entityToChar[capture] : String.fromCharCode(parseInt(capture.substr(2), 10)); }; return (!value) ? value : String(value).replace(entityToCharRegex, htmlDecodeReplaceFn); } resetCharacterEntities(); return { htmlEncode: htmlEncode, htmlDecode: htmlDecode }; })(); (function (angular) { /* DIRECTIVES */ /* directive: bizVideo */ angular.module('bizPart').directive('bizBindElement', bizBindElementDirective); function bizBindElementDirective() { var directive = { restrict: 'A', link: linkFunction, scope: { bizBindElement: '=', bizBindElementOnBound: '&?' } }; function linkFunction(scope, element, attrs) { scope.bizBindElement = element[0]; scope.$watch('bizBindElement', function (element) { if (element && scope.bizBindElementOnBound) scope.bizBindElementOnBound({ $element: element }); }); } return directive; } /* directive: bizVideo */ angular.module('bizPart').directive('bizVideo', bizVideoDirective); function bizVideoDirective() { var directive = { restrict: "A", link: linkFunction, scope: { bizVideo: "=" } }; function linkFunction(scope, element, attrs) { scope.bizVideo = element[0]; } return directive; } /* directive/service: bizCodeEditor */ angular.module('bizPart').directive('bizCodeEditor', bizCodeEditor); angular.module('bizPart').service('bizCodeEditorService', bizCodeEditorService); bizCodeEditor.$inject = ["$sce", "$rootScope", "bizTextEditorService"]; bizCodeEditorService.$inject = ["$mdDialog"]; function bizCodeEditorService($mdDialog) { this.OpenEditorAsDialog = function (content, language) { return $mdDialog.show({ parent: angular.element(document.body), templateUrl: siteRootPath + 'Js/AngularModules/BizPart/views/bizCodeEditorDialog.html', controller: OpenEditorAsDialogController, controllerAs: "vm", bindToController: true, multiple: true, locals: { content, language } }, function () { console.log("closed without saving"); }); OpenEditorAsDialogController.$inject = ["$mdDialog"]; function OpenEditorAsDialogController($mdDialog) { var vm = this; vm.Language = language; vm.Content = content; vm.Save = Save; vm.Cancel = Cancel; function Cancel() { $mdDialog.hide(); } function Save() { $mdDialog.hide(vm.Content); } } }; } function bizCodeEditor($sce, $rootScope, bizTextEditorService) { var directive = { restrict: "EA", require: "ngModel", scope: { language: "@", }, link: monacoLink }; function monacoLink(scope, element, attrs, ngModel) { const id = bizTextEditorService.getUniqueId("ui-monaco"); attrs.$set('id', id); var editor = monaco.editor.create(document.getElementById(id), { language: scope.language, minimap: { enabled: false }, lineNumbers: 'off' }); editor.getModel().onDidChangeContent(function (event) { var content = editor.getValue(); content = $sce.trustAsHtml(content); ngModel.$setViewValue(content); if (!$rootScope.$$phase) { scope.$digest(); } }); ngModel.$formatters.unshift(function (modelValue) { return modelValue ? $sce.trustAsHtml(modelValue) : ''; }); ngModel.$parsers.unshift(function (viewValue) { return viewValue ? $sce.getTrustedHtml(viewValue) : ''; }); ngModel.$render = function () { var viewValue = ngModel.$viewValue ? $sce.getTrustedHtml(ngModel.$viewValue) : ''; editor.getModel().setValue(viewValue); } } return directive; } /* directive: bizTextEditor */ var useLegacyEditor = false; angular.module('bizPart').directive('bizTextEditor', bizTextEditor); angular.module('bizPart').service('bizTextEditorService', bizTextEditorService); bizTextEditor.$inject = ["bizMediabankService", "$filter", "$compile", "$timeout", "$rootScope", "$sce", "$q", "bizTextEditorService", "bizCodeEditorService"]; function bizTextEditorService() { var UITinymceService = function () { var ID_ATTR = 'ui-tinymce'; // uniqueId keeps track of the latest assigned ID var uniqueId = 0; // getUniqueId returns a unique ID var getUniqueId = function (nameOverride) { uniqueId++; var idAttr = nameOverride ? nameOverride : ID_ATTR; return idAttr + '-' + uniqueId; }; // return the function as a public method of the service return { getUniqueId: getUniqueId }; }; // return a new instance of the service return new UITinymceService(); } function bizTextEditor(bizMediabankService, $filter, $compile, $timeout, $rootScope, $sce, $q, bizTextEditorService, bizCodeEditorService) { var directive = { restrict: "EA", require: "ngModel", scope: { styles: "=?", fullpage: "=?", extraMenubarItems: "=?", inline: "=?", menuContainer: "=?", textOutline: "=?" }, link: useLegacyEditor ? tuiEditorLink : tinyEditorLink }; function tinyEditorLink(scope, element, attrs, ngModel) { const id = bizTextEditorService.getUniqueId(); console.log("id", id); attrs.$set('id', id); console.log("tiny styles", scope.style); var selector = "#" + id; var tinyInstance; var tinyInitialised = $q.defer(); var customMenu = {}; customMenu["bizpart"] = { title: 'Bizpart' }; var promiseWrapper = function (func, processResultFunc) { var defer = $q.defer(); func().then(function (data) { var dataToReturn = processResultFunc ? processResultFunc(data) : data; defer.resolve(dataToReturn); }); return defer.promise; }; var bizpartMenuItems = [ { itemName: 'bizimage', itemText: 'Image', order: 10, getContentPromise: function () { return promiseWrapper(function () { return bizMediabankService.ShowMediabankDialog(bizMediabankService.FileTypes.Image); }, function (file) { if (!file) return ''; return String.format('{1}', $filter("siteroot")(file.FileUrl), ""); }); } }, { itemName: 'bizvideo', itemText: 'Video', order: 11, getContentPromise: function () { return promiseWrapper(function () { return bizMediabankService.ShowMediabankDialog(bizMediabankService.FileTypes.Video); }, function (file) { if (!file) return ''; return '##VIDEO-' + file.Id + '-VIDEO##'; }); } }, { itemName: 'bizdoc', itemText: 'Document', order: 12, getContentPromise: function () { return promiseWrapper(function () { return bizMediabankService.ShowMediabankDialog(bizMediabankService.FileTypes.Document); }, function (file) { if (!file) return ''; return '##DOCUMENT-' + file.Id + '-DOCUMENT##'; }); } }, { itemName: 'bizfirstname', itemText: 'First name', content: '##FIRSTNAME##', order: 20 }, { itemName: 'bizlastname', itemText: 'Last name', content: '##LASTNAME##', order: 21 }, { itemName: 'bizfullname', itemText: 'Full name', content: '##FULLNAME##', order: 22 }, { itemName: 'bizcodeeditor', itemText: 'Source code', order: 9999, replaceContentPromise: function (content) { return promiseWrapper(function () { return bizCodeEditorService.OpenEditorAsDialog(content, 'html'); }, function (newContent) { return newContent; }); } } ]; if (IsPortalSettingTrue('IsLevelSystemEnabled')) { bizpartMenuItems.push( { itemName: 'bizlevel', itemText: 'Level', content: '##LEVEL##', order: 30 } ); bizpartMenuItems.push( { itemName: 'bizexperience', itemText: 'Experience', content: '##EXPERIENCE##', order: 31 } ) } if (scope.extraMenubarItems) { for (var i = 0; i < scope.extraMenubarItems.length; i++) { bizpartMenuItems.push({ itemName: scope.extraMenubarItems[i].itemName, itemText: scope.extraMenubarItems[i].itemText, content: scope.extraMenubarItems[i].content, getContentPromise: scope.extraMenubarItems[i].extraMenubarItems, order: scope.extraMenubarItems[i].order }); } } function updateView(editor) { var content = editor.getContent({ format: options.format }).trim(); content = $sce.trustAsHtml(content); ngModel.$setViewValue(content); if (!$rootScope.$$phase) { scope.$digest(); } }; function toggleDisable(disabled) { if (disabled) { ensureInstance(); if (tinyInstance) { tinyInstance.getBody().setAttribute('contenteditable', false); } } else { ensureInstance(); if (tinyInstance && !tinyInstance.options.readonly && tinyInstance.getDoc()) { tinyInstance.getBody().setAttribute('contenteditable', true); } } } function debounce(func, wait) { var debounceTimeout; return function () { var context = this; var args = arguments; var later = function () { debounceTimeout = null; func.apply(context, args); } $timeout.cancel(debounceTimeout); debounceTimeout = $timeout(later, wait); } } var debouncedUpdate = (function (debouncedUpdateDelay) { var debouncedUpdateTimer; return function (ed) { $timeout.cancel(debouncedUpdateTimer); debouncedUpdateTimer = $timeout(function () { return (function (ed) { if (ed.isDirty()) { ed.save(); updateView(ed); } })(ed); }, debouncedUpdateDelay); }; })(400); var debouncedReInitialize = debounce(function (middleFunction) { ensureInstance(); if (tinyInstance) { tinyInstance.remove(); } tinyInstance = null; if (middleFunction) { middleFunction(); } tinyInitialised = $q.defer(); console.log("reinit tiny") initialize(); }, 500); var options = { setup: function (ed) { ed.on('init', function () { ngModel.$render(); ngModel.$setPristine(); ngModel.$setUntouched(); }); ed.on('ExecCommand change NodeChange ObjectResized', function () { debouncedUpdate(ed); }); bizpartMenuItems.sort(function (a, b) { return a.order - b.order; }); var itemNames = []; for (var i = 0; i < bizpartMenuItems.length; i++) { var mi = bizpartMenuItems[i]; ed.ui.registry.addMenuItem(mi.itemName, { text: mi.itemText, onAction: (function (mi) { return function () { if (mi.content) { ed.insertContent(mi.content); } else if (mi.getContentPromise) { mi.getContentPromise().then(function (content) { ed.insertContent(content); }); } else if (mi.replaceContentPromise) { mi.replaceContentPromise(ed.getContent()).then(function (content) { if (content) { ed.setContent(content); updateView(ed); } }); } } })(mi) }); itemNames.push(mi.itemName); } customMenu['bizpart'].items = itemNames.join(' '); }, height: 400, selector, inline: scope.inline || false, convert_urls: false, paste_as_text: true, menu: customMenu, menubar: 'edit view insert format bizpart', toolbar: 'undo redo | formatselect | bold italic underline | alignleft aligncenter alignright alignjustify | forecolor backcolor removeformat | link | numlist bullist | emoticons' }; const pluginLoadList = ['link', 'lists', 'emoticons', 'code']; SetPlugins(); function SetPlugins() { SetPluginStatus('fullpage', scope.fullpage); options.plugins = pluginLoadList.join(" "); console.log("loading plugins", options.plugins); function SetPluginStatus(name, active) { var index = pluginLoadList.indexOf(name); if (active && index < 0) { pluginLoadList.push(name); } else if (!active && index >= 0) { pluginLoadList.splice(index, 1); } } } if (scope.fullpage) { options.plugins = options.plugins + ' fullpage'; } if (scope.menuContainer) { options.fixed_toolbar_container = scope.menuContainer; } scope.$watch(function () { return scope.fullpage; }, function (newVal, oldVal) { console.log("updating fullpage") if (newVal !== undefined && newVal !== oldVal) { console.log("updating fullpage changed") debouncedReInitialize(SetPlugins); } }); function GetBaseStyle() { if (scope.textOutline) { return 'body { -webkit-text-stroke: 0.3px #000; }'; } else { return ''; } } if (scope.styles) { function SetContentStyle() { var styleStr; if (typeof scope.styles === 'object') { styleStr = 'body {'; var props = Object.keys(scope.styles); for (var i = 0; i < props.length; i++) { var prop = props[i]; styleStr += ' ' + prop + ': ' + scope.styles[prop] + '; '; } styleStr += ' }'; } else { styleStr = scope.styles; } //console.log("setting styles", styleStr); styleStr = styleStr + ' ' + GetBaseStyle(); options.content_style = styleStr; } SetContentStyle(); scope.$watch(function () { return scope.styles; }, function (newVal, oldVal) { console.log("updating styles") if (newVal && newVal !== oldVal) { console.log("updating styles changed") debouncedReInitialize(SetContentStyle); } }); } else { options.content_style = GetBaseStyle(); } function initialize() { $timeout(function () { var maybeInitPromise = tinymce.init(options); if (maybeInitPromise && typeof maybeInitPromise.then === 'function') { maybeInitPromise.then(function () { tinyInitialised.resolve(''); toggleDisable(scope.$eval(attrs.ngDisabled)); }); } else { toggleDisable(scope.$eval(attrs.ngDisabled)); } }); } ngModel.$formatters.unshift(function (modelValue) { return modelValue ? $sce.trustAsHtml(modelValue) : ''; }); ngModel.$parsers.unshift(function (viewValue) { return viewValue ? $sce.getTrustedHtml(viewValue) : ''; }); ngModel.$render = function () { ensureInstance(); var viewValue = ngModel.$viewValue ? $sce.getTrustedHtml(ngModel.$viewValue) : ''; tinyInitialised.promise.then(function () { if (tinyInstance && tinyInstance.getDoc()) { tinyInstance.setContent(viewValue); //tinyInstance.fire('change'); } else { console.log("content could not be set") } }); } scope.$on('$destroy', function () { console.log("destroying tiny") ensureInstance(); if (tinyInstance) { tinyInstance.remove(); tinyInstance = null; } }); function ensureInstance() { if (!tinyInstance) { tinyInstance = tinymce.get(attrs.id); } } initialize(); } function tuiEditorLink(scope, element, attrs, ngModel) { var toolbarItems = ['heading', 'bold', 'italic', 'hr', 'divider', 'ul', 'ol', 'table', 'link', 'divider', 'code', // 'task','quote','strike''code','codeblock','indent','outdent' ]; var bizCustomToolbarItems = [{ Name: "Image", Event: "bizimage", EventHandler: imageEventHandler, Class: "fa fa-image", Order: 1 }, { Name: "Video", Event: "bizvideo", EventHandler: videoEventHandler, Class: 'fa fa-video' }, { Name: "Document", Event: "bizdocument", EventHandler: docEventHandler, Class: 'fal fa-file-pdf' }, { Name: "First name", Event: "bizfirstname", Content: "##FIRSTNAME##", Class: "fal fa-user-tag", EventHandler: placeholderEventHandler }, { Name: "Last name", Event: "bizlastname", Content: "##LASTNAME##", Class: "far fa-user-tag", EventHandler: placeholderEventHandler }, { Name: "Full name", Event: "fullname", Content: "##FULLNAME##", Class: "fas fa-user-tag", EventHandler: placeholderEventHandler }]; if (IsPortalSettingTrue('IsLevelSystemEnabled')) { bizCustomToolbarItems.push({ Name: "Level", Event: "bizlevel", Content: "##LEVEL##", Class: "fa fa-trophy-alt", EventHandler: placeholderEventHandler }); bizCustomToolbarItems.push({ Name: "Experience", Event: "bizexperience", Content: "##EXPERIENCE##", Class: "fa fa-trophy", EventHandler: placeholderEventHandler }); } if (scope.extraMenubarItems) { console.log("adding extra toolbar items", scope.extraMenubarItems); for (var i = 0; i < scope.extraMenubarItems.length; i++) { scope.extraMenubarItems[i].EventHandler = localItemEventHandler; //legacy fix: scope.extraMenubarItems[i].Name = scope.extraMenubarItems[i].itemText; scope.extraMenubarItems[i].Event = scope.extraMenubarItems[i].itemName; scope.extraMenubarItems[i].Class = scope.extraMenubarItems[i].class; scope.extraMenubarItems[i].Order = scope.extraMenubarItems[i].order; bizCustomToolbarItems.push(scope.extraMenubarItems[i]); } } var editor = new tui.Editor({ el: element[0], initialEditType: 'wysiwyg', height: 'auto', intialValue: ngModel.$viewValue, hideModeSwitch: false, exts: ['colorSyntax', 'table'], toolbarItems: toolbarItems, events: { load: editorLoaded, change: editorValueChange } }); editor.on('pasteBefore', function (event) { var html = scope.prevPasteData.replace(/(?:\r\n|\r|\n)/g, '
'); event.$clipboardContainer.html(html); }); editor.on("paste", function (event) { scope.prevPasteData = event.data.clipboardData.getData('text') || ""; }); ngModel.$render = function () { editor.setHtml(ngModel.$modelValue); } var toolbar = editor.getUI().getToolbar(); for (var i = 0; i < bizCustomToolbarItems.length; i++) { createToolbarItem(bizCustomToolbarItems[i]); } $compile(element.find('.tui-editor-defaultUI-toolbar'))(scope); element.find(".te-editor").attr("ng-style", "style"); $compile(element.find(".te-editor"))(scope); function createToolbarItem(item) { editor.eventManager.addEventType(item.Event); editor.eventManager.listen(item.Event, createEventHandler(item)); if (!item.Button) item.Button = String.format('', item.Class); var button = $(item.Button); toolbar.addButton({ className: "", name: item.Name, event: item.Event, tooltip: item.Name, $el: button }); } function editorLoaded() { } function editorValueChange() { var html = editor.getHtml(); ngModel.$setViewValue(html); } function createEventHandler(item) { return function () { item.EventHandler(item); } } function reloadContent() { editor.setHtml(editor.getHtml()); } function insertHtml(html) { var fullHtml = editor.getHtml(); fullHtml = fullHtml + html; editor.setHtml(fullHtml); editorValueChange(); } function placeholderEventHandler(item) { editor.insertText(item.Content); } function localItemEventHandler(item) { if (item.GetContent) { item.GetContent().then(function (result) { editor.insertText(result); }); } else { editor.insertText(item.content); } if (item.Reload) { reloadContent(); } } function imageEventHandler(item) { bizMediabankService.ShowMediabankDialog(bizMediabankService.FileTypes.Image).then(function (file) { if (!file) return; editor.insertText(String.format('{1}', $filter("siteroot")(file.FileUrl), "")); reloadContent(); }); } function docEventHandler(item) { bizMediabankService.ShowMediabankDialog(bizMediabankService.FileTypes.Document).then(function (file) { if (!file) return; //directly creating a link here doesnt seem to work, html gets fucked up //editor.insertText(String.format('Link to file', $filter("siteroot")(file.FileUrl))); console.log("file", file); editor.insertText("##DOCUMENT-" + file.Id + "-DOCUMENT##");//get module guid somehow? to fix permissions in getfilehandler?? reloadContent(); }); } function videoEventHandler(item) { bizMediabankService.ShowMediabankDialog(bizMediabankService.FileTypes.Video).then(function (file) { if (!file) return; editor.insertText("##VIDEO-" + file.Id + "-VIDEO##"); }); } } return directive; } /* directive: bizTextViewer */ angular.module('bizPart').directive('bizTextViewer', bizTextViewer); bizTextViewer.$inject = ["bizPlaceholderService", "$compile", "$sce", "$timeout"]; function bizTextViewer(bizPlaceholderService, $compile, $sce, $timeout) { var directive = { restrict: "E", require: "ngModel", scope: { ngModel: "=", customPlaceholders: "=?", moduleGuid: "=?", containerRef: "=?" }, link: link }; function link(scope, element, attrs, ngModel) { var debounceTime = 1000; var timeout = null; var prevValue = null; ngModel.$render = function () { if (prevValue == htmlEnDeCode.htmlDecode(ngModel.$modelValue)) return; prevValue = htmlEnDeCode.htmlDecode(ngModel.$modelValue); if (!timeout) { element.html(bizPlaceholderService.ReplacePlaceholders(htmlEnDeCode.htmlDecode(ngModel.$modelValue), scope.customPlaceholders, scope.moduleGuid, scope.containerRef)); $compile(element.contents())(scope); timeout = $timeout(function () { timeout = null; }, debounceTime); return; } $timeout.cancel(timeout); timeout = $timeout(function () { element.html(bizPlaceholderService.ReplacePlaceholders(htmlEnDeCode.htmlDecode(ngModel.$modelValue), scope.customPlaceholders, scope.moduleGuid, scope.containerRef)); $compile(element.contents())(scope); timeout = null; }, debounceTime); } } return directive; } /* FILTERS */ /* filter: bizSumColumn*/ angular.module('bizPart').filter('bizSumColumn', function () { return function (collection, column) { var total = 0; collection.forEach(function (item) { total += parseFloat(item[column]); }); return total; }; }); /* SERVICES */ angular.module('bizPart').service('bizLazyLoadService', bizLazyLoadService); function bizLazyLoadService() { var lazyLoadEnabled = true; var lazyLoadChangeListeners = []; return { SetLazyLoadEnabled: SetLazyLoadEnabled, OnLazyLoadEnabledChange: OnLazyLoadEnabledChange }; function OnLazyLoadEnabledChange(fn, scope) { fn(lazyLoadEnabled); lazyLoadChangeListeners.push(fn); scope.$on('$destroy', function () { lazyLoadChangeListeners.Remove(fn); }); } function SetLazyLoadEnabled(enabled) { if (enabled == lazyLoadEnabled) return; lazyLoadEnabled = enabled; for (var i = 0; i < lazyLoadChangeListeners.length; i++) { lazyLoadChangeListeners[i](lazyLoadEnabled); } } } /* service: bizPlaceholderService */ angular.module('bizPart').service('bizPlaceholderService', bizPlaceholderService); bizPlaceholderService.$inject = ["$rootScope"]; function bizPlaceholderService($rootScope) { this.ReplacePlaceholders = function (text, customPlaceholders, moduleGuid, containerRef) { if (!text) return text; if (!this.Placeholders) { this.Placeholders = [ { Name: "Relative paths", Regex: /src="\//gmi, Content: 'src="' + siteRootPath }, { Name: "Icon", Regex: /##ICON-(.*?)-ICON##/gmi, Content: '' }, { Name: "Bold", Regex: /##B-(.*?)-B##/gmi, Content: '$1' }, { Name: "Bold 2", Regex: /##B-(.*?)##/gmi, Content: '$1' }, { Name: "Itallic", Regex: /##I-(.*?)##/gmi, Content: '$1' }, { Name: "Color", Regex: /##C(.*?)-(.*?)##/gmi, Content: '$2' }, { Name: "Link", Regex: /##LINK\$(.*?)\$(.*?)##(.*?)##LINK##/gmi, Content: '$3' }, { Name: "Heading 1", Regex: /##H1-(.*?)-H1##/gmi, Content: '

$1

' }, //This inline style should not be here /AF { Name: "Heading 2", Regex: /##H2-(.*?)-H2##/gmi, Content: '

$1

' }, //This inline style should not be here /AF { Name: "Heading 3", Regex: /##H3-(.*?)-H3##/gmi, Content: '

$1

' }, //This inline style should not be here /AF { Name: "Heading 4", Regex: /##H4-(.*?)-H4##/gmi, Content: '

$1

' }, //This inline style should not be here /AF { Name: "Heading 5", Regex: /##H5-(.*?)-H5##/gmi, Content: '
$1
' }, //This inline style should not be here /AF { Name: "Heading 6", Regex: /##H6-(.*?)-H6##/gmi, Content: '
$1
' }, //This inline style should not be here /AF { Name: "Mediabank Video", Regex: /##VIDEO-(.*?)-VIDEO##/gmi, Content: '' }, { Name: "Mediabank Document", Regex: /##DOCUMENT-(.*?)-DOCUMENT##/gmi, ContentFunc: GetMediabankDocumentLink }, { Name: "Experience", Regex: /##EXPERIENCE##/gmi, Content: $rootScope.LoggedInUser ? $rootScope.LoggedInUser.DefaultExperiencePoints : "" }, { Name: "Full name", Regex: /##FULLNAME##/gmi, Content: $rootScope.LoggedInUser ? $rootScope.LoggedInUser.FullName : "" }, { Name: "Firstname", Regex: /##FIRSTNAME##/gmi, Content: $rootScope.LoggedInUser ? $rootScope.LoggedInUser.FirstName : "" }, { Name: "Lastname", Regex: /##LASTNAME##/gmi, Content: $rootScope.LoggedInUser ? $rootScope.LoggedInUser.LastName : "" }, { Name: "Level", Regex: /##LEVEL##/gmi, Content: $rootScope.LoggedInUser && $rootScope.LoggedInUser.DefaultLevel ? $rootScope.LoggedInUser.DefaultLevel.Id : "" }, { Name: "Chain", Regex: /##CHAIN##/gmi, Content: $rootScope.LoggedInUser ? $rootScope.LoggedInUser.CustomerName : "" }, { Name: "Store", Regex: /##STORE##/gmi, Content: $rootScope.LoggedInUser ? $rootScope.LoggedInUser.CustomerParentName : "" } ]; } for (var i = 0; i < this.Placeholders.length; i++) { if (this.Placeholders[i].ContentFunc) { text = text.replace(this.Placeholders[i].Regex, this.Placeholders[i].ContentFunc(moduleGuid, containerRef)); } else { text = text.replace(this.Placeholders[i].Regex, this.Placeholders[i].Content); } } if (customPlaceholders) { for (var i = 0; i < customPlaceholders.length; i++) { text = text.replace(customPlaceholders[i].Regex, customPlaceholders[i].Content); } } return text; function GetMediabankDocumentLink(moduleGuid, containerRef) { var mediabankDocmentLink = ''; if (moduleGuid && containerRef) { mediabankDocmentLink = ''; } return mediabankDocmentLink; } } } })(window.angular) angular.module('bizSelect', ['ngSanitize']) .directive('bizSelect', ["$filter", "$timeout", function ($filter, $timeout) { return { restrict: "E", scope: { items: "=", selectedItem: "=", noSelectText: "@", orderBy: "@", filterDisabled: "=?", filter: "=?", propertyName: "=", disabled: '=?', disabledSearch: '=?', disableDefaultSelect: '=?', selectedItemChange: "&?", imagePropertyName: "=", selectionAriaLabelPhrase: "=?", image:"=" }, templateUrl: siteRootPath + 'Js/AngularModules/BizSelect/bizselect.html', link: function (scope, element, attrs) { scope.IsOpen = false; scope.Key = scope.propertyName ? scope.propertyName : "Name"; scope.ImageKey = scope.imagePropertyName ? scope.imagePropertyName : "Image"; scope.ImageAltPhraseKey = "ImageAltPhrase"; scope.ImageAltSelectedKey = "ImageAltSelected"; scope.searchFilter = {}; scope.searchFilter[scope.Key] = ""; scope.SelectedIndex = -1; scope.required = attrs.required != undefined && attrs.required !== false && attrs.required !== "false"; scope.formname = attrs.name; scope.GetSelectedAltText = function(item) { console.log("item", item); } scope.CheckItems = function () { if (scope.items && scope.items.length == 1 && !scope.disableDefaultSelect) scope.SelectItem(scope.items[0]); }; scope.Blur = function () { scope.IsOpen = false; scope.searchFilter[scope.Key] = ""; scope.SelectedIndex = -1; if (scope.$root.$$phase != '$apply' && scope.$root.$$phase != '$digest') { scope.$digest(); } }; scope.GetPlaceholder = function () { var regex = /(<([^>]+)>)/ig if (scope.noSelectText && scope.noSelectText != "" && (!scope.selectedItem || scope.selectedItem[scope.Key] == undefined)) return scope.noSelectText.replace(regex, " "); else if (scope.selectedItem && scope.selectedItem[scope.Key] != undefined) return scope.selectedItem[scope.Key].replace(regex, " "); }; scope.GetValue = function () { var regex = /(<([^>]+)>)/ig if (scope.noSelectText && scope.noSelectText != "" && (!scope.selectedItem || scope.selectedItem[scope.Key] == undefined)) return ""; else if (scope.selectedItem && scope.selectedItem[scope.Key] != undefined) return scope.selectedItem[scope.Key].replace(regex, " "); } scope.SelectNone = function () { scope.selectedItem = undefined; scope.Blur(); }; scope.SelectItem = function (item) { if (!item.Disabled) { scope.selectedItem = item; //console.log("selected item", item); scope.Blur(); } }; scope.$watch('selectedItem', function (newVal, oldVal) { if (newVal != scope.previous) { if (scope.selectedItemChange) scope.selectedItemChange({ newVal: newVal, oldVal: scope.previous }); scope.previous = newVal; //console.log("selected item", newVal); } }); scope.$watch('items', function (newVal, oldVal) { if (newVal != oldVal) scope.CheckItems(); }, true); scope.$watch('items', function (newVal, oldVal) { if (newVal != oldVal && (scope.orderBy && scope.orderBy != "")) scope.items = $filter('orderBy')(scope.items, scope.orderBy); }, true); $(element).find(".select").on('click', function () { if (scope.disabled) return; scope.IsOpen = !scope.IsOpen; if (!scope.disabledSearch) $(element).find("input").focus(); scope.$digest(); }); $(document).mouseup(function (e) { var container = $(element); if (!container.is(e.target) && container.has(e.target).length === 0) { scope.Blur(); } }); $(element).on('keyup', function (event) { if (event.keyCode == 40) { if (scope.SelectedIndex < $(element).find('ul li:not(.ng-hide)').length - 1) { scope.SelectedIndex++; $(element).find('ul li:not(.ng-hide)')[scope.SelectedIndex].focus(); } event.stopPropagation(); } else if (event.keyCode == 38) { if (scope.SelectedIndex > 0) { scope.SelectedIndex--; $(element).find('ul li:not(.ng-hide)')[scope.SelectedIndex].focus(); } event.stopPropagation(); } }); $(element).on('keydown', function (event) { if (event.keyCode == 40 || event.keyCode == 38) { event.stopPropagation(); return false; } }); scope.CheckItems(); LoadCss(siteRootPath + 'Js/AngularModules/BizSelect/bizselect.css'); } }; }]); (function (angular) { angular.module('bizWelcomeGuide', ['bizPart']); angular.module('bizWelcomeGuide').directive('bizSimpleWelcomeGuide', bizSimpleWelcomeGuide); angular.module('bizWelcomeGuide').directive('bizWelcomeGuideJourneySelector', bizWelcomeGuideJourneySelector); angular.module('bizWelcomeGuide').service('bizWelcomeGuideService', bizWelcomeGuideService); bizWelcomeGuideJourneySelector.$inject = ["bizCore"]; bizSimpleWelcomeGuide.$inject = ["bizCore"]; bizWelcomeGuideService.$inject = ["$http"]; function bizWelcomeGuideJourneySelector(bizCoreProvider) { var directive = { restrict: "E", scope: { }, templateUrl: function (element, attr) { if (attr.templateurl) { return siteRootPath + attr.templateurl; } else { return bizCoreProvider.getView('core.directives.welcomeguidejourneyselector', "Js/AngularModules/BizWelcomeGuide/WelcomeGuideJourneySelector.html"); } }, bindToController: true, controller: bizWelcomeGuideJourneySelectorController, controllerAs: "vm" }; bizWelcomeGuideJourneySelectorController.$inject = ["$rootScope", "bizWelcomeGuideService", "$q", "$attrs"]; function bizWelcomeGuideJourneySelectorController($rootScope, bizWelcomeGuideService, $q, $attrs) { var vm = this; vm.Init = Init; vm.SelectJourney = SelectJourney; vm.MaxJourneys = 99; function SelectJourney(journey) { vm.SelectedJourney = journey; $rootScope.$broadcast('WELCOMEGUIDE.SELECT_JOURNEY', journey); } function Init() { var qsPermFilter = getParameterByNameFromUrl('perms', location.href); var pList = []; pList.push($rootScope.JourneysInitialized); if (qsPermFilter) { qsPermFilter = decodeURI(qsPermFilter); pList.push(bizWelcomeGuideService.GetItemsByPermissionCombination(qsPermFilter)); } $q.all(pList).then((result) => { var filterJourneyCollectionIds; if (result.length > 1) { filterJourneyCollectionIds = BizPartCoreHelpers.getResponseValue(result[1]); } if ($attrs.max) { vm.MaxJourneys = ~~$attrs.max;//cant get this working via scope for textviewer :( } if ($attrs.col == 2) { vm.Wrap = true; } if ($rootScope.Journeys) { vm.Journeys = []; for (var i = 0; i < $rootScope.Journeys.length; i++) { var journey = $rootScope.Journeys[i]; if (!filterJourneyCollectionIds || filterJourneyCollectionIds.indexOf(journey.JourneyCollectionId) >= 0) { vm.Journeys.push(journey); } } } }); } vm.$onInit = vm.Init; } return directive; } function bizSimpleWelcomeGuide(bizCoreProvider) { var directive = { restrict: "E", scope: { pages: "=", key: "@" }, templateUrl: function (element, attr) { if (attr.templateurl) { return siteRootPath + attr.templateurl; } else { return bizCoreProvider.getView('core.directives.simplewelcomeguide', "Js/AngularModules/BizWelcomeGuide/SimpleWelcomeGuide.html"); } }, bindToController: true, controller: bizSimpleWelcomeGuideController, controllerAs: "vm" }; bizSimpleWelcomeGuideController.$inject = ["$rootScope", "$scope", "$timeout", "bizCoreService", "$filter", "$translate"]; function bizSimpleWelcomeGuideController($rootScope, $scope, $timeout, bizCoreService, $filter, $translate) { var vm = this; vm.Translations = []; vm.Init = Init; vm.LoadWelcomeGuide = LoadWelcomeGuide; vm.TriggerNext = TriggerNext; vm.TriggerPrev = TriggerPrev; vm.LoadCustomPlaceholders = LoadCustomPlaceholders; vm.SlickSettings = { autoplay: false, dots: false, arrows: false, infinite: false, mobileFirst: true, method: {} } function TriggerNext(last) { if (last) { $rootScope.$broadcast('WELCOMEGUIDE.COMPLETED', { SelectedJourney: vm.SelectedJourney, Key: vm.key }); } else { $timeout(function () { $("#welcome-guide-slick").slick('slickNext'); }); } } function TriggerPrev() { $timeout(function () { $("#welcome-guide-slick").slick('slickPrev'); }); } function LoadCustomPlaceholders() { vm.CustomPlaceholders = [ { Name: "Journey selection", Regex: /##JOURNEYSELECTION-COL(.*?)-MAX(.*?)##/gmi, Content: '' } ]; } function LoadWelcomeGuide() { if (vm.pages) { InitWelcomeGuide(); } else { const guideKey = vm.key ? vm.key : ''; bizCoreService.GetWelcomeGuide(guideKey).then(GetPagesCallback); function GetPagesCallback(response) { var data = JSON.parse(response.data); vm.pages = data?.pages; InitWelcomeGuide(); } } function InitWelcomeGuide() { $timeout(function () { vm.SlickDataLoaded = true; }); } } function Init() { $translate(['CORE.WELCOMEGUIDE.NEXTBTN', 'CORE.WELCOMEGUIDE.BACKBTN', 'CORE.WELCOMEGUIDE.COMPLETEBTN']).then(function (translations) { Object.entries(translations).forEach(([key, value]) => { if (key !== translations[key]) vm.Translations[key.split('.').pop()] = translations[key]; }); }); vm.LoadCustomPlaceholders(); vm.LogoUrl = $filter('siteroot')(portalSettings['logo']); vm.LoadWelcomeGuide(); $rootScope.$on('WELCOMEGUIDE.SELECT_JOURNEY', function (e, journey) { vm.SelectedJourney = journey; }); } vm.$onInit = vm.Init; } return directive; } function bizWelcomeGuideService($http) { this.GetItemsByPermissionCombination = function (combStr) { return $http.get(siteRootPath + "api/permission/GetItemsByPermissionCombination?key=JOURNEY_COLLECTION&permCombId=" + combStr); } } })(window.angular); (function (angular) { angular.module('bizReactWrapper', []); angular.module('bizReactWrapper').directive('bizReactWrapper', bizReactWrapper); bizReactWrapper.$inject = ['$rootScope']; function bizReactWrapper($rootScope) { return { restrict: 'A', scope: { params: '=?', }, link: reactWrapperLink, }; function reactWrapperLink(scope, element, attrs) { var vm = this; var elementId = element.attr('id'); console.log('reactWrapperLink', elementId); function LoadReactComponent() { console.log('LoadReactComponent', scope.params); const eventName = 'Load-' + elementId; document.dispatchEvent(new CustomEvent(eventName, { detail: { params: scope.params } })); } scope.$watch('params', function (newValue, oldValue) { if (newValue && newValue !== oldValue) { LoadReactComponent(); } }); scope.$on('$destroy', () => { const eventName = 'Unload-' + elementId; document.dispatchEvent(new CustomEvent(eventName, { detail: {} })); }); $rootScope.Initialized.then(() => { console.log('initialized bizreactwrapper'); LoadReactComponent(); }); } } })(window.angular); angular.module('bizPart').directive('bizGauge', bizGaugeDirective); bizGaugeDirective.$inject = []; function bizGaugeDirective() { var directive = { restrict: "E", scope: { min: "=", max: "=", val: "=", absoluteVal: "=", isReversed: "=?", badColor: "@?", goodColor: "@?", settings: "=?", lblFunction: "&?", lblFuncObj: "=?" }, templateUrl: siteRootPath + "Js/AngularModules/BizGauge/bizGauge.html", controller: bizGaugeController, controllerAs: "vm", bindToController: true }; bizGaugeController.$inject = ["$scope", "$timeout"]; function bizGaugeController($scope, $timeout) { var vm = this; vm.gaugeId = guid(); vm.gauge = undefined; function Init() { if(!vm.badColor) vm.badColor = "#f7aa38"; if(!vm.goodColor) vm.goodColor = "#5ee432"; if(!vm.settings) vm.settings = {}; $timeout(function(vm) { //Reset the element... document.getElementById(vm.gaugeId).innerHTML = ""; vm.gauge = Gauge( document.getElementById(vm.gaugeId), { min: vm.min, max: vm.max * 2, dialStartAngle: vm.settings.dialStartAngle || 180, dialEndAngle: vm.settings.dialEndAngle || 0, value: 0, viewBox: vm.settings.viewBox || "0 0 100 57", color: function (value) { //if(vm.isReversed) return vm.badColor; if (value < vm.max) { return vm.isReversed == true ? (vm.goodColor || "#5ee432") : (vm.badColor || "#f7aa38"); } else if (value >= vm.max) { return vm.isReversed == true ? (vm.badColor || "#f7aa38") : (vm.goodColor || "#5ee432"); } }, label: function(val) { if(vm.lblFunction ) { return vm.lblFunction()(vm.absoluteVal, vm.max, vm.lblFuncObj); } return Math.round(val) + "%"; }, textY: vm.settings.textY || 46.5, textX: vm.settings.textX || 50 } ); vm.gauge.setValueAnimated(vm.val, 1.5); }, 1, true, vm); $scope.$watch(function() { return vm.val; }, function(newVal, oldVal) { if(newVal) { vm.gauge.setValueAnimated(newVal, 1.5); } }); $scope.$watch('vm.isReversed', function(newVal, oldVal) { if(newVal !== undefined && newVal != oldVal) { Init(); } }); LoadCss(siteRootPath + 'Js/AngularModules/BizGauge/bizGauge.css'); } vm.$onInit = Init; } return directive; } /* global window, define, module */ (function(global, factory) { var Gauge = factory(global); if(typeof define === "function" && define.amd) { // AMD support define(function() {return Gauge;}); }else if(typeof module === "object" && module.exports) { // CommonJS support module.exports = Gauge; }else { // We are probably running in the browser global.Gauge = Gauge; } })(typeof window === "undefined" ? this : window, function(global, undefined) { var document = global.document, slice = Array.prototype.slice, requestAnimationFrame = (global.requestAnimationFrame || global.mozRequestAnimationFrame || global.webkitRequestAnimationFrame || global.msRequestAnimationFrame || function(cb) { return setTimeout(cb, 1000 / 60); }); // EXPERIMENTAL!! /** * Simplistic animation function for animating the gauge. That's all! * Options are: * { * duration: 1, // In seconds * start: 0, // The start value * end: 100, // The end value * step: function, // REQUIRED! The step function that will be passed the value and does something * easing: function // The easing function. Default is easeInOutCubic * } */ function Animation(options) { var duration = options.duration, currentIteration = 1, iterations = 60 * duration, start = options.start || 0, end = options.end, change = end - start, step = options.step, easing = options.easing || function easeInOutCubic(pos) { // https://github.com/danro/easing-js/blob/master/easing.js if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,3); return 0.5 * (Math.pow((pos-2),3) + 2); }; function animate() { var progress = currentIteration / iterations, value = change * easing(progress) + start; // console.log(progress + ", " + value); step(value, currentIteration); currentIteration += 1; if(progress < 1) { requestAnimationFrame(animate); } } // start! requestAnimationFrame(animate); } var Gauge = (function() { var SVG_NS = "http://www.w3.org/2000/svg"; var GaugeDefaults = { centerX: 50, centerY: 50 }; var defaultOptions = { dialRadius: 40, dialStartAngle: 135, dialEndAngle: 45, value: 0, max: 100, min: 0, valueDialClass: "value", valueClass: "value-text", dialClass: "dial", gaugeClass: "gauge", showValue: true, gaugeColor: null, label: function(val) {return Math.round(val);} }; function shallowCopy(/* source, ...targets*/) { var target = arguments[0], sources = slice.call(arguments, 1); sources.forEach(function(s) { for(var k in s) { if(s.hasOwnProperty(k)) { target[k] = s[k]; } } }); return target; } /** * A utility function to create SVG dom tree * @param {String} name The SVG element name * @param {Object} attrs The attributes as they appear in DOM e.g. stroke-width and not strokeWidth * @param {Array} children An array of children (can be created by this same function) * @return The SVG element */ function svg(name, attrs, children) { var elem = document.createElementNS(SVG_NS, name); for(var attrName in attrs) { elem.setAttribute(attrName, attrs[attrName]); } if(children) { children.forEach(function(c) { elem.appendChild(c); }); } return elem; } /** * Translates percentage value to angle. e.g. If gauge span angle is 180deg, then 50% * will be 90deg */ function getAngle(percentage, gaugeSpanAngle) { return percentage * gaugeSpanAngle / 100; } function normalize(value, min, limit) { var val = Number(value); if(val > limit) return limit; if(val < min) return min; return val; } function getValueInPercentage(value, min, max) { var newMax = max - min, newVal = value - min; return 100 * newVal / newMax; // var absMin = Math.abs(min); // return 100 * (absMin + value) / (max + absMin); } /** * Gets cartesian co-ordinates for a specified radius and angle (in degrees) * @param cx {Number} The center x co-oriinate * @param cy {Number} The center y co-ordinate * @param radius {Number} The radius of the circle * @param angle {Number} The angle in degrees * @return An object with x,y co-ordinates */ function getCartesian(cx, cy, radius, angle) { var rad = angle * Math.PI / 180; return { x: Math.round((cx + radius * Math.cos(rad)) * 1000) / 1000, y: Math.round((cy + radius * Math.sin(rad)) * 1000) / 1000 }; } // Returns start and end points for dial // i.e. starts at 135deg ends at 45deg with large arc flag // REMEMBER!! angle=0 starts on X axis and then increases clockwise function getDialCoords(radius, startAngle, endAngle) { var cx = GaugeDefaults.centerX, cy = GaugeDefaults.centerY; return { end: getCartesian(cx, cy, radius, endAngle), start: getCartesian(cx, cy, radius, startAngle) }; } /** * Creates a Gauge object. This should be called without the 'new' operator. Various options * can be passed for the gauge: * { * dialStartAngle: The angle to start the dial. MUST be greater than dialEndAngle. Default 135deg * dialEndAngle: The angle to end the dial. Default 45deg * radius: The gauge's radius. Default 400 * max: The maximum value of the gauge. Default 100 * value: The starting value of the gauge. Default 0 * label: The function on how to render the center label (Should return a value) * } * @param {Element} elem The DOM into which to render the gauge * @param {Object} opts The gauge options * @return a Gauge object */ return function Gauge(elem, opts) { opts = shallowCopy({}, defaultOptions, opts); var gaugeContainer = elem, limit = opts.max, min = opts.min, value = normalize(opts.value, min, limit), radius = opts.dialRadius, displayValue = opts.showValue, startAngle = opts.dialStartAngle, endAngle = opts.dialEndAngle, valueDialClass = opts.valueDialClass, valueTextClass = opts.valueClass, valueLabelClass = opts.valueLabelClass, dialClass = opts.dialClass, gaugeClass = opts.gaugeClass, gaugeColor = opts.color, textX = opts.textX, textY = opts.textY, gaugeValueElem, gaugeValuePath, label = opts.label, viewBox = opts.viewBox, instance; if(startAngle < endAngle) { console.log("WARN! startAngle < endAngle, Swapping"); var tmp = startAngle; startAngle = endAngle; endAngle = tmp; } function pathString(radius, startAngle, endAngle, largeArc) { var coords = getDialCoords(radius, startAngle, endAngle), start = coords.start, end = coords.end, largeArcFlag = typeof(largeArc) === "undefined" ? 1 : largeArc; return [ "M", start.x, start.y, "A", radius, radius, 0, largeArcFlag, 1, end.x, end.y ].join(" "); } function initializeGauge(elem) { gaugeValueElem = svg("text", { x: textX || 50, y: textY || 50, fill: "#999", "class": valueTextClass, "font-size": "100%", "font-family": "sans-serif", "font-weight": "normal", "text-anchor": "middle", "alignment-baseline": "middle", "dominant-baseline": "central" }); gaugeValuePath = svg("path", { "class": valueDialClass, fill: "none", stroke: "#666", "stroke-width": 2.5, d: pathString(radius, startAngle, startAngle) // value of 0 }); var angle = getAngle(100, 360 - Math.abs(startAngle - endAngle)); var flag = angle <= 180 ? 0 : 1; var gaugeElement = svg("svg", {"viewBox": viewBox || "0 0 100 100", "class": gaugeClass}, [ svg("path", { "class": dialClass, fill: "none", stroke: "#eee", "stroke-width": 2, d: pathString(radius, startAngle, endAngle, flag) }), gaugeValueElem, gaugeValuePath ] ); elem.appendChild(gaugeElement); } function updateGauge(theValue, frame) { var val = getValueInPercentage(theValue, min, limit), // angle = getAngle(val, 360 - Math.abs(endAngle - startAngle)), angle = getAngle(val, 360 - Math.abs(startAngle - endAngle)), // this is because we are using arc greater than 180deg flag = angle <= 180 ? 0 : 1; if(displayValue) { gaugeValueElem.textContent = label.call(opts, theValue); } gaugeValuePath.setAttribute("d", pathString(radius, startAngle, angle + startAngle, flag)); } function setGaugeColor(value, duration) { var c = gaugeColor.call(opts, value), dur = duration * 1000, pathTransition = "stroke " + dur + "ms ease"; // textTransition = "fill " + dur + "ms ease"; gaugeValuePath.style.stroke = c; gaugeValuePath.style["-webkit-transition"] = pathTransition; gaugeValuePath.style["-moz-transition"] = pathTransition; gaugeValuePath.style.transition = pathTransition; /* gaugeValueElem.style = [ "fill: " + c, "-webkit-transition: " + textTransition, "-moz-transition: " + textTransition, "transition: " + textTransition, ].join(";"); */ } instance = { setMaxValue: function(max) { limit = max; }, setValue: function(val) { value = normalize(val, min, limit); if(gaugeColor) { setGaugeColor(value, 0) } updateGauge(value); }, setValueAnimated: function(val, duration) { var oldVal = value; value = normalize(val, min, limit); if(oldVal === value) { return; } if(gaugeColor) { setGaugeColor(value, duration); } Animation({ start: oldVal || 0, end: value, duration: duration || 1, step: function(val, frame) { updateGauge(val, frame); } }); }, getValue: function() { return value; } }; initializeGauge(gaugeContainer); instance.setValue(value); return instance; }; })(); return Gauge; }); /** * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ /** * Implementing Drag and Drop functionality in AngularJS is easier than ever. * Demo: http://codef0rmer.github.com/angular-dragdrop/ * * @version 1.0.13 * * (c) 2013 Amit Gharat a.k.a codef0rmer - amitgharat.wordpress.com */ !function (e, a, t, n) { "use strict"; var i = a.module("ngDragDrop", []).service("ngDragDropService", ["$timeout", "$parse", "$q", function (r, l, o) { this.draggableScope = null, this.droppableScope = null, t("head").prepend(''), this.callEventCallback = function (e, a, n, i) { function r(a) { var n = -1 !== a.indexOf("(") ? a.indexOf("(") : a.length, i = -1 !== a.lastIndexOf(")") ? a.lastIndexOf(")") : a.length, r = a.substring(n + 1, i), o = -1 !== a.indexOf(".") ? a.substr(0, a.indexOf(".")) : null; return o = e[o] && "function" == typeof e[o].constructor ? o : null, { callback: a.substring(o && o.length + 1 || 0, n), args: t.map(r && r.split(",") || [], function (a) { return [l(a)(e)] }), constructor: o } } if (a) { var o = r(a), d = o.callback, s = o.constructor, p = [n, i].concat(o.args); return (e[d] || e[s][d]).apply(e[d] ? e : e[s], p) } }, this.invokeDrop = function (e, l, d, s) { var p, c, u, g = "", f = "", b = {}, h = {}, v = null, y = {}, x = {}, m = null, D = this.droppableScope, q = this.draggableScope, j = null, k = []; g = e.ngattr("ng-model"), f = l.ngattr("ng-model"), p = q.$eval(g), c = D.$eval(f), m = l.find("[jqyoui-draggable]:last,[data-jqyoui-draggable]:last"), h = D.$eval(l.attr("jqyoui-droppable") || l.attr("data-jqyoui-droppable")) || [], b = q.$eval(e.attr("jqyoui-draggable") || e.attr("data-jqyoui-draggable")) || [], b.index = this.fixIndex(q, b, p), h.index = this.fixIndex(D, h, c), v = a.isArray(p) ? b.index : null, y = a.isArray(p) ? p[v] : p, b.deepCopy && (y = a.copy(y)), x = a.isArray(c) && h && h.index !== n ? c[h.index] : a.isArray(c) ? {} : c, h.deepCopy && (x = a.copy(x)), b.beforeDrop && k.push(this.callEventCallback(q, b.beforeDrop, d, s)), o.all(k).then(a.bind(this, function () { if (b.insertInline && g === f) { if (b.index > h.index) { u = p[b.index]; for (var n = b.index; n > h.index; n--) c[n] = a.copy(c[n - 1]), c[n - 1] = {}, c[n][b.direction] = "left"; c[h.index] = u } else { u = p[b.index]; for (var n = b.index; n < h.index; n++) c[n] = a.copy(c[n + 1]), c[n + 1] = {}, c[n][b.direction] = "right"; c[h.index] = u } this.callEventCallback(D, h.onDrop, d, s) } else b.animate === !0 ? (j = e.clone(), j.css({ position: "absolute" }).css(e.offset()), t("body").append(j), e.addClass("angular-dragdrop-hide"), this.move(j, m.length > 0 ? m : l, null, "fast", h, function () { j.remove() }), this.move(m.length > 0 && !h.multiple ? m : [], e.parent("[jqyoui-droppable],[data-jqyoui-droppable]"), i.startXY, "fast", h, a.bind(this, function () { r(a.bind(this, function () { e.css({ position: "relative", left: "", top: "" }).removeClass("angular-dragdrop-hide"), m.css({ position: "relative", left: "", top: "", display: "none" === m.css("display") ? "" : m.css("display") }), this.mutateDraggable(q, h, b, g, f, x, e), this.mutateDroppable(D, h, b, f, y, v), this.callEventCallback(D, h.onDrop, d, s) })) }))) : r(a.bind(this, function () { this.mutateDraggable(q, h, b, g, f, x, e), this.mutateDroppable(D, h, b, f, y, v), this.callEventCallback(D, h.onDrop, d, s) })) }))["finally"](a.bind(this, function () { this.restore(e) })) }, this.move = function (a, t, i, r, l, o) { if (0 === a.length) return o && e.setTimeout(function () { o() }, 300), !1; var d = a.css("z-index"), s = a[l.containment || "offset"](), p = t.css("display"), c = t.hasClass("ng-hide"), u = t.hasClass("angular-dragdrop-hide"); null === i && t.length > 0 && ((t.attr("jqyoui-draggable") || t.attr("data-jqyoui-draggable")) !== n && t.ngattr("ng-model") !== n && t.is(":visible") && l && l.multiple ? (i = t[l.containment || "offset"](), l.stack === !1 ? i.left += t.outerWidth(!0) : i.top += t.outerHeight(!0)) : (c && t.removeClass("ng-hide"), u && t.removeClass("angular-dragdrop-hide"), i = t.css({ visibility: "hidden", display: "block" })[l.containment || "offset"](), t.css({ visibility: "", display: p }))), a.css({ position: "absolute", "z-index": 9999 }).css(s).animate(i, r, function () { c && t.addClass("ng-hide"), u && t.addClass("angular-dragdrop-hide"), a.css("z-index", d), o && o() }) }, this.mutateDroppable = function (e, t, n, i, r, o) { var d = e.$eval(i); e.dndDragItem = r, a.isArray(d) ? (t && t.index >= 0 ? d[t.index] = r : d.push(r), n && n.placeholder === !0 && (d[d.length - 1].jqyoui_pos = o)) : (l(i + " = dndDragItem")(e), n && n.placeholder === !0 && (d.jqyoui_pos = o)) }, this.mutateDraggable = function (e, t, i, r, o, d, s) { var p = a.equals(d, {}) || !d, c = e.$eval(r); e.dndDropItem = d, i && i.placeholder ? "keep" != i.placeholder && (a.isArray(c) && i.index !== n ? c[i.index] = d : l(r + " = dndDropItem")(e)) : a.isArray(c) ? p ? i && i.placeholder !== !0 && "keep" !== i.placeholder && c.splice(i.index, 1) : c[i.index] = d : (l(r + " = dndDropItem")(e), e.$parent && l(r + " = dndDropItem")(e.$parent)), this.restore(s) }, this.restore = function (e) { e.css({ "z-index": "", left: "", top: "" }) }, this.fixIndex = function (e, t, i) { if (t.applyFilter && a.isArray(i) && i.length > 0) { var r = e[t.applyFilter](), l = r[t.index], o = n; return i.forEach(function (e, t) { a.equals(e, l) && (o = t) }), o } return t.index } }]).directive("jqyouiDraggable", ["ngDragDropService", function (e) { return { require: "?jqyouiDroppable", restrict: "A", link: function (n, r, l) { var o, d, s, p, c = t(r), u = function (r, u) { r ? (o = n.$eval(c.attr("jqyoui-draggable") || c.attr("data-jqyoui-draggable")) || {}, d = n.$eval(l.jqyouiOptions) || {}, c.draggable({ disabled: !1 }).draggable(d).draggable({ start: function (a, r) { e.draggableScope = n, s = t(d.helper ? r.helper : this).css("z-index"), t(d.helper ? r.helper : this).css("z-index", 9999), i.startXY = t(this)[o.containment || "offset"](), e.callEventCallback(n, o.onStart, a, r) }, stop: function (a, i) { t(d.helper ? i.helper : this).css("z-index", s), e.callEventCallback(n, o.onStop, a, i) }, drag: function (a, t) { e.callEventCallback(n, o.onDrag, a, t) } })) : c.draggable({ disabled: !0 }), p && a.isDefined(r) && (a.equals(l.drag, "true") || a.equals(l.drag, "false")) && (p(), p = null) }; p = n.$watch(function () { return n.$eval(l.drag) }, u), u(), c.on("$destroy", function () { c.draggable({ disabled: !0 }).draggable("destroy") }) } } }]).directive("jqyouiDroppable", ["ngDragDropService", "$q", function (e, n) { return { restrict: "A", priority: 1, link: function (i, r, l) { var o, d, s, p = t(r), c = function (r, c) { r ? (o = i.$eval(t(p).attr("jqyoui-droppable") || t(p).attr("data-jqyoui-droppable")) || {}, d = i.$eval(l.jqyouiOptions) || {}, p.droppable({ disabled: !1 }).droppable(d).droppable({ over: function (a, t) { e.callEventCallback(i, o.onOver, a, t) }, out: function (a, t) { e.callEventCallback(i, o.onOut, a, t) }, drop: function (r, s) { var p = null; p = o.beforeDrop ? e.callEventCallback(i, o.beforeDrop, r, s) : function () { var e = n.defer(); return e.resolve(), e.promise }(), p.then(a.bind(this, function () { t(s.draggable).ngattr("ng-model") && l.ngModel ? (e.droppableScope = i, e.invokeDrop(t(s.draggable), t(this), r, s)) : e.callEventCallback(i, o.onDrop, r, s) }), function () { s.draggable.animate({ left: "", top: "" }, d.revertDuration || 0) }) } })) : p.droppable({ disabled: !0 }), s && a.isDefined(r) && (a.equals(l.drop, "true") || a.equals(l.drop, "false")) && (s(), s = null) }; s = i.$watch(function () { return i.$eval(l.drop) }, c), c(), p.on("$destroy", function () { p.droppable({ disabled: !0 }).droppable("destroy") }) } } }]); t.fn.ngattr = function (e, a) { var t = this[0]; return t.getAttribute(e) || t.getAttribute("data-" + e) } }(window, window.angular, window.jQuery); /** * angular-drag-and-drop-lists v2.1.0 * * Copyright (c) 2014 Marcel Juenemann marcel@juenemann.cc * Copyright (c) 2014-2017 Google Inc. * https://github.com/marceljuenemann/angular-drag-and-drop-lists * * License: MIT */ (function (dndLists) { // In standard-compliant browsers we use a custom mime type and also encode the dnd-type in it. // However, IE and Edge only support a limited number of mime types. The workarounds are described // in https://github.com/marceljuenemann/angular-drag-and-drop-lists/wiki/Data-Transfer-Design var MIME_TYPE = 'application/x-dnd'; var EDGE_MIME_TYPE = 'application/json'; var MSIE_MIME_TYPE = 'Text'; // All valid HTML5 drop effects, in the order in which we prefer to use them. var ALL_EFFECTS = ['move', 'copy', 'link']; /** * Use the dnd-draggable attribute to make your element draggable * * Attributes: * - dnd-draggable Required attribute. The value has to be an object that represents the data * of the element. In case of a drag and drop operation the object will be * serialized and unserialized on the receiving end. * - dnd-effect-allowed Use this attribute to limit the operations that can be performed. Valid * options are "move", "copy" and "link", as well as "all", "copyMove", * "copyLink" and "linkMove". The semantics of these operations are up to you * and have to be implemented using the callbacks described below. If you * allow multiple options, the user can choose between them by using the * modifier keys (OS specific). The cursor will be changed accordingly, * expect for IE and Edge, where this is not supported. * - dnd-type Use this attribute if you have different kinds of items in your * application and you want to limit which items can be dropped into which * lists. Combine with dnd-allowed-types on the dnd-list(s). This attribute * must be a lower case string. Upper case characters can be used, but will * be converted to lower case automatically. * - dnd-disable-if You can use this attribute to dynamically disable the draggability of the * element. This is useful if you have certain list items that you don't want * to be draggable, or if you want to disable drag & drop completely without * having two different code branches (e.g. only allow for admins). * * Callbacks: * - dnd-dragstart Callback that is invoked when the element was dragged. The original * dragstart event will be provided in the local event variable. * - dnd-moved Callback that is invoked when the element was moved. Usually you will * remove your element from the original list in this callback, since the * directive is not doing that for you automatically. The original dragend * event will be provided in the local event variable. * - dnd-copied Same as dnd-moved, just that it is called when the element was copied * instead of moved, so you probably want to implement a different logic. * - dnd-linked Same as dnd-moved, just that it is called when the element was linked * instead of moved, so you probably want to implement a different logic. * - dnd-canceled Callback that is invoked if the element was dragged, but the operation was * canceled and the element was not dropped. The original dragend event will * be provided in the local event variable. * - dnd-dragend Callback that is invoked when the drag operation ended. Available local * variables are event and dropEffect. * - dnd-selected Callback that is invoked when the element was clicked but not dragged. * The original click event will be provided in the local event variable. * - dnd-callback Custom callback that is passed to dropzone callbacks and can be used to * communicate between source and target scopes. The dropzone can pass user * defined variables to this callback. * * CSS classes: * - dndDragging This class will be added to the element while the element is being * dragged. It will affect both the element you see while dragging and the * source element that stays at it's position. Do not try to hide the source * element with this class, because that will abort the drag operation. * - dndDraggingSource This class will be added to the element after the drag operation was * started, meaning it only affects the original element that is still at * it's source position, and not the "element" that the user is dragging with * his mouse pointer. */ dndLists.directive('dndDraggable', ['$parse', '$timeout', function ($parse, $timeout) { return function (scope, element, attr) { // Set the HTML5 draggable attribute on the element. element.attr("draggable", "true"); // If the dnd-disable-if attribute is set, we have to watch that. if (attr.dndDisableIf) { scope.$watch(attr.dndDisableIf, function (disabled) { element.attr("draggable", !disabled); }); } /** * When the drag operation is started we have to prepare the dataTransfer object, * which is the primary way we communicate with the target element */ element.on('dragstart', function (event) { event = event.originalEvent || event; // Check whether the element is draggable, since dragstart might be triggered on a child. if (element.attr('draggable') == 'false') return true; // Initialize global state. dndState.isDragging = true; dndState.itemType = attr.dndType && scope.$eval(attr.dndType).toLowerCase(); // Set the allowed drop effects. See below for special IE handling. dndState.dropEffect = "none"; dndState.effectAllowed = attr.dndEffectAllowed || ALL_EFFECTS[0]; event.dataTransfer.effectAllowed = dndState.effectAllowed; // Internet Explorer and Microsoft Edge don't support custom mime types, see design doc: // https://github.com/marceljuenemann/angular-drag-and-drop-lists/wiki/Data-Transfer-Design var item = scope.$eval(attr.dndDraggable); var mimeType = MIME_TYPE + (dndState.itemType ? ('-' + dndState.itemType) : ''); try { event.dataTransfer.setData(mimeType, angular.toJson(item)); } catch (e) { // Setting a custom MIME type did not work, we are probably in IE or Edge. var data = angular.toJson({ item: item, type: dndState.itemType }); try { event.dataTransfer.setData(EDGE_MIME_TYPE, data); } catch (e) { // We are in Internet Explorer and can only use the Text MIME type. Also note that IE // does not allow changing the cursor in the dragover event, therefore we have to choose // the one we want to display now by setting effectAllowed. var effectsAllowed = filterEffects(ALL_EFFECTS, dndState.effectAllowed); event.dataTransfer.effectAllowed = effectsAllowed[0]; event.dataTransfer.setData(MSIE_MIME_TYPE, data); } } // Add CSS classes. See documentation above. element.addClass("dndDragging"); $timeout(function () { element.addClass("dndDraggingSource"); }, 0); // Try setting a proper drag image if triggered on a dnd-handle (won't work in IE). if (event._dndHandle && event.dataTransfer.setDragImage) { event.dataTransfer.setDragImage(element[0], 0, 0); } // Invoke dragstart callback and prepare extra callback for dropzone. $parse(attr.dndDragstart)(scope, { event: event }); if (attr.dndCallback) { var callback = $parse(attr.dndCallback); dndState.callback = function (params) { return callback(scope, params || {}); }; } event.stopPropagation(); }); /** * The dragend event is triggered when the element was dropped or when the drag * operation was aborted (e.g. hit escape button). Depending on the executed action * we will invoke the callbacks specified with the dnd-moved or dnd-copied attribute. */ element.on('dragend', function (event) { event = event.originalEvent || event; // Invoke callbacks. Usually we would use event.dataTransfer.dropEffect to determine // the used effect, but Chrome has not implemented that field correctly. On Windows // it always sets it to 'none', while Chrome on Linux sometimes sets it to something // else when it's supposed to send 'none' (drag operation aborted). scope.$apply(function () { var dropEffect = dndState.dropEffect; var cb = { copy: 'dndCopied', link: 'dndLinked', move: 'dndMoved', none: 'dndCanceled' }; $parse(attr[cb[dropEffect]])(scope, { event: event }); $parse(attr.dndDragend)(scope, { event: event, dropEffect: dropEffect }); }); // Clean up dndState.isDragging = false; dndState.callback = undefined; element.removeClass("dndDragging"); element.removeClass("dndDraggingSource"); event.stopPropagation(); // In IE9 it is possible that the timeout from dragstart triggers after the dragend handler. $timeout(function () { element.removeClass("dndDraggingSource"); }, 0); }); /** * When the element is clicked we invoke the callback function * specified with the dnd-selected attribute. */ element.on('click', function (event) { if (!attr.dndSelected) return; event = event.originalEvent || event; scope.$apply(function () { $parse(attr.dndSelected)(scope, { event: event }); }); // Prevent triggering dndSelected in parent elements. event.stopPropagation(); }); /** * Workaround to make element draggable in IE9 */ element.on('selectstart', function () { if (this.dragDrop) this.dragDrop(); }); }; }]); /** * Use the dnd-list attribute to make your list element a dropzone. Usually you will add a single * li element as child with the ng-repeat directive. If you don't do that, we will not be able to * position the dropped element correctly. If you want your list to be sortable, also add the * dnd-draggable directive to your li element(s). * * Attributes: * - dnd-list Required attribute. The value has to be the array in which the data of * the dropped element should be inserted. The value can be blank if used * with a custom dnd-drop handler that always returns true. * - dnd-allowed-types Optional array of allowed item types. When used, only items that had a * matching dnd-type attribute will be dropable. Upper case characters will * automatically be converted to lower case. * - dnd-effect-allowed Optional string expression that limits the drop effects that can be * performed in the list. See dnd-effect-allowed on dnd-draggable for more * details on allowed options. The default value is all. * - dnd-disable-if Optional boolean expresssion. When it evaluates to true, no dropping * into the list is possible. Note that this also disables rearranging * items inside the list. * - dnd-horizontal-list Optional boolean expresssion. When it evaluates to true, the positioning * algorithm will use the left and right halfs of the list items instead of * the upper and lower halfs. * - dnd-external-sources Optional boolean expression. When it evaluates to true, the list accepts * drops from sources outside of the current browser tab. This allows to * drag and drop accross different browser tabs. The only major browser * that does not support this is currently Microsoft Edge. * * Callbacks: * - dnd-dragover Optional expression that is invoked when an element is dragged over the * list. If the expression is set, but does not return true, the element is * not allowed to be dropped. The following variables will be available: * - event: The original dragover event sent by the browser. * - index: The position in the list at which the element would be dropped. * - type: The dnd-type set on the dnd-draggable, or undefined if non was * set. Will be null for drops from external sources in IE and Edge, * since we don't know the type in those cases. * - dropEffect: One of move, copy or link, see dnd-effect-allowed. * - external: Whether the element was dragged from an external source. * - callback: If dnd-callback was set on the source element, this is a * function reference to the callback. The callback can be invoked with * custom variables like this: callback({var1: value1, var2: value2}). * The callback will be executed on the scope of the source element. If * dnd-external-sources was set and external is true, this callback will * not be available. * - dnd-drop Optional expression that is invoked when an element is dropped on the * list. The same variables as for dnd-dragover will be available, with the * exception that type is always known and therefore never null. There * will also be an item variable, which is the transferred object. The * return value determines the further handling of the drop: * - falsy: The drop will be canceled and the element won't be inserted. * - true: Signalises that the drop is allowed, but the dnd-drop * callback already took care of inserting the element. * - otherwise: All other return values will be treated as the object to * insert into the array. In most cases you want to simply return the * item parameter, but there are no restrictions on what you can return. * - dnd-inserted Optional expression that is invoked after a drop if the element was * actually inserted into the list. The same local variables as for * dnd-drop will be available. Note that for reorderings inside the same * list the old element will still be in the list due to the fact that * dnd-moved was not called yet. * * CSS classes: * - dndPlaceholder When an element is dragged over the list, a new placeholder child * element will be added. This element is of type li and has the class * dndPlaceholder set. Alternatively, you can define your own placeholder * by creating a child element with dndPlaceholder class. * - dndDragover Will be added to the list while an element is dragged over the list. */ dndLists.directive('dndList', ['$parse', function ($parse) { return function (scope, element, attr) { // While an element is dragged over the list, this placeholder element is inserted // at the location where the element would be inserted after dropping. var placeholder = getPlaceholderElement(); placeholder.remove(); var placeholderNode = placeholder[0]; var listNode = element[0]; var listSettings = {}; /** * The dragenter event is fired when a dragged element or text selection enters a valid drop * target. According to the spec, we either need to have a dropzone attribute or listen on * dragenter events and call preventDefault(). It should be noted though that no browser seems * to enforce this behaviour. */ element.on('dragenter', function (event) { event = event.originalEvent || event; // Calculate list properties, so that we don't have to repeat this on every dragover event. var types = attr.dndAllowedTypes && scope.$eval(attr.dndAllowedTypes); listSettings = { allowedTypes: angular.isArray(types) && types.join('|').toLowerCase().split('|'), disabled: attr.dndDisableIf && scope.$eval(attr.dndDisableIf), externalSources: attr.dndExternalSources && scope.$eval(attr.dndExternalSources), horizontal: attr.dndHorizontalList && scope.$eval(attr.dndHorizontalList) }; var mimeType = getMimeType(event.dataTransfer.types); if (!mimeType || !isDropAllowed(getItemType(mimeType))) return true; event.preventDefault(); }); /** * The dragover event is triggered "every few hundred milliseconds" while an element * is being dragged over our list, or over an child element. */ element.on('dragover', function (event) { event = event.originalEvent || event; // Check whether the drop is allowed and determine mime type. var mimeType = getMimeType(event.dataTransfer.types); var itemType = getItemType(mimeType); if (!mimeType || !isDropAllowed(itemType)) return true; // Make sure the placeholder is shown, which is especially important if the list is empty. if (placeholderNode.parentNode != listNode) { element.append(placeholder); } if (event.target != listNode) { // Try to find the node direct directly below the list node. var listItemNode = event.target; while (listItemNode.parentNode != listNode && listItemNode.parentNode) { listItemNode = listItemNode.parentNode; } if (listItemNode.parentNode == listNode && listItemNode != placeholderNode) { // If the mouse pointer is in the upper half of the list item element, // we position the placeholder before the list item, otherwise after it. var rect = listItemNode.getBoundingClientRect(); if (listSettings.horizontal) { var isFirstHalf = event.clientX < rect.left + rect.width / 2; } else { var isFirstHalf = event.clientY < rect.top + rect.height / 2; } if (isFirstHalf) { if (listItemNode.previousSibling != placeholderNode) listNode.insertBefore(placeholderNode, listItemNode); } else { if (listItemNode.nextSibling != placeholderNode) listNode.insertBefore(placeholderNode, listItemNode.nextSibling); } } } // In IE we set a fake effectAllowed in dragstart to get the correct cursor, we therefore // ignore the effectAllowed passed in dataTransfer. We must also not access dataTransfer for // drops from external sources, as that throws an exception. var ignoreDataTransfer = mimeType == MSIE_MIME_TYPE; var dropEffect = getDropEffect(event, ignoreDataTransfer); if (dropEffect == 'none') return stopDragover(); // At this point we invoke the callback, which still can disallow the drop. // We can't do this earlier because we want to pass the index of the placeholder. if (attr.dndDragover && !invokeCallback(attr.dndDragover, event, dropEffect, itemType)) { return stopDragover(); } // Set dropEffect to modify the cursor shown by the browser, unless we're in IE, where this // is not supported. This must be done after preventDefault in Firefox. event.preventDefault(); if (!ignoreDataTransfer) { event.dataTransfer.dropEffect = dropEffect; } element.addClass("dndDragover"); event.stopPropagation(); return false; }); /** * When the element is dropped, we use the position of the placeholder element as the * position where we insert the transferred data. This assumes that the list has exactly * one child element per array element. */ element.on('drop', function (event) { event = event.originalEvent || event; // Check whether the drop is allowed and determine mime type. var mimeType = getMimeType(event.dataTransfer.types); var itemType = getItemType(mimeType); if (!mimeType || !isDropAllowed(itemType)) return true; // The default behavior in Firefox is to interpret the dropped element as URL and // forward to it. We want to prevent that even if our drop is aborted. event.preventDefault(); // Unserialize the data that was serialized in dragstart. try { var data = JSON.parse(event.dataTransfer.getData(mimeType)); } catch (e) { return stopDragover(); } // Drops with invalid types from external sources might not have been filtered out yet. if (mimeType == MSIE_MIME_TYPE || mimeType == EDGE_MIME_TYPE) { itemType = data.type || undefined; data = data.item; if (!isDropAllowed(itemType)) return stopDragover(); } // Special handling for internal IE drops, see dragover handler. var ignoreDataTransfer = mimeType == MSIE_MIME_TYPE; var dropEffect = getDropEffect(event, ignoreDataTransfer); if (dropEffect == 'none') return stopDragover(); // Invoke the callback, which can transform the transferredObject and even abort the drop. var index = getPlaceholderIndex(); if (attr.dndDrop) { data = invokeCallback(attr.dndDrop, event, dropEffect, itemType, index, data); if (!data) return stopDragover(); } // The drop is definitely going to happen now, store the dropEffect. dndState.dropEffect = dropEffect; if (!ignoreDataTransfer) { event.dataTransfer.dropEffect = dropEffect; } // Insert the object into the array, unless dnd-drop took care of that (returned true). if (data !== true) { scope.$apply(function () { scope.$eval(attr.dndList).splice(index, 0, data); }); } invokeCallback(attr.dndInserted, event, dropEffect, itemType, index, data); // Clean up stopDragover(); event.stopPropagation(); return false; }); /** * We have to remove the placeholder when the element is no longer dragged over our list. The * problem is that the dragleave event is not only fired when the element leaves our list, * but also when it leaves a child element. Therefore, we determine whether the mouse cursor * is still pointing to an element inside the list or not. */ element.on('dragleave', function (event) { event = event.originalEvent || event; var newTarget = document.elementFromPoint(event.clientX, event.clientY); if (listNode.contains(newTarget) && !event._dndPhShown) { // Signalize to potential parent lists that a placeholder is already shown. event._dndPhShown = true; } else { stopDragover(); } }); /** * Given the types array from the DataTransfer object, returns the first valid mime type. * A type is valid if it starts with MIME_TYPE, or it equals MSIE_MIME_TYPE or EDGE_MIME_TYPE. */ function getMimeType(types) { if (!types) return MSIE_MIME_TYPE; // IE 9 workaround. for (var i = 0; i < types.length; i++) { if (types[i] == MSIE_MIME_TYPE || types[i] == EDGE_MIME_TYPE || types[i].substr(0, MIME_TYPE.length) == MIME_TYPE) { return types[i]; } } return null; } /** * Determines the type of the item from the dndState, or from the mime type for items from * external sources. Returns undefined if no item type was set and null if the item type could * not be determined. */ function getItemType(mimeType) { if (dndState.isDragging) return dndState.itemType || undefined; if (mimeType == MSIE_MIME_TYPE || mimeType == EDGE_MIME_TYPE) return null; return (mimeType && mimeType.substr(MIME_TYPE.length + 1)) || undefined; } /** * Checks various conditions that must be fulfilled for a drop to be allowed, including the * dnd-allowed-types attribute. If the item Type is unknown (null), the drop will be allowed. */ function isDropAllowed(itemType) { if (listSettings.disabled) return false; if (!listSettings.externalSources && !dndState.isDragging) return false; if (!listSettings.allowedTypes || itemType === null) return true; return itemType && listSettings.allowedTypes.indexOf(itemType) != -1; } /** * Determines which drop effect to use for the given event. In Internet Explorer we have to * ignore the effectAllowed field on dataTransfer, since we set a fake value in dragstart. * In those cases we rely on dndState to filter effects. Read the design doc for more details: * https://github.com/marceljuenemann/angular-drag-and-drop-lists/wiki/Data-Transfer-Design */ function getDropEffect(event, ignoreDataTransfer) { var effects = ALL_EFFECTS; if (!ignoreDataTransfer) { effects = filterEffects(effects, event.dataTransfer.effectAllowed); } if (dndState.isDragging) { effects = filterEffects(effects, dndState.effectAllowed); } if (attr.dndEffectAllowed) { effects = filterEffects(effects, attr.dndEffectAllowed); } // MacOS automatically filters dataTransfer.effectAllowed depending on the modifier keys, // therefore the following modifier keys will only affect other operating systems. if (!effects.length) { return 'none'; } else if (event.ctrlKey && effects.indexOf('copy') != -1) { return 'copy'; } else if (event.altKey && effects.indexOf('link') != -1) { return 'link'; } else { return effects[0]; } } /** * Small helper function that cleans up if we aborted a drop. */ function stopDragover() { placeholder.remove(); element.removeClass("dndDragover"); return true; } /** * Invokes a callback with some interesting parameters and returns the callbacks return value. */ function invokeCallback(expression, event, dropEffect, itemType, index, item) { return $parse(expression)(scope, { callback: dndState.callback, dropEffect: dropEffect, event: event, external: !dndState.isDragging, index: index !== undefined ? index : getPlaceholderIndex(), item: item || undefined, type: itemType }); } /** * We use the position of the placeholder node to determine at which position of the array the * object needs to be inserted */ function getPlaceholderIndex() { return Array.prototype.indexOf.call(listNode.children, placeholderNode); } /** * Tries to find a child element that has the dndPlaceholder class set. If none was found, a * new li element is created. */ function getPlaceholderElement() { var placeholder; angular.forEach(element.children(), function (childNode) { var child = angular.element(childNode); if (child.hasClass('dndPlaceholder')) { placeholder = child; } }); return placeholder || angular.element("
  • "); } }; }]); /** * Use the dnd-nodrag attribute inside of dnd-draggable elements to prevent them from starting * drag operations. This is especially useful if you want to use input elements inside of * dnd-draggable elements or create specific handle elements. Note: This directive does not work * in Internet Explorer 9. */ dndLists.directive('dndNodrag', function () { return function (scope, element, attr) { // Set as draggable so that we can cancel the events explicitly element.attr("draggable", "true"); /** * Since the element is draggable, the browser's default operation is to drag it on dragstart. * We will prevent that and also stop the event from bubbling up. */ element.on('dragstart', function (event) { event = event.originalEvent || event; if (!event._dndHandle) { // If a child element already reacted to dragstart and set a dataTransfer object, we will // allow that. For example, this is the case for user selections inside of input elements. if (!(event.dataTransfer.types && event.dataTransfer.types.length)) { event.preventDefault(); } event.stopPropagation(); } }); /** * Stop propagation of dragend events, otherwise dnd-moved might be triggered and the element * would be removed. */ element.on('dragend', function (event) { event = event.originalEvent || event; if (!event._dndHandle) { event.stopPropagation(); } }); }; }); /** * Use the dnd-handle directive within a dnd-nodrag element in order to allow dragging with that * element after all. Therefore, by combining dnd-nodrag and dnd-handle you can allow * dnd-draggable elements to only be dragged via specific "handle" elements. Note that Internet * Explorer will show the handle element as drag image instead of the dnd-draggable element. You * can work around this by styling the handle element differently when it is being dragged. Use * the CSS selector .dndDragging:not(.dndDraggingSource) [dnd-handle] for that. */ dndLists.directive('dndHandle', function () { return function (scope, element, attr) { element.attr("draggable", "true"); element.on('dragstart dragend', function (event) { event = event.originalEvent || event; event._dndHandle = true; }); }; }); /** * Filters an array of drop effects using a HTML5 effectAllowed string. */ function filterEffects(effects, effectAllowed) { if (effectAllowed == 'all') return effects; return effects.filter(function (effect) { return effectAllowed.toLowerCase().indexOf(effect) != -1; }); } /** * For some features we need to maintain global state. This is done here, with these fields: * - callback: A callback function set at dragstart that is passed to internal dropzone handlers. * - dropEffect: Set in dragstart to "none" and to the actual value in the drop handler. We don't * rely on the dropEffect passed by the browser, since there are various bugs in Chrome and * Safari, and Internet Explorer defaults to copy if effectAllowed is copyMove. * - effectAllowed: Set in dragstart based on dnd-effect-allowed. This is needed for IE because * setting effectAllowed on dataTransfer might result in an undesired cursor. * - isDragging: True between dragstart and dragend. Falsy for drops from external sources. * - itemType: The item type of the dragged element set via dnd-type. This is needed because IE * and Edge don't support custom mime types that we can use to transfer this information. */ var dndState = {}; })(angular.module('dndLists', [])); (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.tinycolor = factory()); })(this, (function () { 'use strict'; function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } // https://github.com/bgrins/TinyColor // Brian Grinstead, MIT License var trimLeft = /^\s+/; var trimRight = /\s+$/; function tinycolor(color, opts) { color = color ? color : ""; opts = opts || {}; // If input is already a tinycolor, return itself if (color instanceof tinycolor) { return color; } // If we are called as a function, call using new instead if (!(this instanceof tinycolor)) { return new tinycolor(color, opts); } var rgb = inputToRGB(color); this._originalInput = color, this._r = rgb.r, this._g = rgb.g, this._b = rgb.b, this._a = rgb.a, this._roundA = Math.round(100 * this._a) / 100, this._format = opts.format || rgb.format; this._gradientType = opts.gradientType; // Don't let the range of [0,255] come back in [0,1]. // Potentially lose a little bit of precision here, but will fix issues where // .5 gets interpreted as half of the total, instead of half of 1 // If it was supposed to be 128, this was already taken care of by `inputToRgb` if (this._r < 1) this._r = Math.round(this._r); if (this._g < 1) this._g = Math.round(this._g); if (this._b < 1) this._b = Math.round(this._b); this._ok = rgb.ok; } tinycolor.prototype = { isDark: function isDark() { return this.getBrightness() < 128; }, isLight: function isLight() { return !this.isDark(); }, isValid: function isValid() { return this._ok; }, getOriginalInput: function getOriginalInput() { return this._originalInput; }, getFormat: function getFormat() { return this._format; }, getAlpha: function getAlpha() { return this._a; }, getBrightness: function getBrightness() { //http://www.w3.org/TR/AERT#color-contrast var rgb = this.toRgb(); return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; }, getLuminance: function getLuminance() { //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef var rgb = this.toRgb(); var RsRGB, GsRGB, BsRGB, R, G, B; RsRGB = rgb.r / 255; GsRGB = rgb.g / 255; BsRGB = rgb.b / 255; if (RsRGB <= 0.03928) R = RsRGB / 12.92;else R = Math.pow((RsRGB + 0.055) / 1.055, 2.4); if (GsRGB <= 0.03928) G = GsRGB / 12.92;else G = Math.pow((GsRGB + 0.055) / 1.055, 2.4); if (BsRGB <= 0.03928) B = BsRGB / 12.92;else B = Math.pow((BsRGB + 0.055) / 1.055, 2.4); return 0.2126 * R + 0.7152 * G + 0.0722 * B; }, setAlpha: function setAlpha(value) { this._a = boundAlpha(value); this._roundA = Math.round(100 * this._a) / 100; return this; }, toHsv: function toHsv() { var hsv = rgbToHsv(this._r, this._g, this._b); return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a }; }, toHsvString: function toHsvString() { var hsv = rgbToHsv(this._r, this._g, this._b); var h = Math.round(hsv.h * 360), s = Math.round(hsv.s * 100), v = Math.round(hsv.v * 100); return this._a == 1 ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, " + this._roundA + ")"; }, toHsl: function toHsl() { var hsl = rgbToHsl(this._r, this._g, this._b); return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a }; }, toHslString: function toHslString() { var hsl = rgbToHsl(this._r, this._g, this._b); var h = Math.round(hsl.h * 360), s = Math.round(hsl.s * 100), l = Math.round(hsl.l * 100); return this._a == 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")"; }, toHex: function toHex(allow3Char) { return rgbToHex(this._r, this._g, this._b, allow3Char); }, toHexString: function toHexString(allow3Char) { return "#" + this.toHex(allow3Char); }, toHex8: function toHex8(allow4Char) { return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char); }, toHex8String: function toHex8String(allow4Char) { return "#" + this.toHex8(allow4Char); }, toRgb: function toRgb() { return { r: Math.round(this._r), g: Math.round(this._g), b: Math.round(this._b), a: this._a }; }, toRgbString: function toRgbString() { return this._a == 1 ? "rgb(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ")" : "rgba(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ", " + this._roundA + ")"; }, toPercentageRgb: function toPercentageRgb() { return { r: Math.round(bound01(this._r, 255) * 100) + "%", g: Math.round(bound01(this._g, 255) * 100) + "%", b: Math.round(bound01(this._b, 255) * 100) + "%", a: this._a }; }, toPercentageRgbString: function toPercentageRgbString() { return this._a == 1 ? "rgb(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%)" : "rgba(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")"; }, toName: function toName() { if (this._a === 0) { return "transparent"; } if (this._a < 1) { return false; } return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false; }, toFilter: function toFilter(secondColor) { var hex8String = "#" + rgbaToArgbHex(this._r, this._g, this._b, this._a); var secondHex8String = hex8String; var gradientType = this._gradientType ? "GradientType = 1, " : ""; if (secondColor) { var s = tinycolor(secondColor); secondHex8String = "#" + rgbaToArgbHex(s._r, s._g, s._b, s._a); } return "progid:DXImageTransform.Microsoft.gradient(" + gradientType + "startColorstr=" + hex8String + ",endColorstr=" + secondHex8String + ")"; }, toString: function toString(format) { var formatSet = !!format; format = format || this._format; var formattedString = false; var hasAlpha = this._a < 1 && this._a >= 0; var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name"); if (needsAlphaFormat) { // Special case for "transparent", all other non-alpha formats // will return rgba when there is transparency. if (format === "name" && this._a === 0) { return this.toName(); } return this.toRgbString(); } if (format === "rgb") { formattedString = this.toRgbString(); } if (format === "prgb") { formattedString = this.toPercentageRgbString(); } if (format === "hex" || format === "hex6") { formattedString = this.toHexString(); } if (format === "hex3") { formattedString = this.toHexString(true); } if (format === "hex4") { formattedString = this.toHex8String(true); } if (format === "hex8") { formattedString = this.toHex8String(); } if (format === "name") { formattedString = this.toName(); } if (format === "hsl") { formattedString = this.toHslString(); } if (format === "hsv") { formattedString = this.toHsvString(); } return formattedString || this.toHexString(); }, clone: function clone() { return tinycolor(this.toString()); }, _applyModification: function _applyModification(fn, args) { var color = fn.apply(null, [this].concat([].slice.call(args))); this._r = color._r; this._g = color._g; this._b = color._b; this.setAlpha(color._a); return this; }, lighten: function lighten() { return this._applyModification(_lighten, arguments); }, brighten: function brighten() { return this._applyModification(_brighten, arguments); }, darken: function darken() { return this._applyModification(_darken, arguments); }, desaturate: function desaturate() { return this._applyModification(_desaturate, arguments); }, saturate: function saturate() { return this._applyModification(_saturate, arguments); }, greyscale: function greyscale() { return this._applyModification(_greyscale, arguments); }, spin: function spin() { return this._applyModification(_spin, arguments); }, _applyCombination: function _applyCombination(fn, args) { return fn.apply(null, [this].concat([].slice.call(args))); }, analogous: function analogous() { return this._applyCombination(_analogous, arguments); }, complement: function complement() { return this._applyCombination(_complement, arguments); }, monochromatic: function monochromatic() { return this._applyCombination(_monochromatic, arguments); }, splitcomplement: function splitcomplement() { return this._applyCombination(_splitcomplement, arguments); }, // Disabled until https://github.com/bgrins/TinyColor/issues/254 // polyad: function (number) { // return this._applyCombination(polyad, [number]); // }, triad: function triad() { return this._applyCombination(polyad, [3]); }, tetrad: function tetrad() { return this._applyCombination(polyad, [4]); } }; // If input is an object, force 1 into "1.0" to handle ratios properly // String input requires "1.0" as input, so 1 will be treated as 1 tinycolor.fromRatio = function (color, opts) { if (_typeof(color) == "object") { var newColor = {}; for (var i in color) { if (color.hasOwnProperty(i)) { if (i === "a") { newColor[i] = color[i]; } else { newColor[i] = convertToPercentage(color[i]); } } } color = newColor; } return tinycolor(color, opts); }; // Given a string or object, convert that input to RGB // Possible string inputs: // // "red" // "#f00" or "f00" // "#ff0000" or "ff0000" // "#ff000000" or "ff000000" // "rgb 255 0 0" or "rgb (255, 0, 0)" // "rgb 1.0 0 0" or "rgb (1, 0, 0)" // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1" // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1" // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%" // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1" // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%" // function inputToRGB(color) { var rgb = { r: 0, g: 0, b: 0 }; var a = 1; var s = null; var v = null; var l = null; var ok = false; var format = false; if (typeof color == "string") { color = stringInputToObject(color); } if (_typeof(color) == "object") { if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) { rgb = rgbToRgb(color.r, color.g, color.b); ok = true; format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) { s = convertToPercentage(color.s); v = convertToPercentage(color.v); rgb = hsvToRgb(color.h, s, v); ok = true; format = "hsv"; } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) { s = convertToPercentage(color.s); l = convertToPercentage(color.l); rgb = hslToRgb(color.h, s, l); ok = true; format = "hsl"; } if (color.hasOwnProperty("a")) { a = color.a; } } a = boundAlpha(a); return { ok: ok, format: color.format || format, r: Math.min(255, Math.max(rgb.r, 0)), g: Math.min(255, Math.max(rgb.g, 0)), b: Math.min(255, Math.max(rgb.b, 0)), a: a }; } // Conversion Functions // -------------------- // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from: // // `rgbToRgb` // Handle bounds / percentage checking to conform to CSS color spec // // *Assumes:* r, g, b in [0, 255] or [0, 1] // *Returns:* { r, g, b } in [0, 255] function rgbToRgb(r, g, b) { return { r: bound01(r, 255) * 255, g: bound01(g, 255) * 255, b: bound01(b, 255) * 255 }; } // `rgbToHsl` // Converts an RGB color value to HSL. // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1] // *Returns:* { h, s, l } in [0,1] function rgbToHsl(r, g, b) { r = bound01(r, 255); g = bound01(g, 255); b = bound01(b, 255); var max = Math.max(r, g, b), min = Math.min(r, g, b); var h, s, l = (max + min) / 2; if (max == min) { h = s = 0; // achromatic } else { var d = max - min; s = l > 0.5 ? d / (2 - max - min) : d / (max + min); switch (max) { case r: h = (g - b) / d + (g < b ? 6 : 0); break; case g: h = (b - r) / d + 2; break; case b: h = (r - g) / d + 4; break; } h /= 6; } return { h: h, s: s, l: l }; } // `hslToRgb` // Converts an HSL color value to RGB. // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100] // *Returns:* { r, g, b } in the set [0, 255] function hslToRgb(h, s, l) { var r, g, b; h = bound01(h, 360); s = bound01(s, 100); l = bound01(l, 100); function hue2rgb(p, q, t) { if (t < 0) t += 1; if (t > 1) t -= 1; if (t < 1 / 6) return p + (q - p) * 6 * t; if (t < 1 / 2) return q; if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6; return p; } if (s === 0) { r = g = b = l; // achromatic } else { var q = l < 0.5 ? l * (1 + s) : l + s - l * s; var p = 2 * l - q; r = hue2rgb(p, q, h + 1 / 3); g = hue2rgb(p, q, h); b = hue2rgb(p, q, h - 1 / 3); } return { r: r * 255, g: g * 255, b: b * 255 }; } // `rgbToHsv` // Converts an RGB color value to HSV // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] // *Returns:* { h, s, v } in [0,1] function rgbToHsv(r, g, b) { r = bound01(r, 255); g = bound01(g, 255); b = bound01(b, 255); var max = Math.max(r, g, b), min = Math.min(r, g, b); var h, s, v = max; var d = max - min; s = max === 0 ? 0 : d / max; if (max == min) { h = 0; // achromatic } else { switch (max) { case r: h = (g - b) / d + (g < b ? 6 : 0); break; case g: h = (b - r) / d + 2; break; case b: h = (r - g) / d + 4; break; } h /= 6; } return { h: h, s: s, v: v }; } // `hsvToRgb` // Converts an HSV color value to RGB. // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100] // *Returns:* { r, g, b } in the set [0, 255] function hsvToRgb(h, s, v) { h = bound01(h, 360) * 6; s = bound01(s, 100); v = bound01(v, 100); var i = Math.floor(h), f = h - i, p = v * (1 - s), q = v * (1 - f * s), t = v * (1 - (1 - f) * s), mod = i % 6, r = [v, q, p, p, t, v][mod], g = [t, v, v, q, p, p][mod], b = [p, p, t, v, v, q][mod]; return { r: r * 255, g: g * 255, b: b * 255 }; } // `rgbToHex` // Converts an RGB color to hex // Assumes r, g, and b are contained in the set [0, 255] // Returns a 3 or 6 character hex function rgbToHex(r, g, b, allow3Char) { var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))]; // Return a 3 character hex if possible if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) { return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0); } return hex.join(""); } // `rgbaToHex` // Converts an RGBA color plus alpha transparency to hex // Assumes r, g, b are contained in the set [0, 255] and // a in [0, 1]. Returns a 4 or 8 character rgba hex function rgbaToHex(r, g, b, a, allow4Char) { var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16)), pad2(convertDecimalToHex(a))]; // Return a 4 character hex if possible if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) { return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0); } return hex.join(""); } // `rgbaToArgbHex` // Converts an RGBA color to an ARGB Hex8 string // Rarely used, but required for "toFilter()" function rgbaToArgbHex(r, g, b, a) { var hex = [pad2(convertDecimalToHex(a)), pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))]; return hex.join(""); } // `equals` // Can be called with any tinycolor input tinycolor.equals = function (color1, color2) { if (!color1 || !color2) return false; return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString(); }; tinycolor.random = function () { return tinycolor.fromRatio({ r: Math.random(), g: Math.random(), b: Math.random() }); }; // Modification Functions // ---------------------- // Thanks to less.js for some of the basics here // function _desaturate(color, amount) { amount = amount === 0 ? 0 : amount || 10; var hsl = tinycolor(color).toHsl(); hsl.s -= amount / 100; hsl.s = clamp01(hsl.s); return tinycolor(hsl); } function _saturate(color, amount) { amount = amount === 0 ? 0 : amount || 10; var hsl = tinycolor(color).toHsl(); hsl.s += amount / 100; hsl.s = clamp01(hsl.s); return tinycolor(hsl); } function _greyscale(color) { return tinycolor(color).desaturate(100); } function _lighten(color, amount) { amount = amount === 0 ? 0 : amount || 10; var hsl = tinycolor(color).toHsl(); hsl.l += amount / 100; hsl.l = clamp01(hsl.l); return tinycolor(hsl); } function _brighten(color, amount) { amount = amount === 0 ? 0 : amount || 10; var rgb = tinycolor(color).toRgb(); rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100)))); rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100)))); rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100)))); return tinycolor(rgb); } function _darken(color, amount) { amount = amount === 0 ? 0 : amount || 10; var hsl = tinycolor(color).toHsl(); hsl.l -= amount / 100; hsl.l = clamp01(hsl.l); return tinycolor(hsl); } // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue. // Values outside of this range will be wrapped into this range. function _spin(color, amount) { var hsl = tinycolor(color).toHsl(); var hue = (hsl.h + amount) % 360; hsl.h = hue < 0 ? 360 + hue : hue; return tinycolor(hsl); } // Combination Functions // --------------------- // Thanks to jQuery xColor for some of the ideas behind these // function _complement(color) { var hsl = tinycolor(color).toHsl(); hsl.h = (hsl.h + 180) % 360; return tinycolor(hsl); } function polyad(color, number) { if (isNaN(number) || number <= 0) { throw new Error("Argument to polyad must be a positive number"); } var hsl = tinycolor(color).toHsl(); var result = [tinycolor(color)]; var step = 360 / number; for (var i = 1; i < number; i++) { result.push(tinycolor({ h: (hsl.h + i * step) % 360, s: hsl.s, l: hsl.l })); } return result; } function _splitcomplement(color) { var hsl = tinycolor(color).toHsl(); var h = hsl.h; return [tinycolor(color), tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l }), tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l })]; } function _analogous(color, results, slices) { results = results || 6; slices = slices || 30; var hsl = tinycolor(color).toHsl(); var part = 360 / slices; var ret = [tinycolor(color)]; for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results;) { hsl.h = (hsl.h + part) % 360; ret.push(tinycolor(hsl)); } return ret; } function _monochromatic(color, results) { results = results || 6; var hsv = tinycolor(color).toHsv(); var h = hsv.h, s = hsv.s, v = hsv.v; var ret = []; var modification = 1 / results; while (results--) { ret.push(tinycolor({ h: h, s: s, v: v })); v = (v + modification) % 1; } return ret; } // Utility Functions // --------------------- tinycolor.mix = function (color1, color2, amount) { amount = amount === 0 ? 0 : amount || 50; var rgb1 = tinycolor(color1).toRgb(); var rgb2 = tinycolor(color2).toRgb(); var p = amount / 100; var rgba = { r: (rgb2.r - rgb1.r) * p + rgb1.r, g: (rgb2.g - rgb1.g) * p + rgb1.g, b: (rgb2.b - rgb1.b) * p + rgb1.b, a: (rgb2.a - rgb1.a) * p + rgb1.a }; return tinycolor(rgba); }; // Readability Functions // --------------------- // false // tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false tinycolor.isReadable = function (color1, color2, wcag2) { var readability = tinycolor.readability(color1, color2); var wcag2Parms, out; out = false; wcag2Parms = validateWCAG2Parms(wcag2); switch (wcag2Parms.level + wcag2Parms.size) { case "AAsmall": case "AAAlarge": out = readability >= 4.5; break; case "AAlarge": out = readability >= 3; break; case "AAAsmall": out = readability >= 7; break; } return out; }; // `mostReadable` // Given a base color and a list of possible foreground or background // colors for that base, returns the most readable color. // Optionally returns Black or White if the most readable color is unreadable. // *Example* // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255" // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff" // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3" // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff" tinycolor.mostReadable = function (baseColor, colorList, args) { var bestColor = null; var bestScore = 0; var readability; var includeFallbackColors, level, size; args = args || {}; includeFallbackColors = args.includeFallbackColors; level = args.level; size = args.size; for (var i = 0; i < colorList.length; i++) { readability = tinycolor.readability(baseColor, colorList[i]); if (readability > bestScore) { bestScore = readability; bestColor = tinycolor(colorList[i]); } } if (tinycolor.isReadable(baseColor, bestColor, { level: level, size: size }) || !includeFallbackColors) { return bestColor; } else { args.includeFallbackColors = false; return tinycolor.mostReadable(baseColor, ["#fff", "#000"], args); } }; // Big List of Colors // ------------------ // var names = tinycolor.names = { aliceblue: "f0f8ff", antiquewhite: "faebd7", aqua: "0ff", aquamarine: "7fffd4", azure: "f0ffff", beige: "f5f5dc", bisque: "ffe4c4", black: "000", blanchedalmond: "ffebcd", blue: "00f", blueviolet: "8a2be2", brown: "a52a2a", burlywood: "deb887", burntsienna: "ea7e5d", cadetblue: "5f9ea0", chartreuse: "7fff00", chocolate: "d2691e", coral: "ff7f50", cornflowerblue: "6495ed", cornsilk: "fff8dc", crimson: "dc143c", cyan: "0ff", darkblue: "00008b", darkcyan: "008b8b", darkgoldenrod: "b8860b", darkgray: "a9a9a9", darkgreen: "006400", darkgrey: "a9a9a9", darkkhaki: "bdb76b", darkmagenta: "8b008b", darkolivegreen: "556b2f", darkorange: "ff8c00", darkorchid: "9932cc", darkred: "8b0000", darksalmon: "e9967a", darkseagreen: "8fbc8f", darkslateblue: "483d8b", darkslategray: "2f4f4f", darkslategrey: "2f4f4f", darkturquoise: "00ced1", darkviolet: "9400d3", deeppink: "ff1493", deepskyblue: "00bfff", dimgray: "696969", dimgrey: "696969", dodgerblue: "1e90ff", firebrick: "b22222", floralwhite: "fffaf0", forestgreen: "228b22", fuchsia: "f0f", gainsboro: "dcdcdc", ghostwhite: "f8f8ff", gold: "ffd700", goldenrod: "daa520", gray: "808080", green: "008000", greenyellow: "adff2f", grey: "808080", honeydew: "f0fff0", hotpink: "ff69b4", indianred: "cd5c5c", indigo: "4b0082", ivory: "fffff0", khaki: "f0e68c", lavender: "e6e6fa", lavenderblush: "fff0f5", lawngreen: "7cfc00", lemonchiffon: "fffacd", lightblue: "add8e6", lightcoral: "f08080", lightcyan: "e0ffff", lightgoldenrodyellow: "fafad2", lightgray: "d3d3d3", lightgreen: "90ee90", lightgrey: "d3d3d3", lightpink: "ffb6c1", lightsalmon: "ffa07a", lightseagreen: "20b2aa", lightskyblue: "87cefa", lightslategray: "789", lightslategrey: "789", lightsteelblue: "b0c4de", lightyellow: "ffffe0", lime: "0f0", limegreen: "32cd32", linen: "faf0e6", magenta: "f0f", maroon: "800000", mediumaquamarine: "66cdaa", mediumblue: "0000cd", mediumorchid: "ba55d3", mediumpurple: "9370db", mediumseagreen: "3cb371", mediumslateblue: "7b68ee", mediumspringgreen: "00fa9a", mediumturquoise: "48d1cc", mediumvioletred: "c71585", midnightblue: "191970", mintcream: "f5fffa", mistyrose: "ffe4e1", moccasin: "ffe4b5", navajowhite: "ffdead", navy: "000080", oldlace: "fdf5e6", olive: "808000", olivedrab: "6b8e23", orange: "ffa500", orangered: "ff4500", orchid: "da70d6", palegoldenrod: "eee8aa", palegreen: "98fb98", paleturquoise: "afeeee", palevioletred: "db7093", papayawhip: "ffefd5", peachpuff: "ffdab9", peru: "cd853f", pink: "ffc0cb", plum: "dda0dd", powderblue: "b0e0e6", purple: "800080", rebeccapurple: "663399", red: "f00", rosybrown: "bc8f8f", royalblue: "4169e1", saddlebrown: "8b4513", salmon: "fa8072", sandybrown: "f4a460", seagreen: "2e8b57", seashell: "fff5ee", sienna: "a0522d", silver: "c0c0c0", skyblue: "87ceeb", slateblue: "6a5acd", slategray: "708090", slategrey: "708090", snow: "fffafa", springgreen: "00ff7f", steelblue: "4682b4", tan: "d2b48c", teal: "008080", thistle: "d8bfd8", tomato: "ff6347", turquoise: "40e0d0", violet: "ee82ee", wheat: "f5deb3", white: "fff", whitesmoke: "f5f5f5", yellow: "ff0", yellowgreen: "9acd32" }; // Make it easy to access colors via `hexNames[hex]` var hexNames = tinycolor.hexNames = flip(names); // Utilities // --------- // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }` function flip(o) { var flipped = {}; for (var i in o) { if (o.hasOwnProperty(i)) { flipped[o[i]] = i; } } return flipped; } // Return a valid alpha value [0,1] with all invalid values being set to 1 function boundAlpha(a) { a = parseFloat(a); if (isNaN(a) || a < 0 || a > 1) { a = 1; } return a; } // Take input from [0, n] and return it as [0, 1] function bound01(n, max) { if (isOnePointZero(n)) n = "100%"; var processPercent = isPercentage(n); n = Math.min(max, Math.max(0, parseFloat(n))); // Automatically convert percentage into number if (processPercent) { n = parseInt(n * max, 10) / 100; } // Handle floating point rounding errors if (Math.abs(n - max) < 0.000001) { return 1; } // Convert into [0, 1] range if it isn't already return n % max / parseFloat(max); } // Force a number between 0 and 1 function clamp01(val) { return Math.min(1, Math.max(0, val)); } // Parse a base-16 hex value into a base-10 integer function parseIntFromHex(val) { return parseInt(val, 16); } // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1 // function isOnePointZero(n) { return typeof n == "string" && n.indexOf(".") != -1 && parseFloat(n) === 1; } // Check to see if string passed in is a percentage function isPercentage(n) { return typeof n === "string" && n.indexOf("%") != -1; } // Force a hex value to have 2 characters function pad2(c) { return c.length == 1 ? "0" + c : "" + c; } // Replace a decimal with it's percentage value function convertToPercentage(n) { if (n <= 1) { n = n * 100 + "%"; } return n; } // Converts a decimal to a hex value function convertDecimalToHex(d) { return Math.round(parseFloat(d) * 255).toString(16); } // Converts a hex value to a decimal function convertHexToDecimal(h) { return parseIntFromHex(h) / 255; } var matchers = function () { // var CSS_INTEGER = "[-\\+]?\\d+%?"; // var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?"; // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome. var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")"; // Actual matching. // Parentheses and commas are optional, but not required. // Whitespace can take the place of commas or opening paren var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; return { CSS_UNIT: new RegExp(CSS_UNIT), rgb: new RegExp("rgb" + PERMISSIVE_MATCH3), rgba: new RegExp("rgba" + PERMISSIVE_MATCH4), hsl: new RegExp("hsl" + PERMISSIVE_MATCH3), hsla: new RegExp("hsla" + PERMISSIVE_MATCH4), hsv: new RegExp("hsv" + PERMISSIVE_MATCH3), hsva: new RegExp("hsva" + PERMISSIVE_MATCH4), hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/ }; }(); // `isValidCSSUnit` // Take in a single string / number and check to see if it looks like a CSS unit // (see `matchers` above for definition). function isValidCSSUnit(color) { return !!matchers.CSS_UNIT.exec(color); } // `stringInputToObject` // Permissive string parsing. Take in a number of formats, and output an object // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` function stringInputToObject(color) { color = color.replace(trimLeft, "").replace(trimRight, "").toLowerCase(); var named = false; if (names[color]) { color = names[color]; named = true; } else if (color == "transparent") { return { r: 0, g: 0, b: 0, a: 0, format: "name" }; } // Try to match string input using regular expressions. // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360] // Just return an object and let the conversion functions handle that. // This way the result will be the same whether the tinycolor is initialized with string or object. var match; if (match = matchers.rgb.exec(color)) { return { r: match[1], g: match[2], b: match[3] }; } if (match = matchers.rgba.exec(color)) { return { r: match[1], g: match[2], b: match[3], a: match[4] }; } if (match = matchers.hsl.exec(color)) { return { h: match[1], s: match[2], l: match[3] }; } if (match = matchers.hsla.exec(color)) { return { h: match[1], s: match[2], l: match[3], a: match[4] }; } if (match = matchers.hsv.exec(color)) { return { h: match[1], s: match[2], v: match[3] }; } if (match = matchers.hsva.exec(color)) { return { h: match[1], s: match[2], v: match[3], a: match[4] }; } if (match = matchers.hex8.exec(color)) { return { r: parseIntFromHex(match[1]), g: parseIntFromHex(match[2]), b: parseIntFromHex(match[3]), a: convertHexToDecimal(match[4]), format: named ? "name" : "hex8" }; } if (match = matchers.hex6.exec(color)) { return { r: parseIntFromHex(match[1]), g: parseIntFromHex(match[2]), b: parseIntFromHex(match[3]), format: named ? "name" : "hex" }; } if (match = matchers.hex4.exec(color)) { return { r: parseIntFromHex(match[1] + "" + match[1]), g: parseIntFromHex(match[2] + "" + match[2]), b: parseIntFromHex(match[3] + "" + match[3]), a: convertHexToDecimal(match[4] + "" + match[4]), format: named ? "name" : "hex8" }; } if (match = matchers.hex3.exec(color)) { return { r: parseIntFromHex(match[1] + "" + match[1]), g: parseIntFromHex(match[2] + "" + match[2]), b: parseIntFromHex(match[3] + "" + match[3]), format: named ? "name" : "hex" }; } return false; } function validateWCAG2Parms(parms) { // return valid WCAG2 parms for isReadable. // If input parms are invalid, return {"level":"AA", "size":"small"} var level, size; parms = parms || { level: "AA", size: "small" }; level = (parms.level || "AA").toUpperCase(); size = (parms.size || "small").toLowerCase(); if (level !== "AA" && level !== "AAA") { level = "AA"; } if (size !== "small" && size !== "large") { size = "small"; } return { level: level, size: size }; } return tinycolor; })); /*! * angularjs-color-picker v2.7.2 * https://github.com/ruhley/angular-color-picker/ * * Copyright 2016 ruhley * * 2016-12-23 14:00:20 * */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tinycolor2')) : typeof define === 'function' && define.amd ? define(['tinycolor2'], factory) : (global.AngularjsColorPicker = factory(global.tinycolor)); }(this, (function (tinycolor) { 'use strict'; tinycolor = 'default' in tinycolor ? tinycolor['default'] : tinycolor; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; var classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; var createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; var set = function set(object, property, value, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent !== null) { set(parent, property, value, receiver); } } else if ("value" in desc && desc.writable) { desc.value = value; } else { var setter = desc.set; if (setter !== undefined) { setter.call(receiver, value); } } return value; }; var AngularColorPickerController = function () { function AngularColorPickerController(_$scope, _$element, _$document, _$timeout, _ColorPickerOptions) { classCallCheck(this, AngularColorPickerController); // set angular injected variables this.$scope = _$scope; this.$element = _$element; this.$document = _$document; this.$timeout = _$timeout; this.ColorPickerOptions = _ColorPickerOptions; this.$scope.init = this.init.bind(this); this.hue = 0; this.saturation = undefined; this.lightness = undefined; this.opacity = undefined; } createClass(AngularColorPickerController, [{ key: 'watchNgModel', value: function watchNgModel(newValue, oldValue) { var _this = this; if (this.colorMouse) { return; } if (newValue !== undefined && oldValue !== undefined && !this.hasOwnProperty('initialNgModel')) { this.initialNgModel = newValue; } // check dirty/pristine state if (this.hasOwnProperty('initialNgModel')) { if (newValue === this.initialNgModel) { if (typeof this.$scope.control[0].$setPristine === 'function') { this.$scope.control[0].$setPristine(); } } else { if (typeof this.$scope.control[0].$setDirty === 'function') { this.$scope.control[0].$setDirty(); } } } if (newValue !== undefined && newValue !== null && newValue.length > 4) { var color = tinycolor(newValue); if (color.isValid()) { var hsl; if (this.options.round) { hsl = color.toHsl(); this.lightness = hsl.l * 100; } else { hsl = color.toHsv(); this.lightness = hsl.v * 100; } this.hue = hsl.h; this.saturation = hsl.s * 100; this.updateModel = false; if (this.options.alpha) { this.opacity = hsl.a * 100; } this.$timeout(function () { _this.updateModel = true; }); this.isValid = true; } else { this.isValid = false; } this.$scope.control[0].$setValidity(this.$element.attr('name'), this.isValid); } else { if (newValue === null || newValue === '') { this.hue = 0; this.saturation = undefined; this.lightness = undefined; this.opacity = undefined; } this.swatchColor = ''; } } }, { key: 'watchSwatchPos', value: function watchSwatchPos(newValue) { var _this2 = this; if (newValue !== undefined) { this.initConfig(); this.$timeout(function () { _this2.updateSwatchBackground(); }); } } }, { key: 'setupApi', value: function setupApi() { var _this3 = this; if (!this.api) { this.api = {}; } this.api.open = function (event) { // if already open then don't run show again if (_this3.is_open) { return true; } _this3.is_open = true; _this3.hueMouse = false; _this3.opacityMouse = false; _this3.colorMouse = false; // force the sliders to re-caculate their position _this3.hueUpdate(); _this3.saturationUpdate(); _this3.lightnessUpdate(); _this3.opacityUpdate(); _this3.eventApiDispatch('onOpen', [event]); }; this.api.close = function (event) { if (!_this3.options.inline && (_this3.is_open || _this3.$element[0].querySelector('.color-picker-panel').offsetParent !== null)) { _this3.is_open = false; _this3.$scope.$applyAsync(); _this3.eventApiDispatch('onClose', [event]); } }; this.api.clear = function (event) { if (_this3.ngModel !== '') { _this3.ngModel = ''; _this3.eventApiDispatch('onClear', [event]); } }; this.api.reset = function (event) { if (_this3.ngModel !== _this3.initialNgModel) { _this3.ngModel = _this3.initialNgModel; _this3.eventApiDispatch('onReset', [event]); } }; this.api.getElement = function () { return _this3.$element; }; this.api.getScope = function () { return _this3.$scope; }; } }, { key: 'reInit', value: function reInit(newValue) { if (newValue !== undefined) { this.initConfig(); } } }, { key: 'reInitAndUpdate', value: function reInitAndUpdate(newValue) { if (newValue !== undefined) { this.initConfig(); this.update(); } } }, { key: 'init', value: function init() { var _this4 = this; // browser variables this.chrome = Boolean(window.chrome); var _android_version = window.navigator.userAgent.match(/Android\s([0-9\.]*)/i); this.android_version = _android_version && _android_version.length > 1 ? parseFloat(_android_version[1]) : NaN; var eventHandlers = { mouseDown: this.onMouseDown.bind(this), mouseUp: this.onMouseUp.bind(this), mouseMove: this.onMouseMove.bind(this), keyUp: this.onKeyUp.bind(this) }; // needed variables this.updateModel = true; //--------------------------- // watchers //--------------------------- // ngModel this.$scope.$watch('AngularColorPickerController.ngModel', this.watchNgModel.bind(this)); // options this.$scope.$watch('AngularColorPickerController.options.swatchPos', this.watchSwatchPos.bind(this)); this.$scope.$watchGroup(['AngularColorPickerController.options.format', 'AngularColorPickerController.options.alpha', 'AngularColorPickerController.options.case'], this.reInitAndUpdate.bind(this)); this.$scope.$watchGroup(['AngularColorPickerController.options.disabled', 'AngularColorPickerController.options.swatchBootstrap', 'AngularColorPickerController.options.swatchOnly', 'AngularColorPickerController.options.swatch', 'AngularColorPickerController.options.pos', 'AngularColorPickerController.options.inline', 'AngularColorPickerController.options.placeholder', 'AngularColorPickerController.options.round'], this.reInit.bind(this)); // api this.$scope.$watch('AngularColorPickerController.api', this.setupApi.bind(this)); // internal this.$scope.$watch('AngularColorPickerController.swatchColor', this.updateSwatchBackground.bind(this)); this.$scope.$watch('AngularColorPickerController.hue', this.hueUpdate.bind(this)); this.$scope.$watch('AngularColorPickerController.saturation', this.saturationUpdate.bind(this)); this.$scope.$watch('AngularColorPickerController.lightness', this.lightnessUpdate.bind(this)); this.$scope.$watch('AngularColorPickerController.opacity', this.opacityUpdate.bind(this)); //--------------------------- // destroy //--------------------------- this.$scope.$on('$destroy', function () { // remove mouse events _this4.$document.off('mousedown', eventHandlers.mouseDown); _this4.$document.off('mouseup', eventHandlers.mouseUp); _this4.$document.off('mousemove', eventHandlers.mouseMove); // remove touch events _this4.$document.off('touchstart', eventHandlers.mouseDown); _this4.$document.off('touchend', eventHandlers.mouseUp); _this4.$document.off('touchmove', eventHandlers.mouseMove); // remove key events _this4.$document.off('keyup', eventHandlers.keyUp); _this4.eventApiDispatch('onDestroy'); }); // set default config settings this.initConfig(); // setup mouse events this.$document.on('mousedown', eventHandlers.mouseDown); this.$document.on('mouseup', eventHandlers.mouseUp); this.$document.on('mousemove', eventHandlers.mouseMove); // setup touch events this.$document.on('touchstart', eventHandlers.mouseDown); this.$document.on('touchend', eventHandlers.mouseUp); this.$document.on('touchmove', eventHandlers.mouseMove); // setup key events this.$document.on('keyup', eventHandlers.keyUp); // grid click this.find('.color-picker-grid').on('click', this.onColorClick.bind(this)); this.find('.color-picker-grid').on('touchend', this.onColorClick.bind(this)); // hue click this.find('.color-picker-hue').on('click', this.onHueClick.bind(this)); this.find('.color-picker-hue').on('touchend', this.onHueClick.bind(this)); // saturation click this.find('.color-picker-saturation').on('click', this.onSaturationClick.bind(this)); this.find('.color-picker-saturation').on('touchend', this.onSaturationClick.bind(this)); // lightness click this.find('.color-picker-lightness').on('click', this.onLightnessClick.bind(this)); this.find('.color-picker-lightness').on('touchend', this.onLightnessClick.bind(this)); // opacity click this.find('.color-picker-opacity').on('click', this.onOpacityClick.bind(this)); this.find('.color-picker-opacity').on('touchend', this.onOpacityClick.bind(this)); } }, { key: 'onMouseDown', value: function onMouseDown(event) { this.has_moused_moved = false; // an element in this picker if (!this.options.disabled && this.find(event.target).length > 0) { // mouse event on color grid if (event.target.classList.contains('color-picker-grid-inner') || event.target.classList.contains('color-picker-picker') || event.target.parentNode.classList.contains('color-picker-picker')) { this.colorDown(event); this.$scope.$apply(); // mouse event on hue slider } else if (event.target.classList.contains('color-picker-hue') || event.target.parentNode.classList.contains('color-picker-hue')) { this.hueDown(event); this.$scope.$apply(); // mouse event on saturation slider } else if (event.target.classList.contains('color-picker-saturation') || event.target.parentNode.classList.contains('color-picker-saturation')) { this.saturationDown(event); this.$scope.$apply(); // mouse event on lightness slider } else if (event.target.classList.contains('color-picker-lightness') || event.target.parentNode.classList.contains('color-picker-lightness')) { this.lightnessDown(event); this.$scope.$apply(); // mouse event on opacity slider } else if (event.target.classList.contains('color-picker-opacity') || event.target.parentNode.classList.contains('color-picker-opacity')) { this.opacityDown(event); this.$scope.$apply(); } } } }, { key: 'onMouseUp', value: function onMouseUp(event) { // no current mouse events and not an element in the picker if (!this.colorMouse && !this.hueMouse && !this.opacityMouse && this.find(event.target).length === 0) { this.setupApi(); // TODO - there are some weird times when this is needed to call close. Need to figure out why. if (this.options.hide.click) { this.api.close(event); } this.$scope.$apply(); // mouse event on color grid } else if (this.colorMouse && this.has_moused_moved) { this.colorUp(event); this.$scope.$apply(); this.onChange(event); // mouse event on hue slider } else if (this.hueMouse && this.has_moused_moved) { this.hueUp(event); this.$scope.$apply(); this.onChange(event); // mouse event on saturation slider } else if (this.saturationMouse && this.has_moused_moved) { this.saturationUp(event); this.$scope.$apply(); this.onChange(event); // mouse event on lightness slider } else if (this.lightnessMouse && this.has_moused_moved) { this.lightnessUp(event); this.$scope.$apply(); this.onChange(event); // mouse event on opacity slider } else if (this.opacityMouse && this.has_moused_moved) { this.opacityUp(event); this.$scope.$apply(); this.onChange(event); } } }, { key: 'onMouseMove', value: function onMouseMove(event) { // mouse event on color grid if (this.colorMouse) { this.has_moused_moved = true; this.colorChange(event); this.$scope.$apply(); // mouse event on hue slider } else if (this.hueMouse) { this.has_moused_moved = true; this.hueChange(event); this.$scope.$apply(); // mouse event on saturation slider } else if (this.saturationMouse) { this.has_moused_moved = true; this.saturationChange(event); this.$scope.$apply(); // mouse event on lightness slider } else if (this.lightnessMouse) { this.has_moused_moved = true; this.lightnessChange(event); this.$scope.$apply(); // mouse event on opacity slider } else if (this.opacityMouse) { this.has_moused_moved = true; this.opacityChange(event); this.$scope.$apply(); } } }, { key: 'onKeyUp', value: function onKeyUp(event) { // escape key if (this.options.hide.escape && event.keyCode === 27) { this.api.close(event); } } }, { key: 'onColorClick', value: function onColorClick(event) { if (!this.options.disabled && !this.has_moused_moved) { this.colorChange(event); this.colorUp(event); this.$scope.$apply(); this.onChange(event); } } }, { key: 'onHueClick', value: function onHueClick(event) { if (!this.options.disabled && !this.has_moused_moved) { this.hueChange(event); this.hueUp(event); this.$scope.$apply(); this.onChange(event); } } }, { key: 'onSaturationClick', value: function onSaturationClick(event) { if (!this.options.disabled && !this.has_moused_moved) { this.saturationChange(event); this.saturationUp(event); this.$scope.$apply(); this.onChange(event); } } }, { key: 'onLightnessClick', value: function onLightnessClick(event) { if (!this.options.disabled && !this.has_moused_moved) { this.lightnessChange(event); this.lightnessUp(event); this.$scope.$apply(); this.onChange(event); } } }, { key: 'onOpacityClick', value: function onOpacityClick(event) { if (!this.options.disabled && !this.has_moused_moved) { this.opacityChange(event); this.opacityUp(event); this.$scope.$apply(); this.onChange(event); } } }, { key: 'onChange', value: function onChange(event) { // don't fire if it hasn't actually changed if (this.ngModel !== this.onChangeValue) { this.onChangeValue = this.ngModel; this.eventApiDispatch('onChange', [event]); } } }, { key: 'onBlur', value: function onBlur(event) { if (this.ngModel !== this.onChangeValue) { this.updateModel = true; this.update(); } this.$scope.control[0].$setTouched(); this.eventApiDispatch('onBlur', [event]); // if clicking outside the color picker if (this.options.hide.blur && this.find(event.relatedTarget).length === 0) { this.api.close(event); } } }, { key: 'initConfig', value: function initConfig() { if (!this.options) { this.options = {}; } this.mergeOptions(this.options, this.ColorPickerOptions); this.is_open = this.options.inline; if (this.options.round) { this.options.hue = false; } else { this.options.saturation = false; } if (this.options.inline) { this.options.close.show = false; } } }, { key: 'mergeOptions', value: function mergeOptions(options, defaultOptions) { for (var attr in defaultOptions) { if (defaultOptions.hasOwnProperty(attr)) { if (!options || !options.hasOwnProperty(attr)) { options[attr] = defaultOptions[attr]; } else if (_typeof(defaultOptions[attr]) === 'object') { this.mergeOptions(options[attr], defaultOptions[attr]); } } } } }, { key: 'onSwatchClick', value: function onSwatchClick($event) { if (this.options.show.swatch) { this.api.open($event); } } }, { key: 'onFocus', value: function onFocus($event) { if (this.options.show.focus) { this.api.open($event); } } }, { key: 'update', value: function update() { if (this.hue === undefined || this.saturation === undefined || this.lightness === undefined) { return false; } var color; if (this.options.round) { color = tinycolor({ h: this.hue, s: this.saturation, l: this.lightness }); } else { color = tinycolor({ h: this.hue, s: this.saturation, v: this.lightness }); } if (this.options.alpha) { color.setAlpha(this.opacity / 100); } this.swatchColor = color.toHslString(); this.updateSaturationBackground(color); this.updateLightnessBackground(color); var colorString; switch (this.options.format) { case 'rgb': colorString = color.toRgbString(); break; case 'hex': colorString = color.toHexString(); if (this.options.case === 'lower') { colorString = colorString.toLowerCase(); } else { colorString = colorString.toUpperCase(); } break; case 'hex8': colorString = color.toHex8String(); if (this.options.case === 'lower') { colorString = colorString.toLowerCase(); } else { colorString = colorString.toUpperCase(); } break; case 'hsv': colorString = color.toHsvString(); break; default: colorString = color.toHslString(); break; } if (this.updateModel) { this.ngModel = colorString; } } }, { key: 'updateSwatchBackground', value: function updateSwatchBackground() { var el = angular.element(this.$element[0].querySelector('.color-picker-swatch')); el.css({ 'background-color': this.swatchColor }); } }, { key: 'huePosUpdate', value: function huePosUpdate() { var _this5 = this; this.$timeout(function () { var container = _this5.$element[0].querySelector('.color-picker-hue'); var el = angular.element(_this5.$element[0].querySelector('.color-picker-hue .color-picker-slider')); var bounding = container.getBoundingClientRect(); el.css({ 'top': bounding.height * _this5.huePos / 100 + 'px' }); }); } }, { key: 'saturationPosUpdate', value: function saturationPosUpdate() { var _this6 = this; this.$timeout(function () { var container, el, bounding; if (!_this6.options.round) { container = _this6.$element[0].querySelector('.color-picker-grid'); el = angular.element(_this6.$element[0].querySelector('.color-picker-grid .color-picker-picker')); bounding = container.getBoundingClientRect(); el.css({ 'left': bounding.width * _this6.saturationPos / 100 + 'px' }); } container = _this6.$element[0].querySelector('.color-picker-saturation'); el = angular.element(_this6.$element[0].querySelector('.color-picker-saturation .color-picker-slider')); bounding = container.getBoundingClientRect(); el.css({ 'top': bounding.height * (100 - _this6.saturationPos) / 100 + 'px' }); }); } }, { key: 'lightnessPosUpdate', value: function lightnessPosUpdate() { var _this7 = this; this.$timeout(function () { var container, el, bounding; if (!_this7.options.round) { container = _this7.$element[0].querySelector('.color-picker-grid'); el = angular.element(_this7.$element[0].querySelector('.color-picker-grid .color-picker-picker')); bounding = container.getBoundingClientRect(); el.css({ 'top': bounding.height * _this7.lightnessPos / 100 + 'px' }); } container = _this7.$element[0].querySelector('.color-picker-lightness'); el = angular.element(_this7.$element[0].querySelector('.color-picker-lightness .color-picker-slider')); bounding = container.getBoundingClientRect(); el.css({ 'top': bounding.height * _this7.lightnessPos / 100 + 'px' }); }); } }, { key: 'opacityPosUpdate', value: function opacityPosUpdate() { var _this8 = this; this.$timeout(function () { var container = _this8.$element[0].querySelector('.color-picker-opacity'); var el = angular.element(_this8.$element[0].querySelector('.color-picker-opacity .color-picker-slider')); var bounding = container.getBoundingClientRect(); el.css({ 'top': bounding.height * _this8.opacityPos / 100 + 'px' }); }); } }, { key: 'gridUpdate', value: function gridUpdate() { var el = angular.element(this.$element[0].querySelector('.color-picker-grid')); el.css({ 'background-color': this.grid }); } //--------------------------- // hue functions //--------------------------- }, { key: 'hueDown', value: function hueDown(event) { event.stopPropagation(); event.preventDefault(); this.hueMouse = true; } }, { key: 'hueUp', value: function hueUp(event) { event.stopPropagation(); event.preventDefault(); this.hueMouse = false; } }, { key: 'hueChange', value: function hueChange(event) { event.stopPropagation(); event.preventDefault(); var el = this.find('.color-picker-hue'); var eventPos = this.getEventPos(event); this.hue = Math.round((1 - (eventPos.pageY - this.offset(el).top) / el.prop('offsetHeight')) * 360); if (this.hue > 360) { this.hue = 360; } else if (this.hue < 0) { this.hue = 0; } } }, { key: 'hueUpdate', value: function hueUpdate() { if (this.hue !== undefined) { this.huePos = (1 - this.hue / 360) * 100; this.grid = tinycolor({ h: this.hue, s: 100, v: 1 }).toHslString(); if (this.huePos < 0) { this.huePos = 0; } else if (this.huePos > 100) { this.huePos = 100; } if (this.options.round) { this.getRoundPos(); this.updateRoundPos(); } else { this.gridUpdate(); } this.huePosUpdate(); this.update(); } } //--------------------------- // saturation functions //--------------------------- }, { key: 'saturationDown', value: function saturationDown(event) { event.stopPropagation(); event.preventDefault(); this.saturationMouse = true; } }, { key: 'saturationUp', value: function saturationUp(event) { event.stopPropagation(); event.preventDefault(); this.saturationMouse = false; } }, { key: 'saturationChange', value: function saturationChange(event) { event.stopPropagation(); event.preventDefault(); var el = this.find('.color-picker-saturation'); var eventPos = this.getEventPos(event); this.saturation = Math.round((1 - (eventPos.pageY - this.offset(el).top) / el.prop('offsetHeight')) * 100); if (this.saturation > 100) { this.saturation = 100; } else if (this.saturation < 0) { this.saturation = 0; } } }, { key: 'saturationUpdate', value: function saturationUpdate() { if (this.saturation !== undefined) { if (this.options.round) { this.getRoundPos(); this.updateRoundPos(); } this.saturationPos = this.saturation; if (this.saturationPos < 0) { this.saturationPos = 0; } else if (this.saturationPos > 100) { this.saturationPos = 100; } this.saturationPosUpdate(); this.update(); } } }, { key: 'updateSaturationBackground', value: function updateSaturationBackground(color) { var el = this.find('.color-picker-saturation'); var saturated = color.clone().saturate(100); var desaturated = color.clone().desaturate(100); el.css({ 'background': 'linear-gradient(to bottom, ' + saturated.toHexString() + ' 0%, ' + desaturated.toHexString() + ' 100%)' }); } }, { key: 'updateLightnessBackground', value: function updateLightnessBackground(color) { var el = this.find('.color-picker-lightness'); if (this.options.round) { var hsl = color.toHsl(); hsl.l = 50; hsl = tinycolor(hsl); el.css({ 'background': 'linear-gradient(to bottom, #FFFFFF 0%, ' + hsl.toHexString() + ' 50%, #000000 100%)' }); } else { var hsv = color.toHsv(); hsv.v = 100; hsv = tinycolor(hsv); el.css({ 'background': 'linear-gradient(to bottom, ' + hsv.toHexString() + ' 0%, #000000 100%)' }); } } //--------------------------- // lightness functions //--------------------------- }, { key: 'lightnessDown', value: function lightnessDown(event) { event.stopPropagation(); event.preventDefault(); this.lightnessMouse = true; } }, { key: 'lightnessUp', value: function lightnessUp(event) { event.stopPropagation(); event.preventDefault(); this.lightnessMouse = false; } }, { key: 'lightnessChange', value: function lightnessChange(event) { event.stopPropagation(); event.preventDefault(); var el = this.find('.color-picker-lightness'); var eventPos = this.getEventPos(event); this.lightness = Math.round((1 - (eventPos.pageY - this.offset(el).top) / el.prop('offsetHeight')) * 100); if (this.lightness > 100) { this.lightness = 100; } else if (this.lightness < 0) { this.lightness = 0; } } }, { key: 'lightnessUpdate', value: function lightnessUpdate() { if (this.lightness !== undefined) { this.lightnessPos = 100 - this.lightness; if (this.lightnessPos < 0) { this.lightnessPos = 0; } else if (this.lightnessPos > 100) { this.lightnessPos = 100; } this.lightnessPosUpdate(); this.update(); } } //--------------------------- // opacity functions //--------------------------- }, { key: 'opacityDown', value: function opacityDown(event) { event.stopPropagation(); event.preventDefault(); this.opacityMouse = true; } }, { key: 'opacityUp', value: function opacityUp(event) { event.stopPropagation(); event.preventDefault(); this.opacityMouse = false; } }, { key: 'opacityChange', value: function opacityChange(event) { event.stopPropagation(); event.preventDefault(); var el = this.find('.color-picker-opacity'); var eventPos = this.getEventPos(event); this.opacity = (1 - (eventPos.pageY - this.offset(el).top) / el.prop('offsetHeight')) * 100; if (this.opacity > 100) { this.opacity = 100; } else if (this.opacity < 0) { this.opacity = 0; } } }, { key: 'opacityUpdate', value: function opacityUpdate() { if (this.opacity !== undefined) { this.opacityPos = (1 - this.opacity / 100) * 100; if (this.opacityPos < 0) { this.opacityPos = 0; } else if (this.opacityPos > 100) { this.opacityPos = 100; } this.opacityPosUpdate(); this.update(); } } //--------------------------- // color functions //--------------------------- }, { key: 'colorDown', value: function colorDown(event) { event.stopPropagation(); event.preventDefault(); this.colorMouse = true; } }, { key: 'colorUp', value: function colorUp(event) { event.stopPropagation(); event.preventDefault(); this.colorMouse = false; } }, { key: 'colorChange', value: function colorChange(event) { event.stopPropagation(); event.preventDefault(); var el = this.find('.color-picker-grid-inner'); var eventPos = this.getEventPos(event); var offset = this.offset(el); if (this.options.round) { var dx = (eventPos.pageX - offset.left) * 2.0 / el.prop('offsetWidth') - 1.0; var dy = -((eventPos.pageY - offset.top) * 2.0 / el.prop('offsetHeight')) + 1.0; var tmpHue = Math.atan2(dy, dx); var degHue = Math.round(tmpHue * 57.29577951308233); // rad to deg if (degHue < 0) { degHue += 360; } this.hue = degHue; var tmpSaturation = Math.sqrt(dx * dx + dy * dy); if (tmpSaturation > 1) { tmpSaturation = 1; } else if (tmpSaturation < 0) { tmpSaturation = 0; } this.saturation = tmpSaturation * 100; if (this.lightness === undefined) { this.lightness = 50; } } else { this.saturation = (eventPos.pageX - offset.left) / el.prop('offsetWidth') * 100; this.lightness = (1 - (eventPos.pageY - offset.top) / el.prop('offsetHeight')) * 100; if (this.saturation > 100) { this.saturation = 100; } else if (this.saturation < 0) { this.saturation = 0; } if (this.lightness > 100) { this.lightness = 100; } else if (this.lightness < 0) { this.lightness = 0; } } } //--------------------------- // helper functions //--------------------------- }, { key: 'getRoundPos', value: function getRoundPos() { var angle = this.hue * 0.01745329251994; // deg to rad var px = Math.cos(angle) * this.saturation; var py = -Math.sin(angle) * this.saturation; this.xPos = (px + 100.0) * 0.5; this.yPos = (py + 100.0) * 0.5; // because it are using percentages this can be half of 100% var center = 50; // distance of pointer from the center of the circle var distance = Math.pow(center - this.xPos, 2) + Math.pow(center - this.yPos, 2); // distance of edge of circle from the center of the circle var radius = Math.pow(center, 2); // if not inside the circle if (distance > radius) { var rads = Math.atan2(this.yPos - center, this.xPos - center); this.xPos = Math.cos(rads) * center + center; this.yPos = Math.sin(rads) * center + center; } } }, { key: 'updateRoundPos', value: function updateRoundPos() { var _this9 = this; this.$timeout(function () { var container = _this9.$element[0].querySelector('.color-picker-grid'); var el = angular.element(_this9.$element[0].querySelector('.color-picker-grid .color-picker-picker')); var bounding = container.getBoundingClientRect(); el.css({ left: bounding.width * _this9.xPos / 100 + 'px', top: bounding.height * _this9.yPos / 100 + 'px' }); }); } }, { key: 'getEventPos', value: function getEventPos(event) { // if a touch event if (event.type.search('touch') === 0) { // if event modified by angular if (event.originalEvent && event.originalEvent.changedTouches) { return event.originalEvent.changedTouches[0]; // if a standard js touch event } else if (event.changedTouches) { return event.changedTouches[0]; } } // return a non-touch event return event; } }, { key: 'eventApiDispatch', value: function eventApiDispatch(name, args) { if (this.eventApi && typeof this.eventApi[name] === 'function') { if (!args) { args = []; } args.unshift(this.ngModel); args.unshift(this.api); this.eventApi[name].apply(this, args); } } // taken and modified from jQuery's find }, { key: 'find', value: function find(selector) { var context = this.wrapper ? this.wrapper[0] : this.$element[0], results = [], nodeType; // Same basic safeguard as Sizzle if (!selector) { return results; } if (typeof selector === 'string') { // Early return if context is not an element or document if ((nodeType = context.nodeType) !== 1 && nodeType !== 9) { return []; } results = context.querySelectorAll(selector); } else { if (context.contains(selector)) { results.push(selector); } } return angular.element(results); } // taken and modified from jQuery's offset }, { key: 'offset', value: function offset(el) { var docElem, win, rect, doc, elem = el[0]; if (!elem) { return; } // Support: IE<=11+ // Running getBoundingClientRect on a // disconnected node in IE throws an error if (!elem.getClientRects().length) { return { top: 0, left: 0 }; } rect = elem.getBoundingClientRect(); // Make sure element is not hidden (display: none) if (rect.width || rect.height) { doc = elem.ownerDocument; win = doc !== null && doc === doc.window ? doc : doc.nodeType === 9 && doc.defaultView; docElem = doc.documentElement; // hack for small chrome screens not position the clicks properly when the page is scrolled if (this.chrome && this.android_version < 6 && screen.width <= 768) { return { top: rect.top - docElem.clientTop, left: rect.left - docElem.clientLeft }; } return { top: rect.top + win.pageYOffset - docElem.clientTop, left: rect.left + win.pageXOffset - docElem.clientLeft }; } return rect; } }]); return AngularColorPickerController; }(); AngularColorPickerController.$inject = ['$scope', '$element', '$document', '$timeout', 'ColorPickerOptions']; function colorPickerDirective() { return { restrict: 'E', require: ['^ngModel'], scope: { ngModel: '=', options: '=?', api: '=?', eventApi: '=?' }, bindToController: true, templateUrl: 'template/color-picker/directive.html', controller: AngularColorPickerController, controllerAs: 'AngularColorPickerController', link: function link($scope, element, attrs, control) { $scope.control = control; $scope.init(); } }; } function template($templateCache) { $templateCache.put('template/color-picker/directive.html', '
    ' + '
    ' + ' ' + ' ' + ' ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + ' ' + ' {{AngularColorPickerController.options.close.label}}' + ' ' + '
    ' + '
    ' + '
    '); } template.$inject = ['$templateCache']; var AngularColorPickerOptions = function AngularColorPickerOptions() { classCallCheck(this, AngularColorPickerOptions); return { required: false, disabled: false, hue: true, saturation: false, lightness: false, alpha: true, round: false, case: 'upper', format: 'hsl', pos: 'bottom left', swatch: true, swatchOnly: false, swatchPos: 'left', swatchBootstrap: true, inline: false, placeholder: '', id: undefined, name: undefined, show: { swatch: true, focus: true }, hide: { blur: true, escape: true, click: true }, close: { show: false, label: 'Close', class: '' }, clear: { show: false, label: 'Clear', class: '' }, reset: { show: false, label: 'Reset', class: '' } }; }; var colorPicker = angular.module('color.picker', []).service('ColorPickerOptions', AngularColorPickerOptions).directive('colorPicker', colorPickerDirective).run(template); return colorPicker; }))); var duScrollDefaultEasing = function (e) { "use strict"; return e < .5 ? Math.pow(2 * e, 2) / 2 : 1 - Math.pow(2 * (1 - e), 2) / 2 }, duScroll = angular.module("duScroll", ["duScroll.scrollspy", "duScroll.smoothScroll", "duScroll.scrollContainer", "duScroll.spyContext", "duScroll.scrollHelpers"]).value("duScrollDuration", 350).value("duScrollSpyWait", 100).value("duScrollSpyRefreshInterval", 0).value("duScrollGreedy", !1).value("duScrollOffset", 0).value("duScrollEasing", duScrollDefaultEasing).value("duScrollCancelOnEvents", "scroll mousedown mousewheel touchmove keydown").value("duScrollBottomSpy", !1).value("duScrollActiveClass", "active"); "undefined" != typeof module && module && module.exports && (module.exports = duScroll), angular.module("duScroll.scrollHelpers", ["duScroll.requestAnimation"]).run(["$window", "$q", "cancelAnimation", "requestAnimation", "duScrollEasing", "duScrollDuration", "duScrollOffset", "duScrollCancelOnEvents", function (e, t, n, r, o, l, u, i) { "use strict"; var c = {}, a = function (e) { return "undefined" != typeof HTMLDocument && e instanceof HTMLDocument || e.nodeType && e.nodeType === e.DOCUMENT_NODE }, s = function (e) { return "undefined" != typeof HTMLElement && e instanceof HTMLElement || e.nodeType && e.nodeType === e.ELEMENT_NODE }, d = function (e) { return s(e) || a(e) ? e : e[0] }; c.duScrollTo = function (t, n, r, o) { var l; if (angular.isElement(t) ? l = this.duScrollToElement : angular.isDefined(r) && (l = this.duScrollToAnimated), l) return l.apply(this, arguments); var u = d(this); return a(u) ? e.scrollTo(t, n) : (u.scrollLeft = t, void (u.scrollTop = n)) }; var f, m; c.duScrollToAnimated = function (e, l, u, c) { u && !c && (c = o); var a = this.duScrollLeft(), s = this.duScrollTop(), d = Math.round(e - a), p = Math.round(l - s), S = null, g = 0, v = this, h = function (e) { (!e || g && e.which > 0) && (i && v.unbind(i, h), n(f), m.reject(), f = null) }; if (f && h(), m = t.defer(), 0 === u || !d && !p) return 0 === u && v.duScrollTo(e, l), m.resolve(), m.promise; var y = function (e) { null === S && (S = e), g = e - S; var t = g >= u ? 1 : c(g / u); v.scrollTo(a + Math.ceil(d * t), s + Math.ceil(p * t)), t < 1 ? f = r(y) : (i && v.unbind(i, h), f = null, m.resolve()) }; return v.duScrollTo(a, s), i && v.bind(i, h), f = r(y), m.promise }, c.duScrollToElement = function (e, t, n, r) { var o = d(this); angular.isNumber(t) && !isNaN(t) || (t = u); var l = this.duScrollTop() + d(e).getBoundingClientRect().top - t; return s(o) && (l -= o.getBoundingClientRect().top), this.duScrollTo(0, l, n, r) }, c.duScrollLeft = function (t, n, r) { if (angular.isNumber(t)) return this.duScrollTo(t, this.duScrollTop(), n, r); var o = d(this); return a(o) ? e.scrollX || document.documentElement.scrollLeft || document.body.scrollLeft : o.scrollLeft }, c.duScrollTop = function (t, n, r) { if (angular.isNumber(t)) return this.duScrollTo(this.duScrollLeft(), t, n, r); var o = d(this); return a(o) ? e.scrollY || document.documentElement.scrollTop || document.body.scrollTop : o.scrollTop }, c.duScrollToElementAnimated = function (e, t, n, r) { return this.duScrollToElement(e, t, n || l, r) }, c.duScrollTopAnimated = function (e, t, n) { return this.duScrollTop(e, t || l, n) }, c.duScrollLeftAnimated = function (e, t, n) { return this.duScrollLeft(e, t || l, n) }, angular.forEach(c, function (e, t) { angular.element.prototype[t] = e; var n = t.replace(/^duScroll/, "scroll"); angular.isUndefined(angular.element.prototype[n]) && (angular.element.prototype[n] = e) }) }]), angular.module("duScroll.polyfill", []).factory("polyfill", ["$window", function (e) { "use strict"; var t = ["webkit", "moz", "o", "ms"]; return function (n, r) { if (e[n]) return e[n]; for (var o, l = n.substr(0, 1).toUpperCase() + n.substr(1), u = 0; u < t.length; u++) if (o = t[u] + l, e[o]) return e[o]; return r } }]), angular.module("duScroll.requestAnimation", ["duScroll.polyfill"]).factory("requestAnimation", ["polyfill", "$timeout", function (e, t) { "use strict"; var n = 0, r = function (e, r) { var o = (new Date).getTime(), l = Math.max(0, 16 - (o - n)), u = t(function () { e(o + l) }, l); return n = o + l, u }; return e("requestAnimationFrame", r) }]).factory("cancelAnimation", ["polyfill", "$timeout", function (e, t) { "use strict"; var n = function (e) { t.cancel(e) }; return e("cancelAnimationFrame", n) }]), angular.module("duScroll.spyAPI", ["duScroll.scrollContainerAPI"]).factory("spyAPI", ["$rootScope", "$timeout", "$interval", "$window", "$document", "scrollContainerAPI", "duScrollGreedy", "duScrollSpyWait", "duScrollSpyRefreshInterval", "duScrollBottomSpy", "duScrollActiveClass", function (e, t, n, r, o, l, u, i, c, a, s) { "use strict"; var d = function (n) { var l = !1, c = !1, d = function () { c = !1; var t, l = n.container, i = l[0], d = 0; if ("undefined" != typeof HTMLElement && i instanceof HTMLElement || i.nodeType && i.nodeType === i.ELEMENT_NODE) d = i.getBoundingClientRect().top, t = Math.round(i.scrollTop + i.clientHeight) >= i.scrollHeight; else { var f = o[0].body.scrollHeight || o[0].documentElement.scrollHeight; t = Math.round(r.pageYOffset + r.innerHeight) >= f } var m, p, S, g, v, h, y = a && t ? "bottom" : "top"; for (g = n.spies, p = n.currentlyActive, S = void 0, m = 0; m < g.length; m++) v = g[m], h = v.getTargetPosition(), h && v.$element && (a && t || h.top + v.offset - d < 20 && (u || h.top * -1 + d) < h.height) && (!S || S[y] < h[y]) && (S = { spy: v }, S[y] = h[y]); S && (S = S.spy), p === S || u && !S || (p && p.$element && (p.$element.removeClass(s), e.$broadcast("duScrollspy:becameInactive", p.$element, angular.element(p.getTargetElement()))), S && (S.$element.addClass(s), e.$broadcast("duScrollspy:becameActive", S.$element, angular.element(S.getTargetElement()))), n.currentlyActive = S) }; return i ? function () { l ? c = !0 : (d(), l = t(function () { l = !1, c && d() }, i, !1)) } : d }, f = {}, m = function (e) { var t = e.$id, n = { spies: [] }; return n.handler = d(n), f[t] = n, e.$on("$destroy", function () { p(e) }), t }, p = function (e) { var t = e.$id, r = f[t], o = r.container; r.intervalPromise && n.cancel(r.intervalPromise), o && o.off("scroll", r.handler), delete f[t] }, S = m(e), g = function (e) { return f[e.$id] ? f[e.$id] : e.$parent ? g(e.$parent) : f[S] }, v = function (e) { var t, n, r = e.$scope; if (r) return g(r); for (n in f) if (t = f[n], t.spies.indexOf(e) !== -1) return t }, h = function (e) { for (; e.parentNode;) if (e = e.parentNode, e === document) return !0; return !1 }, y = function (e) { var t = v(e); t && (t.spies.push(e), t.container && h(t.container) || (t.container && t.container.off("scroll", t.handler), t.container = l.getContainer(e.$scope), c && !t.intervalPromise && (t.intervalPromise = n(t.handler, c, 0, !1)), t.container.on("scroll", t.handler).triggerHandler("scroll"))) }, $ = function (t) { var n = v(t); t === n.currentlyActive && (e.$broadcast("duScrollspy:becameInactive", n.currentlyActive.$element), n.currentlyActive = null); var r = n.spies.indexOf(t); r !== -1 && n.spies.splice(r, 1), t.$element = null }; return { addSpy: y, removeSpy: $, createContext: m, destroyContext: p, getContextForScope: g } }]), angular.module("duScroll.scrollContainerAPI", []).factory("scrollContainerAPI", ["$document", function (e) { "use strict"; var t = {}, n = function (e, n) { var r = e.$id; return t[r] = n, r }, r = function (e) { return t[e.$id] ? e.$id : e.$parent ? r(e.$parent) : void 0 }, o = function (n) { var o = r(n); return o ? t[o] : e }, l = function (e) { var n = r(e); n && delete t[n] }; return { getContainerId: r, getContainer: o, setContainer: n, removeContainer: l } }]), angular.module("duScroll.smoothScroll", ["duScroll.scrollHelpers", "duScroll.scrollContainerAPI"]).directive("duSmoothScroll", ["duScrollDuration", "duScrollOffset", "scrollContainerAPI", function (e, t, n) { "use strict"; return { link: function (r, o, l) { o.on("click", function (o) { if (l.href && l.href.indexOf("#") !== -1 || "" !== l.duSmoothScroll) { var u = l.href ? l.href.replace(/.*(?=#[^\s]+$)/, "").substring(1) : l.duSmoothScroll, i = document.getElementById(u) || document.getElementsByName(u)[0]; if (i && i.getBoundingClientRect) { o.stopPropagation && o.stopPropagation(), o.preventDefault && o.preventDefault(); var c = l.offset ? parseInt(l.offset, 10) : t, a = l.duration ? parseInt(l.duration, 10) : e, s = n.getContainer(r); s.duScrollToElement(angular.element(i), isNaN(c) ? 0 : c, isNaN(a) ? 0 : a) } } }) } } }]), angular.module("duScroll.spyContext", ["duScroll.spyAPI"]).directive("duSpyContext", ["spyAPI", function (e) { "use strict"; return { restrict: "A", scope: !0, compile: function (t, n, r) { return { pre: function (t, n, r, o) { e.createContext(t) } } } } }]), angular.module("duScroll.scrollContainer", ["duScroll.scrollContainerAPI"]).directive("duScrollContainer", ["scrollContainerAPI", function (e) { "use strict"; return { restrict: "A", scope: !0, compile: function (t, n, r) { return { pre: function (t, n, r, o) { r.$observe("duScrollContainer", function (r) { angular.isString(r) && (r = document.getElementById(r)), r = angular.isElement(r) ? angular.element(r) : n, e.setContainer(t, r), t.$on("$destroy", function () { e.removeContainer(t) }) }) } } } } }]), angular.module("duScroll.scrollspy", ["duScroll.spyAPI"]).directive("duScrollspy", ["spyAPI", "duScrollOffset", "$timeout", "$rootScope", function (e, t, n, r) { "use strict"; var o = function (e, t, n, r) { angular.isElement(e) ? this.target = e : angular.isString(e) && (this.targetId = e), this.$scope = t, this.$element = n, this.offset = r }; return o.prototype.getTargetElement = function () { return !this.target && this.targetId && (this.target = document.getElementById(this.targetId) || document.getElementsByName(this.targetId)[0]), this.target }, o.prototype.getTargetPosition = function () { var e = this.getTargetElement(); if (e) return e.getBoundingClientRect() }, o.prototype.flushTargetCache = function () { this.targetId && (this.target = void 0) }, { link: function (l, u, i) { var c, a = i.ngHref || i.href; if (a && a.indexOf("#") !== -1 ? c = a.replace(/.*(?=#[^\s]+$)/, "").substring(1) : i.duScrollspy ? c = i.duScrollspy : i.duSmoothScroll && (c = i.duSmoothScroll), c) { var s = n(function () { var n = new o(c, l, u, (-(i.offset ? parseInt(i.offset, 10) : t))); e.addSpy(n), l.$on("$locationChangeSuccess", n.flushTargetCache.bind(n)); var a = r.$on("$stateChangeSuccess", n.flushTargetCache.bind(n)); l.$on("$destroy", function () { e.removeSpy(n), a() }) }, 0, !1); l.$on("$destroy", function () { n.cancel(s) }) } } } }]); angular.module("duParallax", ["duScroll", "duParallax.directive", "duParallax.helper"]).value("duParallaxTouchEvents", !0), angular.module("duParallax.helper", []).factory("parallaxHelper", function () { function r(r, a, o, n) { return function (t) { var e = r * ((n || 0) + t.elemY); return angular.isNumber(a) && e > a ? a : angular.isNumber(o) && o > e ? o : e } } return { createAnimator: r, background: r(-.3, 150, -30, 50) } }), angular.module("duParallax.directive", ["duScroll"]).directive("duParallax", ["$rootScope", "$window", "$document", "duParallaxTouchEvents", function (r, a, o, n) { for (var t, e = angular.element("
    ")[0], l = "transform WebkitTransform MozTransform OTransform".split(" "), u = 0; u < l.length; u++) if (void 0 !== e.style[l[u]]) { t = l[u]; break } if (!(!t || !n && "ontouchstart" in window)) { var i = function (r) { return r.x || r.y ? "translate3d(" + Math.round(r.x) + "px, " + Math.round(r.y) + "px, 0)" : "" }, c = function (r) { return r.rotation ? " rotate(" + (angular.isNumber(r.rotation) ? Math.round(r.rotation) + "deg" : r.rotation) + ")" : "" }, d = function (r, a) { a.style[t] = i(r) + c(r), a.style.opacity = r.opacity, r.custom && angular.extend(a.style, r.custom) }; return { scope: { y: "=", x: "=", rotation: "=", opacity: "=", custom: "=" }, link: function (r, n) { var t, e = n[0], l = !1, u = function () { var n = o.scrollTop(), i = e.getBoundingClientRect(); l || (l = !0, angular.element(a).on("load", function () { var r, a = 0, o = 10, n = i.top; do r = n, u(), n = e.getBoundingClientRect().top, a++; while (o > a && r !== n) })); var c = { scrollY: n, elemX: i.left, elemY: i.top }, s = { x: 0, y: 0, rotation: 0, opacity: 1, custom: void 0 }; for (var f in s) angular.isFunction(r[f]) ? s[f] = r[f](c) : r[f] && (s[f] = r[f]); var m = angular.isUndefined(t); if (!m) for (f in s) if (s[f] !== t[f]) { m = !0; break } m && (d(s, e), t = s) }; o.on("scroll touchmove", u).triggerHandler("scroll"), r.$on("$destroy", function () { o.off("scroll touchmove", u) }) } } } }]); !function(i){"use strict";"function"==typeof define&&define.amd?define(["jquery"],i):"undefined"!=typeof exports?module.exports=i(require("jquery")):i(jQuery)}(function(i){"use strict";var e=window.Slick||{};(e=function(){var e=0;return function(t,o){var s,n=this;n.defaults={accessibility:!0,adaptiveHeight:!1,appendArrows:i(t),appendDots:i(t),arrows:!0,asNavFor:null,prevArrow:'',nextArrow:'',autoplay:!1,autoplaySpeed:3e3,centerMode:!1,centerPadding:"50px",cssEase:"ease",customPaging:function(e,t){return i('