/*!
* jquery.customSelect() - v0.4.1
* http://adam.co/lab/jquery/customselect/
* 2013-05-13
*
* Copyright 2013 Adam Coulombe
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @license http://www.gnu.org/licenses/gpl.html GPL2 License
*/
(function (a) { a.fn.extend({ customSelect: function (c) { if (typeof document.body.style.maxHeight === "undefined") { return this } var e = { customClass: "customSelect", mapClass: true, mapStyle: true }, c = a.extend(e, c), d = c.customClass, f = function (h, k) { var g = h.find(":selected"), j = k.children(":first"), i = g.html() || " "; j.html(i); if (g.attr("disabled")) { k.addClass(b("DisabledOption")) } else { k.removeClass(b("DisabledOption")) } setTimeout(function () { k.removeClass(b("Open")); a(document).off("mouseup." + b("Open")) }, 60) }, b = function (g) { return d + g }; return this.each(function () { var g = a(this), i = a("").addClass(b("Inner")), h = a(""); g.after(h.append(i)); h.addClass(d); if (c.mapClass) { h.addClass(g.attr("class")) } if (c.mapStyle) { h.attr("style", g.attr("style")) } g.addClass("hasCustomSelect").on("update", function () { f(g, h); var k = parseInt(g.outerWidth(), 10) - (parseInt(h.outerWidth(), 10) - parseInt(h.width(), 10)); h.css({ display: "inline-block" }); var j = h.outerHeight(); if (g.attr("disabled")) { h.addClass(b("Disabled")) } else { h.removeClass(b("Disabled")) } i.css({ width: k, display: "inline-block" }); g.css({ "-webkit-appearance": "menulist-button", width: h.outerWidth(), position: "absolute", opacity: 0, height: j, fontSize: h.css("font-size") }) }).on("change", function () { h.addClass(b("Changed")); f(g, h) }).on("keyup", function (j) { if (!h.hasClass(b("Open"))) { g.blur(); g.focus() } else { if (j.which == 13 || j.which == 27) { f(g, h) } } }).on("mousedown", function (j) { h.removeClass(b("Changed")) }).on("mouseup", function (j) { if (!h.hasClass(b("Open"))) { if (a("." + b("Open")).not(h).length > 0 && typeof InstallTrigger !== "undefined") { g.focus() } else { h.addClass(b("Open")); j.stopPropagation(); a(document).one("mouseup." + b("Open"), function (k) { if (k.target != g.get(0) && a.inArray(k.target, g.find("*").get()) < 0) { g.blur() } else { f(g, h) } }) } } }).focus(function () { h.removeClass(b("Changed")).addClass(b("Focus")) }).blur(function () { h.removeClass(b("Focus") + " " + b("Open")) }).hover(function () { h.addClass(b("Hover")) }, function () { h.removeClass(b("Hover")) }).trigger("update") }) } }) })(jQuery);
//var sortable = function () { "use strict"; function e(e, t, n) { if (void 0 === n) return e && e.h5s && e.h5s.data && e.h5s.data[t]; e.h5s = e.h5s || {}, e.h5s.data = e.h5s.data || {}, e.h5s.data[t] = n } function t(e) { e.h5s && delete e.h5s.data } function n(e, t, r) { if (e instanceof Array) for (var o = 0; o < e.length; ++o) n(e[o], t, r); else e.addEventListener(t, r), p(e).setData("event" + t, r) } function r(e, t) { if (e instanceof Array) for (var n = 0; n < e.length; ++n) r(e[n], t); else e.removeEventListener(t, p(e).getData("event" + t)), p(e).deleteData("event" + t) } function o(e, t, n) { if (e instanceof Array) for (var r = 0; r < e.length; ++r) o(e[r], t, n); else e.setAttribute(t, n) } function i(e, t) { if (e instanceof Array) for (var n = 0; n < e.length; ++n) i(e[n], t); else e.removeAttribute(t) } function a(e, t) { var n = this; if (void 0 === t && (t = 250), "function" != typeof e) throw new Error("You must provide a function as the first argument for throttle."); if ("number" != typeof t) throw new Error("You must provide a number as the second argument for throttle."); var r = null; return function () { for (var o = [], i = 0; i < arguments.length; i++) o[i] = arguments[i]; var a = Date.now(); (null === r || a - r >= t) && (r = a, e.apply(n, o)) } } function l(e, t) { if (t.composedPath) return t.composedPath().find(function (e) { return e.isSortable }); for (; !0 !== e.isSortable;) e = e.parentElement; return e } function s(t, n) { var r = e(t, "opts"), o, i = f(t.children, r.items).filter(function (e) { return e.contains(n) || e.shadowRoot && e.shadowRoot.contains(n) }); return i.length > 0 ? i[0] : n } function c(t, r) { var i = String(r); return r = r || {}, "string" == typeof t && (t = document.querySelectorAll(t)), t instanceof HTMLElement && (t = [t]), t = Array.prototype.slice.call(t), /serialize/.test(i) ? t.map(function (t) { var n = e(t, "opts"); return b(t, n.itemSerializer, n.containerSerializer) }) : (t.forEach(function (t) { if (/enable|disable|destroy/.test(i)) return c[i](t);["connectWith", "disableIEFix"].forEach(function (e) { Object.prototype.hasOwnProperty.call(r, e) && null !== r[e] && console.warn('HTML5Sortable: You are using the deprecated configuration "' + e + '". This will be removed in an upcoming version, make sure to migrate to the new options when updating.') }), r = Object.assign({}, I, p(t).config, r), p(t).config = r, e(t, "opts", r), t.isSortable = !0, G(t); var a = f(t.children, r.items), u; if (null !== r.placeholder && void 0 !== r.placeholder) { var w = document.createElement(t.tagName); r.placeholder instanceof HTMLElement ? w.appendChild(r.placeholder) : w.innerHTML = r.placeholder, u = w.children[0] } p(t).placeholder = T(t, u, r.placeholderClass), e(t, "items", r.items), r.acceptFrom ? e(t, "acceptFrom", r.acceptFrom) : r.connectWith && e(t, "connectWith", r.connectWith), U(t), o(a, "role", "option"), o(a, "aria-grabbed", "false"), S(t, !0), n(t, "dragstart", function (e) { var t = x(e); if (!0 !== t.isSortable && (e.stopImmediatePropagation(), (!r.handle || t.matches(r.handle)) && "false" !== t.getAttribute("draggable"))) { var n = l(t, e), i = s(n, t); W = f(n.children, r.items), z = W.indexOf(i), N = g(i, n.children), P = n, H(e, i, r.customDragImage), Y = L(i), O = C(i), i.classList.add(r.draggingClass), o(_ = R(i, n), "aria-grabbed", "true"), n.dispatchEvent(new CustomEvent("sortstart", { detail: { origin: { elementIndex: N, index: z, container: P }, item: _, originalTarget: t } })) } }), n(t, "dragenter", function (n) { var r = x(n), o = l(r, n); o && o !== j && (F = f(o.children, e(o, "items")).filter(function (e) { return e !== p(t).placeholder }), o.dispatchEvent(new CustomEvent("sortenter", { detail: { origin: { elementIndex: N, index: z, container: P }, destination: { container: o, itemsBeforeUpdate: F }, item: _, originalTarget: r } }))), j = o }), n(t, "dragend", function (n) { if (_) { _.classList.remove(r.draggingClass), o(_, "aria-grabbed", "false"), "true" === _.getAttribute("aria-copied") && "true" !== e(_, "dropped") && _.remove(), _.style.display = _.oldDisplay, delete _.oldDisplay; var i = Array.from(d.values()).map(function (e) { return e.placeholder }).filter(function (e) { return e instanceof HTMLElement }).filter(v)[0]; i && i.remove(), t.dispatchEvent(new CustomEvent("sortstop", { detail: { origin: { elementIndex: N, index: z, container: P }, item: _ } })), j = null, _ = null, Y = null, O = null } }), n(t, "drop", function (n) { if (A(t, _.parentElement)) { n.preventDefault(), n.stopPropagation(), e(_, "dropped", "true"); var o = Array.from(d.values()).map(function (e) { return e.placeholder }).filter(function (e) { return e instanceof HTMLElement }).filter(v)[0]; E(o, _), o.remove(), t.dispatchEvent(new CustomEvent("sortstop", { detail: { origin: { elementIndex: N, index: z, container: P }, item: _ } })); var i = p(t).placeholder, a = f(P.children, r.items).filter(function (e) { return e !== i }), l = !0 === this.isSortable ? this : this.parentElement, s = f(l.children, e(l, "items")).filter(function (e) { return e !== i }), c = g(_, Array.from(_.parentElement.children).filter(function (e) { return e !== i })), u = g(_, s); N === c && P === l || t.dispatchEvent(new CustomEvent("sortupdate", { detail: { origin: { elementIndex: N, index: z, container: P, itemsBeforeUpdate: W, items: a }, destination: { index: u, elementIndex: c, container: l, itemsBeforeUpdate: F, items: s }, item: _ } })) } }); var b = h(function (e, t, n, o) { if (_) if (r.forcePlaceholderSize && (p(e).placeholder.style.height = Y + "px", p(e).placeholder.style.width = O + "px"), Array.from(e.children).indexOf(t) > -1) { var i = L(t), a = C(t), l = g(p(e).placeholder, t.parentElement.children), s = g(t, t.parentElement.children); if (i > Y || a > O) { var c = i - Y, u = a - O, h = m(t).top, v = m(t).left; if (l < s && ("vertical" === r.orientation && o < h || "horizontal" === r.orientation && n < v)) return; if (l > s && ("vertical" === r.orientation && o > h + i - c || "horizontal" === r.orientation && n > v + a - u)) return } void 0 === _.oldDisplay && (_.oldDisplay = _.style.display), "none" !== _.style.display && (_.style.display = "none"); var w = !1; try { var b = m(t).top + t.offsetHeight / 2, T = m(t).left + t.offsetWidth / 2; w = "vertical" === r.orientation && o >= b || "horizontal" === r.orientation && n >= T } catch (e) { w = l < s } w ? E(t, p(e).placeholder) : y(t, p(e).placeholder), Array.from(d.values()).filter(function (e) { return void 0 !== e.placeholder }).forEach(function (t) { t.placeholder !== p(e).placeholder && t.placeholder.remove() }) } else { var M = Array.from(d.values()).filter(function (e) { return void 0 !== e.placeholder }).map(function (e) { return e.placeholder }); -1 !== M.indexOf(t) || e !== t || f(t.children, r.items).length || (M.forEach(function (e) { return e.remove() }), t.appendChild(p(e).placeholder)) } }, r.debounce), M = function (t) { var n = t.target, r = !0 === n.isSortable ? n : l(n, t); if (n = s(r, n), _ && A(r, _.parentElement) && "true" !== e(r, "_disabled")) { var o = e(r, "opts"); parseInt(o.maxItems) && f(r.children, e(r, "items")).length >= parseInt(o.maxItems) && _.parentElement !== r || (t.preventDefault(), t.stopPropagation(), t.dataTransfer.dropEffect = !0 === p(r).getConfig("copy") ? "copy" : "move", b(r, n, t.pageX, t.pageY)) } }; n(a.concat(t), "dragover", M), n(a.concat(t), "dragenter", M) }), t) } var f = function (e, t) { if (!(e instanceof NodeList || e instanceof HTMLCollection || e instanceof Array)) throw new Error("You must provide a nodeList/HTMLCollection/Array of elements to be filtered."); return "string" != typeof t ? Array.from(e) : Array.from(e).filter(function (e) { return 1 === e.nodeType && e.matches(t) }) }, d = new Map, u = function () { function e() { this._config = new Map, this._placeholder = void 0, this._data = new Map } return Object.defineProperty(e.prototype, "config", { get: function () { var e = {}; return this._config.forEach(function (t, n) { e[n] = t }), e }, set: function (e) { if ("object" != typeof e) throw new Error("You must provide a valid configuration object to the config setter."); var t = Object.assign({}, e); this._config = new Map(Object.entries(t)) }, enumerable: !0, configurable: !0 }), e.prototype.setConfig = function (e, t) { if (!this._config.has(e)) throw new Error("Trying to set invalid configuration item: " + e); this._config.set(e, t) }, e.prototype.getConfig = function (e) { if (!this._config.has(e)) throw new Error("Invalid configuration item requested: " + e); return this._config.get(e) }, Object.defineProperty(e.prototype, "placeholder", { get: function () { return this._placeholder }, set: function (e) { if (!(e instanceof HTMLElement) && null !== e) throw new Error("A placeholder must be an html element or null."); this._placeholder = e }, enumerable: !0, configurable: !0 }), e.prototype.setData = function (e, t) { if ("string" != typeof e) throw new Error("The key must be a string."); this._data.set(e, t) }, e.prototype.getData = function (e) { if ("string" != typeof e) throw new Error("The key must be a string."); return this._data.get(e) }, e.prototype.deleteData = function (e) { if ("string" != typeof e) throw new Error("The key must be a string."); return this._data.delete(e) }, e }(), p = function (e) { if (!(e instanceof HTMLElement)) throw new Error("Please provide a sortable to the store function."); return d.has(e) || d.set(e, new u), d.get(e) }, m = function (e) { if (!e.parentElement || 0 === e.getClientRects().length) throw new Error("target element must be part of the dom"); var t = e.getClientRects()[0]; return { left: t.left + window.pageXOffset, right: t.right + window.pageXOffset, top: t.top + window.pageYOffset, bottom: t.bottom + window.pageYOffset } }, h = function (e, t) { var n; return void 0 === t && (t = 0), function () { for (var r = [], o = 0; o < arguments.length; o++) r[o] = arguments[o]; clearTimeout(n), n = setTimeout(function () { e.apply(void 0, r) }, t) } }, g = function (e, t) { if (!(e instanceof HTMLElement && (t instanceof NodeList || t instanceof HTMLCollection || t instanceof Array))) throw new Error("You must provide an element and a list of elements."); return Array.from(t).indexOf(e) }, v = function (e) { if (!(e instanceof HTMLElement)) throw new Error("Element is not a node element."); return null !== e.parentNode }, w = function (e, t, n) { if (!(e instanceof HTMLElement && e.parentElement instanceof HTMLElement)) throw new Error("target and element must be a node"); e.parentElement.insertBefore(t, "before" === n ? e : e.nextElementSibling) }, y = function (e, t) { return w(e, t, "before") }, E = function (e, t) { return w(e, t, "after") }, b = function (t, n, r) { if (void 0 === n && (n = function (e, t) { return e }), void 0 === r && (r = function (e) { return e }), !(t instanceof HTMLElement) || !0 == !t.isSortable) throw new Error("You need to provide a sortableContainer to be serialized."); if ("function" != typeof n || "function" != typeof r) throw new Error("You need to provide a valid serializer for items and the container."); var o, i = e(t, "opts").items, a = f(t.children, i), l = a.map(function (e) { return { parent: t, node: e, html: e.outerHTML, index: g(e, a) } }), s; return { container: r({ node: t, itemCount: l.length }), items: l.map(function (e) { return n(e, t) }) } }, T = function (e, t, n) { var r; if (void 0 === n && (n = "sortable-placeholder"), !(e instanceof HTMLElement)) throw new Error("You must provide a valid element as a sortable."); if (!(t instanceof HTMLElement) && void 0 !== t) throw new Error("You must provide a valid element as a placeholder or set ot to undefined."); return void 0 === t && (["UL", "OL"].includes(e.tagName) ? t = document.createElement("li") : ["TABLE", "TBODY"].includes(e.tagName) ? (t = document.createElement("tr")).innerHTML = '
' : t = document.createElement("div")), "string" == typeof n && (r = t.classList).add.apply(r, n.split(" ")), t }, L = function (e) { if (!(e instanceof HTMLElement)) throw new Error("You must provide a valid dom element"); var t = window.getComputedStyle(e); return ["height", "padding-top", "padding-bottom"].map(function (e) { var n = parseInt(t.getPropertyValue(e), 10); return isNaN(n) ? 0 : n }).reduce(function (e, t) { return e + t }) }, C = function (e) { if (!(e instanceof HTMLElement)) throw new Error("You must provide a valid dom element"); var t = window.getComputedStyle(e); return ["width", "padding-left", "padding-right"].map(function (e) { var n = parseInt(t.getPropertyValue(e), 10); return isNaN(n) ? 0 : n }).reduce(function (e, t) { return e + t }) }, M = function (e, t) { if (!(e instanceof Array)) throw new Error("You must provide a Array of HTMLElements to be filtered."); return "string" != typeof t ? e : e.filter(function (e) { return e.querySelector(t) instanceof HTMLElement || e.shadowRoot && e.shadowRoot.querySelector(t) instanceof HTMLElement }).map(function (e) { return e.querySelector(t) || e.shadowRoot && e.shadowRoot.querySelector(t) }) }, x = function (e) { return e.composedPath && e.composedPath()[0] || e.target }, D = function (e, t, n) { return { element: e, posX: n.pageX - t.left, posY: n.pageY - t.top } }, H = function (e, t, n) { if (!(e instanceof Event)) throw new Error("setDragImage requires a DragEvent as the first argument."); if (!(t instanceof HTMLElement)) throw new Error("setDragImage requires the dragged element as the second argument."); if (n || (n = D), e.dataTransfer && e.dataTransfer.setDragImage) { var r, o = n(t, m(t), e); if (!(o.element instanceof HTMLElement) || "number" != typeof o.posX || "number" != typeof o.posY) throw new Error("The customDragImage function you provided must return and object with the properties element[string], posX[integer], posY[integer]."); e.dataTransfer.effectAllowed = "copyMove", e.dataTransfer.setData("text/plain", x(e).id), e.dataTransfer.setDragImage(o.element, o.posX, o.posY) } }, A = function (e, t) { if (!0 === e.isSortable) { var n = p(e).getConfig("acceptFrom"); if (null !== n && !1 !== n && "string" != typeof n) throw new Error('HTML5Sortable: Wrong argument, "acceptFrom" must be "null", "false", or a valid selector string.'); if (null !== n) return !1 !== n && n.split(",").filter(function (e) { return e.length > 0 && t.matches(e) }).length > 0; if (e === t) return !0; if (void 0 !== p(e).getConfig("connectWith") && null !== p(e).getConfig("connectWith")) return p(e).getConfig("connectWith") === p(t).getConfig("connectWith") } return !1 }, I = { items: null, connectWith: null, disableIEFix: null, acceptFrom: null, copy: !1, placeholder: null, placeholderClass: "sortable-placeholder", draggingClass: "sortable-dragging", hoverClass: !1, debounce: 0, throttleTime: 100, maxItems: 0, itemSerializer: void 0, containerSerializer: void 0, customDragImage: null, orientation: "vertical" }, S = function (e, t) { if ("string" == typeof p(e).getConfig("hoverClass")) { var o = p(e).getConfig("hoverClass").split(" "); !0 === t ? (n(e, "mousemove", a(function (t) { 0 === t.buttons && f(e.children, p(e).getConfig("items")).forEach(function (e) { var n, r; e !== t.target ? (n = e.classList).remove.apply(n, o) : (r = e.classList).add.apply(r, o) }) }, p(e).getConfig("throttleTime"))), n(e, "mouseleave", function () { f(e.children, p(e).getConfig("items")).forEach(function (e) { var t; (t = e.classList).remove.apply(t, o) }) })) : (r(e, "mousemove"), r(e, "mouseleave")) } }, _, Y, O, P, z, N, W, j, F, q = function (e) { r(e, "dragstart"), r(e, "dragend"), r(e, "dragover"), r(e, "dragenter"), r(e, "drop"), r(e, "mouseenter"), r(e, "mouseleave") }, R = function (e, t) { var n = e; return !0 === p(t).getConfig("copy") && (o(n = e.cloneNode(!0), "aria-copied", "true"), e.parentElement.appendChild(n), n.style.display = "none", n.oldDisplay = e.style.display), n }, X = function (e) { t(e), i(e, "aria-dropeffect") }, B = function (e) { i(e, "aria-grabbed"), i(e, "aria-copied"), i(e, "draggable"), i(e, "role") }, k = function (t) { var n = e(t, "opts") || {}, o = f(t.children, n.items), i = M(o, n.handle); r(t, "dragover"), r(t, "dragenter"), r(t, "dragstart"), r(t, "dragend"), r(t, "drop"), X(t), r(i, "mousedown"), q(o), B(o), t.isSortable = !1 }, U = function (t) { var r = e(t, "opts"), i = f(t.children, r.items), a = M(i, r.handle), l; (o(t, "aria-dropeffect", "move"), e(t, "_disabled", "false"), o(a, "draggable", "true"), !1 === r.disableIEFix) && ("function" == typeof (document || window.document).createElement("span").dragDrop && n(a, "mousedown", function () { if (-1 !== i.indexOf(this)) this.dragDrop(); else { for (var e = this.parentElement; -1 === i.indexOf(e);) e = e.parentElement; e.dragDrop() } })) }, V = function (t) { var n = e(t, "opts"), i = f(t.children, n.items), a = M(i, n.handle); o(t, "aria-dropeffect", "none"), e(t, "_disabled", "true"), o(a, "draggable", "false"), r(a, "mousedown") }, G = function (t) { var n = e(t, "opts"), o = f(t.children, n.items), i = M(o, n.handle); e(t, "_disabled", "false"), q(o), r(i, "mousedown"), r(t, "dragover"), r(t, "dragenter"), r(t, "drop") }; return c.destroy = function (e) { k(e) }, c.enable = function (e) { U(e) }, c.disable = function (e) { V(e) }, c.__testing = { _data: e, _removeItemEvents: q, _removeItemData: B, _removeSortableData: X }, c }();
/*
* HTML5 Sortable jQuery Plugin
* http://farhadi.ir/projects/html5sortable
*
* Copyright 2012, Ali Farhadi
* Released under the MIT license.
*/
(function($) {
var dragging, placeholders = $();
$.fn.sortable = function(options) {
var method = String(options);
options = $.extend({
connectWith: false
}, options);
return this.each(function() {
if (/^enable|disable|destroy$/.test(method)) {
var items = $(this).children($(this).data('items')).attr('draggable', method == 'enable');
if (method == 'destroy') {
items.add(this).removeData('connectWith items')
.off('dragstart.h5s dragend.h5s selectstart.h5s dragover.h5s dragenter.h5s drop.h5s');
}
return;
}
var isHandle, index, items = $(this).children(options.items);
var placeholder = $('<' + (/^ul|ol$/i.test(this.tagName) ? 'li' : 'div') + ' class="sortable-placeholder">');
items.find(options.handle).mousedown(function() {
isHandle = true;
}).mouseup(function() {
isHandle = false;
});
$(this).data('items', options.items)
placeholders = placeholders.add(placeholder);
if (options.connectWith) {
$(options.connectWith).add(this).data('connectWith', options.connectWith);
}
items.attr('draggable', 'true').on('dragstart.h5s', function(e) {
e.stopPropagation(); // Mod to handle nested sortables - DC
if (options.handle && !isHandle) {
return false;
}
isHandle = false;
var dt = e.originalEvent.dataTransfer;
dt.effectAllowed = 'move';
dt.setData('Text', 'dummy');
index = (dragging = $(this)).addClass('sortable-dragging').index();
//Custom addition by Rob to hold the index before it was moved
$(this).attr('data-previndex', index);
}).on('dragend.h5s', function() {
dragging = $(this);
dragging.removeClass('sortable-dragging').show();
placeholders.detach();
if (index != dragging.index()) {
items.parent().trigger('sortupdate', {item: dragging});
}
dragging = null;
}).not('a[href], img').on('selectstart.h5s', function() {
this.dragDrop && this.dragDrop();
return false;
}).end().add([this, placeholder]).on('dragover.h5s dragenter.h5s drop.h5s', function(e) {
if (!items.is(dragging) && options.connectWith !== $(dragging).parent().data('connectWith')) {
return true;
}
if (e.type == 'drop') {
e.stopPropagation();
placeholders.filter(':visible').after(dragging);
return false;
}
e.preventDefault();
e.originalEvent.dataTransfer.dropEffect = 'move';
if (items.is(this)) {
if (options.forcePlaceholderSize) {
placeholder.height(dragging.outerHeight());
}
dragging.hide();
$(this)[placeholder.index() < $(this).index() ? 'after' : 'before'](placeholder);
placeholders.not(placeholder).detach();
} else if (!placeholders.is(this) && !$(this).children(options.items).length) {
placeholders.detach();
$(this).append(placeholder);
}
return false;
});
});
};
})(jQuery);
/*
* jQuery formatDateTime Plugin
*
* Copyright 2012 Adam Gschwender
* Dual licensed under the MIT or GPL Version 2 licenses.
*/
; (function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else {
// Browser globals: jQuery or jQuery-like library, such as Zepto
factory(window.jQuery || window.$);
}
} (function ($) {
var defaults = {
monthNames: ['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November',
'December'],
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',
'Friday', 'Saturday'],
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
ampmNames: ['AM', 'PM'],
attribute: 'data-datetime',
formatAttribute: 'data-dateformat'
};
var ticksTo1970 = (((1970 - 1) * 365 + Math.floor(1970 / 4)
- Math.floor(1970 / 100)
+ Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000);
var formatDateTime = function (format, date, settings) {
var output = '';
var literal = false;
var iFormat = 0;
// Check whether a format character is doubled
var lookAhead = function (match) {
var matches = (iFormat + 1 < format.length
&& format.charAt(iFormat + 1) == match);
if (matches) {
iFormat++;
}
return matches;
};
// Format a number, with leading zero if necessary
var formatNumber = function (match, value, len) {
var num = '' + value;
if (lookAhead(match)) {
while (num.length < len) {
num = '0' + num;
}
}
return num;
};
// Format a name, short or long as requested
var formatName = function (match, value, shortNames, longNames) {
return (lookAhead(match) ? longNames[value] : shortNames[value]);
};
for (iFormat = 0; iFormat < format.length; iFormat++) {
if (literal) {
if (format.charAt(iFormat) == "'" && !lookAhead("'")) {
literal = false;
}
else {
output += format.charAt(iFormat);
}
} else {
switch (format.charAt(iFormat)) {
case 'a':
output += date.getHours() < 12
? settings.ampmNames[0]
: settings.ampmNames[1];
break;
case 'd':
output += formatNumber('d', date.getDate(), 2);
break;
case 'D':
output += formatName('D',
date.getDay(),
settings.dayNamesShort,
settings.dayNames);
break;
case 'o':
var end = new Date(date.getFullYear(),
date.getMonth(),
date.getDate()).getTime();
var start = new Date(date.getFullYear(), 0, 0).getTime();
output += formatNumber(
'o', Math.round((end - start) / 86400000), 3);
break;
case 'g':
var hour = date.getHours() % 12;
output += formatNumber('g', (hour === 0 ? 12 : hour), 2);
break;
case 'h':
output += formatNumber('h', date.getHours(), 2);
break;
case 'u':
output += formatNumber('u', date.getMilliseconds(), 3);
break;
case 'i':
output += formatNumber('i', date.getMinutes(), 2);
break;
case 'm':
output += formatNumber('m', date.getMonth() + 1, 2);
break;
case 'M':
output += formatName('M',
date.getMonth(),
settings.monthNamesShort,
settings.monthNames);
break;
case 's':
output += formatNumber('s', date.getSeconds(), 2);
break;
case 'y':
output += (lookAhead('y')
? date.getFullYear()
: (date.getYear() % 100 < 10 ? '0' : '')
+ date.getYear() % 100);
break;
case '@':
output += date.getTime();
break;
case '!':
output += date.getTime() * 10000 + ticksTo1970;
break;
case "'":
if (lookAhead("'")) {
output += "'";
} else {
literal = true;
}
break;
default:
output += format.charAt(iFormat);
}
}
}
return output;
};
$.fn.formatDateTime = function (format, settings) {
settings = $.extend({}, defaults, settings);
var date = $(this).attr(settings.attribute);
// Use explicit format string first, then fallback to format attribute
format = format || $(this).attr(settings.formatAttribute);
if (typeof date === 'undefined' || date === false) {
date = $(this).text();
}
if (date === '') {
$(this).text('');
} else {
$(this).text(formatDateTime(format, new Date(date), settings));
}
return this;
};
/**
Format a date object into a string value.
The format can be combinations of the following:
a - Ante meridiem and post meridiem
d - day of month (no leading zero)
dd - day of month (two digit)
o - day of year (no leading zeros)
oo - day of year (three digit)
D - day name short
DD - day name long
g - 12-hour hour format of day (no leading zero)
gg - 12-hour hour format of day (two digit)
h - 24-hour hour format of day (no leading zero)
hh - 24-hour hour format of day (two digit)
u - millisecond of second (no leading zeros)
uu - millisecond of second (three digit)
i - minute of hour (no leading zero)
ii - minute of hour (two digit)
m - month of year (no leading zero)
mm - month of year (two digit)
M - month name short
MM - month name long
s - second of minute (no leading zero)
ss - second of minute (two digit)
y - year (two digit)
yy - year (four digit)
@ - Unix timestamp (ms since 01/01/1970)
! - Windows ticks (100ns since 01/01/0001)
'...' - literal text
'' - single quote
@param format string - the desired format of the date
@param date Date - the date value to format
@param settings Object - attributes include:
ampmNames string[2] - am/pm (optional)
dayNamesShort string[7] - abbreviated names of the days
from Sunday (optional)
dayNames string[7] - names of the days from Sunday (optional)
monthNamesShort string[12] - abbreviated names of the months
(optional)
monthNames string[12] - names of the months (optional)
attribute string - Attribute which stores datetime, defaults
to data-datetime, only valid when called
on dom element(s). If not present,
uses text.
@return string - the date in the above format
*/
$.formatDateTime = function (format, date, settings) {
settings = $.extend({}, defaults, settings);
if (!date) { return ''; }
return formatDateTime(format, date, settings);
};
}));
$(function () {
//Method to check if select has an option in it
//$('#ctl').hasOption('a_value');
$.fn.hasOption = function (val) {
if ($(this).is('select')) {
return $(this).find('option').filter(function () {
return $(this).val() === val;
}).length !== 0;
} else
return false;
}
//Method to add an option to a select
//$('#ctl').addOption('Some text to show', 'a_value');
$.fn.addOption = function (txt, val) {
if ($(this).is('select') && !$(this).hasOption(val)) {
var o = new Option(txt, val);
$(this).append(o);
}
};
//Method to clear all options from a select
//$('#ctl').clearOptions(false);
$.fn.clearOptions = function (inclFirst) {
if ($(this).is('select')) {
if (!inclFirst)
$(this).find('option:not(:first)').remove();
else
$(this).empty();
}
};
//Method to add mulitple options to a select
//$('#ctl').addOptions(["v1~^~t1", "v2~^~t2"], '~^~');
$.fn.addOptions = function (data, delimiter) {
if ($(this).is('select')) {
if (delimiter == undefined || delimiter == null)
delimiter = '~^~';
var _this = $(this);
$.each(data, function (index, value) {
var itm = value.split(delimiter);
_this.addOption(itm[1], itm[0]);
});
}
};
//Method to set the selected value on a custom select
//$('#ctl').setVal('a_value');
$.fn.setVal = function (val) {
if ($(this).is('select')) {
$(this).val(val);
$(this).next('span.customSelect').find('span.customSelectInner').text($(this).find('option:selected').text());
}
};
$.fn.exists = function () {
return $(this).length > 0;
};
$.fn.scrollTo = function (additionalOffset) {
if (additionalOffset == undefined)
additionalOffset = 0;
$('html,body').animate({ scrollTop: $(this).offset().top - additionalOffset });
};
$.fn.encHTML = function () {
return $(this).html().replace(/&/g, '&').replace(//g, '>');
};
$.fn.decHTML = function () {
return $(this).html().replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
};
//Converts querystring to object
$.QueryString = (function (a) {
if (a == "") return {};
var b = {};
for (var i = 0; i < a.length; ++i) {
var p = a[i].split('=');
if (p.length != 2) continue;
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
}
return b;
})(window.location.search.substr(1).split('&'));
//http://maximeparmentier.com/2012/11/06/bind-show-hide-events-with-jquery/
$.each(['show', 'hide'], function (i, ev) {
var el = $.fn[ev];
$.fn[ev] = function () {
this.trigger(ev);
return el.apply(this, arguments);
};
});
//http://stackoverflow.com/a/14084869/880792
//Adds an event that can used to know when the show class has been added
var origAddClassMethod = $.fn.addClass;
$.fn.addClass = function () {
var result = origAddClassMethod.apply(this, arguments);
if ($.inArray('show', arguments) >= 0)
$(this).trigger('showCSS');
return result;
}
//http://stackoverflow.com/a/14084869/880792
//Adds an event that can used to know when the show class has been removed
var origRemoveClassMethod = $.fn.removeClass;
$.fn.removeClass = function () {
var result = origRemoveClassMethod.apply(this, arguments);
if ($.inArray('show', arguments) >= 0)
$(this).trigger('hideCSS');
return result;
}
});
//Default parameters to make and AJAX call
var ajaxParams = {
url: 'https://mir.mts360.com/api/ajax.asmx/',
type: 'post',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify({}),
dataType: 'json',
sync: true
};
String.prototype.endsWith = function (str) { return (this.match(str + "$") == str) }
String.prototype.startsWith = function (str) { return (this.match("$" + str) == str) }
String.prototype.stripHTML = function (nbspSwapChar) {
var reg = /(<([^>]+)>)/ig;
return this.replace(reg, '').replace(/ /g, nbspSwapChar);
}
String.prototype.replaceAll = function (search, replace) {
if (replace === undefined) {
return this.toString();
}
return this.replace(new RegExp('[' + search + ']', 'g'), replace);
};
String.prototype.encHTML = function () {
var d = $('').html(this);
return $(d).html();
}
String.prototype.decHTML = function () {
var d = $('').html(this);
return $(d).text();
}
function capitaliseSentences(txt) {
capText = txt.toLowerCase();
capText = capText.replace("
", "
. ");
capText = capText.replace(" ", " ");
console.log('capText', capText);
var wordSplit = '. ';
var wordArray = capText.split(wordSplit);
var numWords = wordArray.length;
for (x = 0; x < numWords; x++) {
wordArray[x] = wordArray[x].replace(wordArray[x].charAt(0), wordArray[x].charAt(0).toUpperCase());
if (x == 0) {
capText = wordArray[x] + ". ";
} else if (x != numWords -1) {
capText = capText + wordArray[x] + ". ";
} else if (x == numWords -1) {
capText = capText+wordArray[x];
}
}
capText = capText.replace("