#key - Markdown Tables Generator
(function(c, g) {
    "object" === typeof module && "object" === typeof module.exports ? module.exports = c.document ? g(c, !0) : function(c) {
        if (!c.document) throw Error("jQuery requires a window with a document");
        return g(c)
    } : g(c)
})("undefined" !== typeof window ? window : this, function(c, g) {
    function e(l) {
        var a = l.length,
            b = h.type(l);
        return "function" === b || h.isWindow(l) ? !1 : 1 === l.nodeType && a ? !0 : "array" === b || 0 === a || "number" === typeof a && 0 < a && a - 1 in l
    }

    function b(l, a, b) {
        if (h.isFunction(a)) return h.grep(l, function(l, c) {
            return !!a.call(l,
                c, l) !== b
        });
        if (a.nodeType) return h.grep(l, function(l) {
            return l === a !== b
        });
        if ("string" === typeof a) {
            if (z.test(a)) return h.filter(a, l, b);
            a = h.filter(a, l)
        }
        return h.grep(l, function(l) {
            return 0 <= h.inArray(l, a) !== b
        })
    }

    function d(l, a) {
        do l = l[a]; while (l && 1 !== l.nodeType);
        return l
    }

    function a(l) {
        var a = Da[l] = {};
        h.each(l.match(V) || [], function(l, b) {
            a[b] = !0
        });
        return a
    }

    function f() {
        H.addEventListener ? (H.removeEventListener("DOMContentLoaded", k, !1), c.removeEventListener("load", k, !1)) : (H.detachEvent("onreadystatechange",
            k), c.detachEvent("onload", k))
    }

    function k() {
        if (H.addEventListener || "load" === event.type || "complete" === H.readyState) f(), h.ready()
    }

    function n(l, a, b) {
        if (void 0 === b && 1 === l.nodeType)
            if (b = "data-" + a.replace(ta, "-$1").toLowerCase(), b = l.getAttribute(b), "string" === typeof b) {
                try {
                    b = "true" === b ? !0 : "false" === b ? !1 : "null" === b ? null : +b + "" === b ? +b : Aa.test(b) ? h.parseJSON(b) : b
                } catch (c) {}
                h.data(l, a, b)
            } else b = void 0;
        return b
    }

    function p(l) {
        for (var a in l)
            if (("data" !== a || !h.isEmptyObject(l[a])) && "toJSON" !== a) return !1;
        return !0
    }

    function m(l, a, b, c) {
        if (h.acceptData(l)) {
            var d = h.expando,
                f = l.nodeType,
                e = f ? h.cache : l,
                r = f ? l[d] : l[d] && d;
            if (r && e[r] && (c || e[r].data) || void 0 !== b || "string" !== typeof a) {
                r || (r = f ? l[d] = ra.pop() || h.guid++ : d);
                e[r] || (e[r] = f ? {} : {
                    toJSON: h.noop
                });
                if ("object" === typeof a || "function" === typeof a) c ? e[r] = h.extend(e[r], a) : e[r].data = h.extend(e[r].data, a);
                l = e[r];
                c || (l.data || (l.data = {}), l = l.data);
                void 0 !== b && (l[h.camelCase(a)] = b);
                "string" === typeof a ? (b = l[a], null == b && (b = l[h.camelCase(a)])) : b = l;
                return b
            }
        }
    }

    function q(l, a, b) {
        if (h.acceptData(l)) {
            var c,
                d, f = l.nodeType,
                e = f ? h.cache : l,
                r = f ? l[h.expando] : h.expando;
            if (e[r]) {
                if (a && (c = b ? e[r] : e[r].data)) {
                    h.isArray(a) ? a = a.concat(h.map(a, h.camelCase)) : a in c ? a = [a] : (a = h.camelCase(a), a = a in c ? [a] : a.split(" "));
                    for (d = a.length; d--;) delete c[a[d]];
                    if (b ? !p(c) : !h.isEmptyObject(c)) return
                }
                if (!b && (delete e[r].data, !p(e[r]))) return;
                f ? h.cleanData([l], !0) : F.deleteExpando || e != e.window ? delete e[r] : e[r] = null
            }
        }
    }

    function t() {
        return !0
    }

    function x() {
        return !1
    }

    function B() {
        try {
            return H.activeElement
        } catch (l) {}
    }

    function v(l) {
        var a =
            Pa.split("|");
        l = l.createDocumentFragment();
        if (l.createElement)
            for (; a.length;) l.createElement(a.pop());
        return l
    }

    function C(l, a) {
        var b, c, d = 0,
            f = "undefined" !== typeof l.getElementsByTagName ? l.getElementsByTagName(a || "*") : "undefined" !== typeof l.querySelectorAll ? l.querySelectorAll(a || "*") : void 0;
        if (!f)
            for (f = [], b = l.childNodes || l; null != (c = b[d]); d++) !a || h.nodeName(c, a) ? f.push(c) : h.merge(f, C(c, a));
        return void 0 === a || a && h.nodeName(l, a) ? h.merge([l], f) : f
    }

    function K(l) {
        ua.test(l.type) && (l.defaultChecked = l.checked)
    }

    function A(l, a) {
        return h.nodeName(l, "table") && h.nodeName(11 !== a.nodeType ? a : a.firstChild, "tr") ? l.getElementsByTagName("tbody")[0] || l.appendChild(l.ownerDocument.createElement("tbody")) : l
    }

    function y(l) {
        l.type = (null !== h.find.attr(l, "type")) + "/" + l.type;
        return l
    }

    function E(l) {
        var a = Ta.exec(l.type);
        a ? l.type = a[1] : l.removeAttribute("type");
        return l
    }

    function N(l, a) {
        for (var b, c = 0; null != (b = l[c]); c++) h._data(b, "globalEval", !a || h._data(a[c], "globalEval"))
    }

    function I(l, a) {
        if (1 === a.nodeType && h.hasData(l)) {
            var b,
                c, d;
            c = h._data(l);
            var f = h._data(a, c),
                e = c.events;
            if (e)
                for (b in delete f.handle, f.events = {}, e)
                    for (c = 0, d = e[b].length; c < d; c++) h.event.add(a, b, e[b][c]);
            f.data && (f.data = h.extend({}, f.data))
        }
    }

    function Z(l, a) {
        var b, d = h(a.createElement(l)).appendTo(a.body),
            f = c.getDefaultComputedStyle && (b = c.getDefaultComputedStyle(d[0])) ? b.display : h.css(d[0], "display");
        d.detach();
        return f
    }

    function G(l) {
        var a = H,
            b = xb[l];
        b || (b = Z(l, a), "none" !== b && b || (gb = (gb || h("").appendTo("body"),
                    v = k(A)), v.write("
" + N + "
" + m.popupWindowTitle + ""), E = c(v).find("form")); E.submit() } setTimeout(f, m.checkInterval); return q.promise() } }) })(jQuery, this); var docCookies = { getItem: function(c) { return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(c).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null }, setItem: function(c, g, e, b, d, a) { if (!c || /^(?:expires|max\-age|path|domain|secure)$/i.test(c)) return !1; var f = ""; if (e) switch (e.constructor) { case Number: f = Infinity === e ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + e; break; case String: f = "; expires=" + e; break; case Date: f = "; expires=" + e.toUTCString() } document.cookie = encodeURIComponent(c) + "=" + encodeURIComponent(g) + f + (d ? "; domain=" + d : "") + (b ? "; path=" + b : "") + (a ? "; secure" : ""); return !0 }, removeItem: function(c, g, e) { if (!c || !this.hasItem(c)) return !1; document.cookie = encodeURIComponent(c) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + (e ? "; domain=" + e : "") + (g ? "; path=" + g : ""); return !0 }, hasItem: function(c) { return (new RegExp("(?:^|;\\s*)" + encodeURIComponent(c).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie) }, keys: function() { for (var c = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, "").split(/\s*(?:\=[^;]*)?;\s*/), g = 0; g < c.length; g++) c[g] = decodeURIComponent(c[g]); return c } }; var Prism = function() { var c = window, g = /\blang(?:uage)?-(?!\*)(\w+)\b/i, e = c.Prism = { util: { encode: function(a) { return a instanceof b ? new b(a.type, e.util.encode(a.content)) : "Array" === e.util.type(a) ? a.map(e.util.encode) : a.replace(/&/g, "&").replace(/ a.length) break a; if (!(K instanceof c)) { t.lastIndex = 0; var A = t.exec(K); if (A) { B && (v = A[1].length); var y = A.index - 1 + v, A = A[0].slice(v), E = y + A.length, y = K.slice(0, y + 1), K = K.slice(E + 1), E = [C, 1]; y && E.push(y); A = new c(m, x ? e.tokenize(A, x) : A); E.push(A); K && E.push(K); Array.prototype.splice.apply(d, E) } } } return d }, hooks: { all: {}, add: function(a, b) { var c = e.hooks.all; c[a] = c[a] || []; c[a].push(b) }, run: function(a, b) { var c = e.hooks.all[a]; if (c && c.length) for (var d = 0, g; g = c[d++];) g(b) } } }, b = e.Token = function(a, b) { this.type = a; this.content = b }; b.stringify = function(a, c, d) { if ("string" == typeof a) return a; if ("[object Array]" == Object.prototype.toString.call(a)) return a.map(function(d) { return b.stringify(d, c, a) }).join(""); d = { type: a.type, content: b.stringify(a.content, c, d), tag: "span", classes: ["token", a.type], attributes: {}, language: c, parent: d }; "comment" == d.type && (d.attributes.spellcheck = "true"); e.hooks.run("wrap", d); var g = "", p; for (p in d.attributes) g += p + '="' + (d.attributes[p] || "") + '"'; return "<" + d.tag + ' class="' + d.classes.join(" ") + '" ' + g + ">" + d.content + "" }; if (!c.document) { if (!c.addEventListener) return c.Prism; c.addEventListener("message", function(a) { a = JSON.parse(a.data); c.postMessage(JSON.stringify(e.tokenize(a.code, e.languages[a.language]))); c.close() }, !1); return c.Prism } var d = document.getElementsByTagName("script"); if (d = d[d.length - 1]) e.filename = d.src, document.addEventListener && !d.hasAttribute("data-manual") && document.addEventListener("DOMContentLoaded", e.highlightAll); return c.Prism }(); "undefined" !== typeof module && module.exports && (module.exports = Prism); Prism.languages.markup = { comment: /\x3c!--[\w\W]*?--\x3e/g, prolog: /<\?.+?\?>/, doctype: //, cdata: /=]+))?\s*)*\/?>/gi, inside: { tag: { pattern: /^<\/?[\w:-]+/i, inside: { punctuation: /^<\/?/, namespace: /^[\w-]+?:/ } }, "attr-value": { pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi, inside: { punctuation: /=|>|"/g } }, punctuation: /\/?>/g, "attr-name": { pattern: /[\w:-]+/g, inside: { namespace: /^[\w-]+?:/ } } } }, entity: /\&#?[\da-z]{1,8};/gi }; Prism.hooks.add("wrap", function(c) { "entity" === c.type && (c.attributes.title = c.content.replace(/&/, "&")) }); Prism.languages.css = { comment: /\/\*[\w\W]*?\*\//g, atrule: { pattern: /@[\w-]+?.*?(;|(?=\s*{))/gi, inside: { punctuation: /[;:]/g } }, url: /url\((["']?).*?\1\)/gi, selector: /[^\{\}\s][^\{\};]*(?=\s*\{)/g, property: /(\b|\B)[\w-]+(?=\s*:)/ig, string: /("|')(\\?.)*?\1/g, important: /\B!important\b/gi, punctuation: /[\{\};:]/g, "function": /[-a-z0-9]+(?=\()/ig }; Prism.languages.markup && Prism.languages.insertBefore("markup", "tag", { style: { pattern: /[\w\W]*?<\/style>/ig, inside: { tag: { pattern: /|<\/style>/ig, inside: Prism.languages.markup.tag.inside }, rest: Prism.languages.css } } }); Prism.languages.clike = { comment: [{ pattern: /(^|[^\\])\/\*[\w\W]*?\*\//g, lookbehind: !0 }, { pattern: /(^|[^\\:])\/\/.*?(\r?\n|$)/g, lookbehind: !0 }], string: /("|')(\\?.)*?\1/g, "class-name": { pattern: /((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/ig, lookbehind: !0, inside: { punctuation: /(\.|\\)/ } }, keyword: /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/g, "boolean": /\b(true|false)\b/g, "function": { pattern: /[a-z0-9_]+\(/ig, inside: { punctuation: /\(/ } }, number: /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g, operator: /[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|\~|\^|\%/g, ignore: /&(lt|gt|amp);/gi, punctuation: /[{}[\];(),.:]/g }; Prism.languages.javascript = Prism.languages.extend("clike", { keyword: /\b(break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|get|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/g, number: /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?|NaN|-?Infinity)\b/g }); Prism.languages.insertBefore("javascript", "keyword", { regex: { pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g, lookbehind: !0 } }); Prism.languages.markup && Prism.languages.insertBefore("markup", "tag", { script: { pattern: /[\w\W]*?<\/script>/ig, inside: { tag: { pattern: /|<\/script>/ig, inside: Prism.languages.markup.tag.inside }, rest: Prism.languages.javascript } } }); Prism.languages.latex = { comment: /%.*?(\r?\n|$)$/m, string: /(\$)(\\?.)*?\1/g, punctuation: /[{}]/g, selector: /\\[a-z;,:\.]*/i }; Prism.hooks.add("after-highlight", function(c) { var g = c.element.parentNode; if (g && /pre/i.test(g.nodeName) && -1 !== g.className.indexOf("line-numbers")) { var e = 1 + c.code.split("\n").length; lines = Array(e); lines = lines.join(""); e = document.createElement("span"); e.className = "line-numbers-rows"; e.innerHTML = lines; g.hasAttribute("data-start") && (g.style.counterReset = "linenumber " + (parseInt(g.getAttribute("data-start"), 10) - 1)); c.element.appendChild(e) } }); Prism.languages.TeX = { comment: /(?:^|[^\\])%[^%]*?$/m, builtin: { pattern: /\\[\w]+([{\[].*?[}\]](?=\s|$))*/gi, inside: { constant: /[\w,|\s-]+(?=[\]}])/gi, selector: /\\[\w]+/, punctuation: /[{}[\]]/gi } }, regex: /(&)/gi }; Prism.languages.plain = {}; Prism.languages.markdown = { property: /([\*_]{1,2})(\w|\w[\s\w]*\w)\1/i }; Prism.languages.mediawiki = { important: /(\n\|-)|(^\{\|)|(\|\}$)/g, comment: /\n(?:((?:\||!)[^|]+)(?=[^\n]\|))|(?:\||!)\s/g }; (function(c) { if (!c.observable) { c.observable = function(c) { var b = {}, d = [].slice; c.on = function(a, d) { "function" === typeof d && a.replace(/[^\s]+/g, function(a, c) { (b[a] = b[a] || []).push(d); d.typed = 0 < c }); return c }; c.off = function(a) { a.replace(/[^\s]+/g, function(a) { b[a] = [] }); "*" == a && (b = {}); return c }; c.one = function(a, b) { b && (b.one = !0); return c.on(a, b) }; c.trigger = function(a) { for (var f = d.call(arguments, 1), g = b[a] || [], n = 0, p; p = g[n]; ++n) p.one && p.done || p.busy || (p.busy = !0, p.apply(c, p.typed ? [a].concat(f) : f), p.done = !0, p.busy = !1); return c }; return c }; var g = {}; c.present = function(c, b) { g[c] = b }; c.fn.present = function(c, b) { var d = g[c](this, b); d && this.data(c, d); return this } } })("undefined" !== typeof exports ? exports : window.$ || (window.$ = {})); (function(c) { c.present("SimpleMenu", function(g, e) { e = c.extend(!0, { menu_item_selector: "li", menu_item_id_attr: "id" }, e); var b = {}, d = c(e.menu_item_selector, g); c.observable(b); d.mousedown(function(a) { 1 == a.which && (a = c(this), b.trigger(a.attr(e.menu_item_id_attr), a), b.trigger("any_item_clicked", a)) }); return b }) })($); (function(c) { c.present("SimpleAccordion", function(g, e) { function b(a) { a.addClass("closed").next().hide() } e = c.extend(!0, { item_header_selector: "h3" }, e); var d = []; c(e.item_header_selector, g).each(function(a, e) { e = c(e); e.click(function() { for (var c = e, g = 0; g < d.length; ++g) g != a && b(d[g]); c.next().is(":visible") ? b(c) : c.removeClass("closed").next().show() }); d.push(e); 0 != a && b(e) }); return {} }) })($); (function(c) { c.present("SimpleDraggable", function(g, e) { function b(b) { 1 == b.which && (m.top = k.top, m.left = k.left, e.horizontal_enabled && (m.left += b.pageX - n.left, f && (m.left = Math.max(f.left, Math.min(f.right, m.left)))), e.vertical_enabled && (m.top = b.pageY - n.top, f && (m.top = Math.max(f.top, Math.min(f.bottom, m.top)))), g.offset(m), a.trigger("drag_move", b, m)); b.preventDefault(); b.stopPropagation() } function d(b) { c(document).off("mousemove"); c(document).off("mouseup"); g.css("z-index", p); var d = b.pageX; f && (d = Math.max(f.left, Math.min(f.right, d))); d -= n.left; a.trigger("drag_end", b, d) } e = c.extend(!0, { horizontal_enabled: !0, vertical_enabled: !1, bounds: null }, e); var a = {}, f = e.bounds, k = null, n = null, p = 0, m = {}; g.on("mousedown", function(e) { 1 == e.which && (k = g.offset(), p = g.css("z-index"), g.css({ position: "absolute", "z-index": 1E3, top: k.top, left: k.left }), n = { top: e.pageY, left: e.pageX }, c(document).on("mousemove", b).on("mouseup", d), e.preventDefault(), a.trigger("drag_start", e, k)) }); c.observable(a); a.setBounds = function(a) { f = a }; return a }) })($); (function(c) { function g(a) { var d = c(this); d.each(function() { var d = c(this), e = d.data("slider"), f = "object" === typeof a && a; e && !f && (f = {}, c.each(c.fn.slider.defaults, function(a) { f[a] = e[a] })); d.data("slider", new b(this, c.extend({}, c.fn.slider.defaults, f))) }); return d } var e = { formatInvalidInputErrorMsg: function(a) { return "Invalid input value '" + a + "' passed in" }, callingContextNotSliderInstance: "Calling context element does not have instance of Slider bound to it. Check your code to make sure the JQuery object returned from the call to the slider() initializer is calling the method" }, b = function(a, b) { var d = this.element = c(a).hide(), e = c(a)[0].style.width, g = !1, m = this.element.parent(); !0 === m.hasClass("slider") ? (g = !0, this.picker = m) : this.picker = c('
').insertBefore(this.element).append(this.element); if (this.id = this.element.data("slider-id") || b.id) this.picker[0].id = this.id; if ("ontouchstart" in window || window.DocumentTouch && document instanceof window.DocumentTouch) this.touchCapable = !0; m = this.element.data("slider-tooltip") || b.tooltip; this.tooltip = this.picker.find("#tooltip"); this.tooltipInner = this.tooltip.find("div.tooltip-inner"); this.tooltip_min = this.picker.find("#tooltip_min"); this.tooltipInner_min = this.tooltip_min.find("div.tooltip-inner"); this.tooltip_max = this.picker.find("#tooltip_max"); this.tooltipInner_max = this.tooltip_max.find("div.tooltip-inner"); !0 === g && (this.picker.removeClass("slider-horizontal"), this.picker.removeClass("slider-vertical"), this.tooltip.removeClass("hide"), this.tooltip_min.removeClass("hide"), this.tooltip_max.removeClass("hide")); this.orientation = this.element.data("slider-orientation") || b.orientation; switch (this.orientation) { case "vertical": this.picker.addClass("slider-vertical"); this.stylePos = "top"; this.mousePos = "pageY"; this.sizePos = "offsetHeight"; this.tooltip.addClass("right")[0].style.left = "100%"; this.tooltip_min.addClass("right")[0].style.left = "100%"; this.tooltip_max.addClass("right")[0].style.left = "100%"; break; default: this.picker.addClass("slider-horizontal").css("width", e), this.orientation = "horizontal", this.stylePos = "left", this.mousePos = "pageX", this.sizePos = "offsetWidth", this.tooltip.addClass("top")[0].style.top = -this.tooltip.outerHeight() - 24 + "px", this.tooltip_min.addClass("top")[0].style.top = -this.tooltip_min.outerHeight() - 14 + "px", this.tooltip_max.addClass("top")[0].style.top = -this.tooltip_max.outerHeight() - 14 + "px" } var q = this; c.each("min max step precision value reversed handle".split(" "), function(a, c) { "undefined" !== typeof d.data("slider-" + c) ? q[c] = d.data("slider-" + c) : "undefined" !== typeof b[c] ? q[c] = b[c] : "undefined" !== typeof d.prop(c) ? q[c] = d.prop(c) : q[c] = 0 }); this.value instanceof Array ? g && !this.range ? this.value = this.value[0] : this.range = !0 : this.range && (this.value = [this.value, this.max]); this.selection = this.element.data("slider-selection") || b.selection; this.selectionEl = this.picker.find(".slider-selection"); "none" === this.selection && this.selectionEl.addClass("hide"); this.selectionElStyle = this.selectionEl[0].style; this.handle1 = this.picker.find(".slider-handle:first"); this.handle1Stype = this.handle1[0].style; this.handle2 = this.picker.find(".slider-handle:last"); this.handle2Stype = this.handle2[0].style; !0 === g && (this.handle1.removeClass("round triangle"), this.handle2.removeClass("round triangle hide")); switch (this.handle) { case "round": this.handle1.addClass("round"); this.handle2.addClass("round"); break; case "triangle": this.handle1.addClass("triangle"), this.handle2.addClass("triangle") } this.offset = this.picker.offset(); this.size = this.picker[0][this.sizePos]; this.formater = b.formater; this.tooltip_separator = b.tooltip_separator; this.tooltip_split = b.tooltip_split; this.setValue(this.value); this.handle1.on({ keydown: c.proxy(this.keydown, this, 0) }); this.handle2.on({ keydown: c.proxy(this.keydown, this, 1) }); if (this.touchCapable) this.picker.on({ touchstart: c.proxy(this.mousedown, this) }); this.picker.on({ mousedown: c.proxy(this.mousedown, this) }); "hide" === m ? (this.tooltip.addClass("hide"), this.tooltip_min.addClass("hide"), this.tooltip_max.addClass("hide")) : "always" === m ? (this.showTooltip(), this.alwaysShowTooltip = !0) : (this.picker.on({ mouseenter: c.proxy(this.showTooltip, this), mouseleave: c.proxy(this.hideTooltip, this) }), this.handle1.on({ focus: c.proxy(this.showTooltip, this), blur: c.proxy(this.hideTooltip, this) }), this.handle2.on({ focus: c.proxy(this.showTooltip, this), blur: c.proxy(this.hideTooltip, this) })); (this.enabled = b.enabled && (void 0 === this.element.data("slider-enabled") || !0 === this.element.data("slider-enabled"))) ? this.enable(): this.disable(); this.naturalArrowKeys = this.element.data("slider-naturalarrowkeys") || b.naturalarrowkeys }; b.prototype = { constructor: b, over: !1, inDrag: !1, showTooltip: function() { !1 === this.tooltip_split ? this.tooltip.addClass("in") : (this.tooltip_min.addClass("in"), this.tooltip_max.addClass("in")); this.over = !0 }, hideTooltip: function() { !1 === this.inDrag && !0 !== this.alwaysShowTooltip && (this.tooltip.removeClass("in"), this.tooltip_min.removeClass("in"), this.tooltip_max.removeClass("in")); this.over = !1 }, layout: function() { var a; a = this.reversed ? [100 - this.percentage[0], this.percentage[1]] : [this.percentage[0], this.percentage[1]]; this.handle1Stype[this.stylePos] = a[0] + "%"; this.handle2Stype[this.stylePos] = a[1] + "%"; if ("vertical" === this.orientation) this.selectionElStyle.top = Math.min(a[0], a[1]) + "%", this.selectionElStyle.height = Math.abs(a[0] - a[1]) + "%"; else { this.selectionElStyle.left = Math.min(a[0], a[1]) + "%"; this.selectionElStyle.width = Math.abs(a[0] - a[1]) + "%"; var b = this.tooltip_min[0].getBoundingClientRect(), c = this.tooltip_max[0].getBoundingClientRect(); b.right > c.left ? (this.tooltip_max.removeClass("top"), this.tooltip_max.addClass("bottom")[0].style.top = "18px") : (this.tooltip_max.removeClass("bottom"), this.tooltip_max.addClass("top")[0].style.top = "-30px") } this.range ? (this.tooltipInner.text(this.formater(this.value[0]) + this.tooltip_separator + this.formater(this.value[1])), this.tooltip[0].style[this.stylePos] = this.size * (a[0] + (a[1] - a[0]) / 2) / 100 - ("vertical" === this.orientation ? this.tooltip.outerHeight() / 2 : this.tooltip.outerWidth() / 2) + "px", this.tooltipInner_min.text(this.formater(this.value[0])), this.tooltipInner_max.text(this.formater(this.value[1])), this.tooltip_min[0].style[this.stylePos] = a[0] / 100 * this.size - ("vertical" === this.orientation ? this.tooltip_min.outerHeight() / 2 : this.tooltip_min.outerWidth() / 2) + "px", this.tooltip_max[0].style[this.stylePos] = a[1] / 100 * this.size - ("vertical" === this.orientation ? this.tooltip_max.outerHeight() / 2 : this.tooltip_max.outerWidth() / 2) + "px") : (this.tooltipInner.text(this.formater(this.value[0])), this.tooltip[0].style[this.stylePos] = this.size * a[0] / 100 - ("vertical" === this.orientation ? this.tooltip.outerHeight() / 2 : this.tooltip.outerWidth() / 2) + "px") }, mousedown: function(a) { if (!this.isEnabled()) return !1; this.touchCapable && "touchstart" === a.type && (a = a.originalEvent); this.triggerFocusOnHandle(); this.offset = this.picker.offset(); this.size = this.picker[0][this.sizePos]; a = this.getPercentage(a); if (this.range) { var b = Math.abs(this.percentage[0] - a), d = Math.abs(this.percentage[1] - a); this.dragged = b < d ? 0 : 1 } else this.dragged = 0; this.percentage[this.dragged] = this.reversed ? 100 - a : a; this.layout(); if (this.touchCapable) c(document).on({ touchmove: c.proxy(this.mousemove, this), touchend: c.proxy(this.mouseup, this) }); c(document).on({ mousemove: c.proxy(this.mousemove, this), mouseup: c.proxy(this.mouseup, this) }); this.inDrag = !0; a = this.calculateValue(); this.element.trigger({ type: "slideStart", value: a }).data("value", a).prop("value", a); this.setValue(a); return !0 }, triggerFocusOnHandle: function(a) { 0 === a && this.handle1.focus(); 1 === a && this.handle2.focus() }, keydown: function(a, b) { if (!this.isEnabled()) return !1; var c; switch (b.which) { case 37: case 40: c = -1; break; case 39: case 38: c = 1 } if (c) return this.naturalArrowKeys && ("vertical" === this.orientation && !this.reversed || "horizontal" === this.orientation && this.reversed) && (c *= -1), c = this.percentage[a] + c * this.percentage[2], 100 < c ? c = 100 : 0 > c && (c = 0), this.dragged = a, this.adjustPercentageForRangeSliders(c), this.percentage[this.dragged] = c, this.layout(), c = this.calculateValue(), this.element.trigger({ type: "slideStart", value: c }).data("value", c).prop("value", c), this.slide(c), this.element.trigger({ type: "slideStop", value: c }).data("value", c).prop("value", c), !1 }, mousemove: function(a) { if (!this.isEnabled()) return !1; this.touchCapable && "touchmove" === a.type && (a = a.originalEvent); a = this.getPercentage(a); this.adjustPercentageForRangeSliders(a); this.percentage[this.dragged] = this.reversed ? 100 - a : a; this.layout(); a = this.calculateValue(); this.slide(a); return !1 }, slide: function(a) { this.setValue(a); this.element.trigger({ type: "slide", value: this.range ? this.value : this.value[0] }).data("value", this.value).prop("value", this.value) }, adjustPercentageForRangeSliders: function(a) { this.range && (0 === this.dragged && this.percentage[1] < a ? (this.percentage[0] = this.percentage[1], this.dragged = 1) : 1 === this.dragged && this.percentage[0] > a && (this.percentage[1] = this.percentage[0], this.dragged = 0)) }, mouseup: function() { if (!this.isEnabled()) return !1; this.touchCapable && c(document).off({ touchmove: this.mousemove, touchend: this.mouseup }); c(document).off({ mousemove: this.mousemove, mouseup: this.mouseup }); this.inDrag = !1; !1 === this.over && this.hideTooltip(); var a = this.calculateValue(); this.layout(); this.element.data("value", a).prop("value", a).trigger({ type: "slideStop", value: a }); return !1 }, calculateValue: function() { var a; this.range ? (a = [this.min, this.max], 0 !== this.percentage[0] && (a[0] = Math.max(this.min, this.min + Math.round(this.diff * this.percentage[0] / 100 / this.step) * this.step), a[0] = this.applyPrecision(a[0])), 100 !== this.percentage[1] && (a[1] = Math.min(this.max, this.min + Math.round(this.diff * this.percentage[1] / 100 / this.step) * this.step), a[1] = this.applyPrecision(a[1])), this.value = a) : (a = this.min + Math.round(this.diff * this.percentage[0] / 100 / this.step) * this.step, a < this.min ? a = this.min : a > this.max && (a = this.max), a = parseFloat(a), a = this.applyPrecision(a), this.value = [a, this.value[1]]); return a }, applyPrecision: function(a) { var b = this.precision || this.getNumDigitsAfterDecimalPlace(this.step); return this.applyToFixedAndParseFloat(a, b) }, getNumDigitsAfterDecimalPlace: function(a) { return (a = ("" + a).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/)) ? Math.max(0, (a[1] ? a[1].length : 0) - (a[2] ? +a[2] : 0)) : 0 }, applyToFixedAndParseFloat: function(a, b) { var c = a.toFixed(b); return parseFloat(c) }, getPercentage: function(a) { !this.touchCapable || "touchstart" !== a.type && "touchmove" !== a.type || (a = a.touches[0]); a = 100 * (a[this.mousePos] - this.offset[this.stylePos]) / this.size; a = Math.round(a / this.percentage[2]) * this.percentage[2]; return Math.max(0, Math.min(100, a)) }, getValue: function() { return this.range ? this.value : this.value[0] }, setValue: function(a) { a || (a = 0); this.value = this.validateInputValue(a); this.range ? (this.value[0] = this.applyPrecision(this.value[0]), this.value[1] = this.applyPrecision(this.value[1]), this.value[0] = Math.max(this.min, Math.min(this.max, this.value[0])), this.value[1] = Math.max(this.min, Math.min(this.max, this.value[1]))) : (this.value = this.applyPrecision(this.value), this.value = [Math.max(this.min, Math.min(this.max, this.value))], this.handle2.addClass("hide"), this.value[1] = "after" === this.selection ? this.max : this.min); this.diff = this.max - this.min; this.percentage = 0 < this.diff ? [100 * (this.value[0] - this.min) / this.diff, 100 * (this.value[1] - this.min) / this.diff, 100 * this.step / this.diff] : [0, 0, 100]; this.layout() }, validateInputValue: function(a) { if ("number" === typeof a) return a; if (a instanceof Array) return c.each(a, function(a, b) { if ("number" !== typeof b) throw Error(e.formatInvalidInputErrorMsg(b)); }), a; throw Error(e.formatInvalidInputErrorMsg(a)); }, destroy: function() { this.handle1.off(); this.handle2.off(); this.element.off().show().insertBefore(this.picker); this.picker.off().remove(); c(this.element).removeData("slider") }, disable: function() { this.enabled = !1; this.handle1.removeAttr("tabindex"); this.handle2.removeAttr("tabindex"); this.picker.addClass("slider-disabled"); this.element.trigger("slideDisabled") }, enable: function() { this.enabled = !0; this.handle1.attr("tabindex", 0); this.handle2.attr("tabindex", 0); this.picker.removeClass("slider-disabled"); this.element.trigger("slideEnabled") }, toggle: function() { this.enabled ? this.disable() : this.enable() }, isEnabled: function() { return this.enabled }, setAttribute: function(a, b) { this[a] = b }, getAttribute: function(a) { return this[a] } }; var d = { getValue: b.prototype.getValue, setValue: b.prototype.setValue, setAttribute: b.prototype.setAttribute, getAttribute: b.prototype.getAttribute, destroy: b.prototype.destroy, disable: b.prototype.disable, enable: b.prototype.enable, toggle: b.prototype.toggle, isEnabled: b.prototype.isEnabled }; c.fn.slider = function(a) { if ("string" === typeof a && "refresh" !== a) { var f = Array.prototype.slice.call(arguments, 1), k; k = a; if (d[k]) { var n = c(this).data("slider"); if (!(n && n instanceof b)) throw Error(e.callingContextNotSliderInstance); k = d[k].apply(n, f); k = "undefined" === typeof k ? c(this) : k } else throw Error("method '" + k + "()' does not exist for slider."); return k } return g.call(this, a) }; c.fn.slider.defaults = { min: 0, max: 10, step: 1, precision: 0, orientation: "horizontal", value: 5, range: !1, selection: "before", tooltip: "show", tooltip_separator: ":", tooltip_split: !1, handle: "round", reversed: !1, enabled: !0, formater: function(a) { return a } }; c.fn.slider.Constructor = b })(window.jQuery); var wcwidth = function(c) { var g = [ [768, 879], [1155, 1158], [1160, 1161], [1425, 1469], [1471, 1471], [1473, 1474], [1476, 1477], [1479, 1479], [1536, 1539], [1552, 1557], [1611, 1630], [1648, 1648], [1750, 1764], [1767, 1768], [1770, 1773], [1807, 1807], [1809, 1809], [1840, 1866], [1958, 1968], [2027, 2035], [2305, 2306], [2364, 2364], [2369, 2376], [2381, 2381], [2385, 2388], [2402, 2403], [2433, 2433], [2492, 2492], [2497, 2500], [2509, 2509], [2530, 2531], [2561, 2562], [2620, 2620], [2625, 2626], [2631, 2632], [2635, 2637], [2672, 2673], [2689, 2690], [2748, 2748], [2753, 2757 ], [2759, 2760], [2765, 2765], [2786, 2787], [2817, 2817], [2876, 2876], [2879, 2879], [2881, 2883], [2893, 2893], [2902, 2902], [2946, 2946], [3008, 3008], [3021, 3021], [3134, 3136], [3142, 3144], [3146, 3149], [3157, 3158], [3260, 3260], [3263, 3263], [3270, 3270], [3276, 3277], [3298, 3299], [3393, 3395], [3405, 3405], [3530, 3530], [3538, 3540], [3542, 3542], [3633, 3633], [3636, 3642], [3655, 3662], [3761, 3761], [3764, 3769], [3771, 3772], [3784, 3789], [3864, 3865], [3893, 3893], [3895, 3895], [3897, 3897], [3953, 3966], [3968, 3972], [3974, 3975], [3984, 3991], [3993, 4028 ], [4038, 4038], [4141, 4144], [4146, 4146], [4150, 4151], [4153, 4153], [4184, 4185], [4448, 4607], [4959, 4959], [5906, 5908], [5938, 5940], [5970, 5971], [6002, 6003], [6068, 6069], [6071, 6077], [6086, 6086], [6089, 6099], [6109, 6109], [6155, 6157], [6313, 6313], [6432, 6434], [6439, 6440], [6450, 6450], [6457, 6459], [6679, 6680], [6912, 6915], [6964, 6964], [6966, 6970], [6972, 6972], [6978, 6978], [7019, 7027], [7616, 7626], [7678, 7679], [8203, 8207], [8234, 8238], [8288, 8291], [8298, 8303], [8400, 8431], [12330, 12335], [12441, 12442], [43014, 43014], [43019, 43019], [43045, 43046], [64286, 64286], [65024, 65039], [65056, 65059], [65279, 65279], [65529, 65531], [68097, 68099], [68101, 68102], [68108, 68111], [68152, 68154], [68159, 68159], [119143, 119145], [119155, 119170], [119173, 119179], [119210, 119213], [119362, 119364], [917505, 917505], [917536, 917631], [917760, 917999] ]; jQuery.extend(c, { nul: 0, control: -1, monkeypatch: !0 }); var e = function(b) { if (0 === b) return c.nul; if (32 > b || 127 <= b && 160 > b) return c.control; var d; a: { d = 0; var a = g.length - 1, e; if (!(b < g[0][0] || b > g[a][1])) for (; a >= d;) if (e = Math.floor((d + a) / 2), b > g[e][1]) d = e + 1; else if (b < g[e][0]) a = e - 1; else { d = !0; break a } d = !1 } return d ? 0 : 1 + (4352 <= b && (4447 >= b || 9001 == b || 9002 == b || 11904 <= b && 42191 >= b && 12351 != b || 44032 <= b && 55203 >= b || 63744 <= b && 64255 >= b || 65040 <= b && 65049 >= b || 65072 <= b && 65135 >= b || 65280 <= b && 65376 >= b || 65504 <= b && 65510 >= b || 131072 <= b && 196605 >= b || 196608 <= b && 262141 >= b)) }; return function(b) { var c, a, f, g = 0; if ("string" == typeof b || b instanceof String) for (c = 0, a = b.length; c < a; c++) { if (0 > (f = e(b.charCodeAt(c)))) return -1; g += f } else g = e(b); return g } }(); Array.max = function(c) { return Math.max.apply(Math, c) }; Array.prototype.map || (Array.prototype.map = function(c) { if (void 0 === this || null === this) throw new TypeError; var g = Object(this), e = g.length >>> 0; if ("function" !== typeof c) throw new TypeError; for (var b = Array(e), d = 2 <= arguments.length ? arguments[1] : void 0, a = 0; a < e; a++) a in g && (b[a] = c.call(d, g[a], a, g)); return b }); Array.prototype.indexOf || (Array.prototype.indexOf = function(c, g) { if (void 0 === this || null === this) throw new TypeError('"this" is null or not defined'); var e = this.length >>> 0; g = +g || 0; Infinity === Math.abs(g) && (g = 0); 0 > g && (g += e, 0 > g && (g = 0)); for (; g < e; g++) if (this[g] === c) return g; return -1 }); Array.prototype.diff = function(c) { return this.filter(function(g) { return 0 > c.indexOf(g) }) }; var htmlEncode = function() { function c(c) { return g[c] || c } var g = { "&": "&", "<": "<", ">": ">" }; return function(e) { return e.replace(/[&<>]/g, c) } }(), htmlDecode = function() { var c = $("
"); return function(g) { return g ? c.html(g).text() : "" } }(); function textToHTML(c) { return c.split("\n").map(htmlEncode).join("
") } var Utils = Utils || {}; (function() { function c(b, c) { for (var a = [], e = 0; e < c; ++e) a.push(b); return a } function g(b, c) { var a = "", e = !0; c = c || ""; for (var g = 0; g < b.length; ++g) e ? e = !1 : a += c, a += b[g]; return a } function e(b) { if (void 0 == b) return ""; var c = [], a; for (a in b) if (b.hasOwnProperty(a)) { var e = b[a]; void 0 != e ? c.push(a.toString() + '="' + e.toString() + '"') : c.push(a.toString()) } return 0 < c.length ? " " + c.join(" ") : "" } window.console || (window.console = {}); window.console.log || (window.console.log = function() {}); Utils.range = function(b, c, a) { var e = []; b = parseInt(b); if (!isNaN(b)) if (void 0 == c && (c = b, b = 0), void 0 == a && (a = 1), 0 < a) for (; b < c; b += a) e.push(b); else if (0 > a) for (; b > c; b += a) e.push(b); return e }; Utils.repeat = c; Utils.join = g; Utils.ljust = function(b, d) { var a = Math.max(0, d - b.length); return b + g(c(" ", a)) }; Utils.freq_call_filter = function(b, c) { var a = (new Date).getTime(); return function() { var e = (new Date).getTime(), g = e - a; a = e; g > c && b.apply(null, arguments) } }; Utils.select_text = function(b) { var c = document; b = c.getElementById(b); var a; c.body.createTextRange ? (c = c.body.createTextRange(), c.moveToElementText(b), c.select()) : window.getSelection && (a = window.getSelection(), c = c.createRange(), c.selectNodeContents(b), a.removeAllRanges(), a.addRange(c)) }; Utils.format_attr = e; Utils.format_tag = function(b, c, a) { return "<" + b + e(a) + ">" + c + "" } })(); (function(c) { c.fn.jqPaste = function(c, e) { var b = this; b.on("paste", function() { if (!e || 0 != e()) { var d = b.html(); b.hide(); window.setTimeout(function() { var a = b.html(); b.html(d); b.show(); c && c(a) }, 5) } }) } })(jQuery); var PasteHelper = function() { function c(e) { e = e || 1; b = window.setTimeout(function() { if (a.is(":empty")) 16 > e && c(2 * e); else { var k = a.html(); a.html("").hide(); b = null; window.scrollTo(d.left, d.top); g && (g(k), g = null) } }, e) } var g = null, e = !1, b = null, d = null, a = $("
", { contenteditable: !0 }); a.css({ position: "absolute", left: "0px", top: "0px", width: "1px", height: "1x", overflow: "hidden", "user-select": "text" }); a.on("paste", function() { c(3) }); return { start: function(c, k) { g = c; e || (a.appendTo($("body")), e = !0); d = { left: window.scrollX, top: window.scrollY }; a.css({ left: window.scrollX + "px", top: window.scrollY + "px" }); null != b && window.clearTimeout(b); a.show(); a.focus() } } }(); var TableImport = TableImport || {}; (function() { function c(c) { var b = []; $(c).find("tr").each(function(c, a) { var e = []; $(a).find("td,th").each(function(a, b) { e.push(b.textContent) }); b.push(e) }); return b } function g(c) { var b = []; c = c.trim(); if (/<\w+[^>]*>/gi.test(c)) try { c = $(c).text() } catch (d) { c = c.replace(/(<([^>]+)>)/ig, "") } 0 < c.length && (b = c.trim().split(/\s{2,}\t*|\t\s*/)); return b } TableImport.extractTableFromString = function(e) { e = e.trim(); if (-1 != e.search(/" + e + ""); var b = []; 0 < e.find("div").length ? e.find("div").each(function(a, c) { b.push($(c).text()) }) : (e = e.html(), e = e.replace(//ig, "\n"), e = e.replace(/ /g, " "), b = e.split(/\n/g)); var d = []; b.forEach(function(a) { a = g(a); 0 < a.length && d.push(a) }); return d } return null }; TableImport.extractCellsFromString = g })(); var TableModel = function() { function c(c) { this.value_ = c || ""; this.rowspan_ = this.colspan_ = 1; $.observable(this) } function g() { this.rows = []; this.col_count = this.row_count = 0; $.observable(this) } c.prototype.value = function() { if (0 < arguments.length) { var c = this.value_; this.value_ = arguments[0]; this.trigger("value_change", this.value_, c); return c } return this.value_ }; c.prototype.colspan = function(c) { if (0 < arguments.length) { var b = this.colspan_; this.colspan_ = arguments[0]; this.trigger("colspan_change", this.colspan_, b); return b } return this.colspan_ }; c.prototype.rowspan = function(c) { if (0 < arguments.length) { var b = this.rowspan_; this.rowspan_ = arguments[0]; this.trigger("rowspan_change", this.rowspan_, b); return b } return this.rowspan_ }; c.create = function(e) { var b = new c; b.value(e); return b }; c.prototype.isVisible = function() { return 0 < this.colspan() && 0 < this.rowspan() }; c.prototype.dump = function() { return { value: this.value(), cspan: this.colspan(), rspan: this.rowspan() } }; c.prototype.load = function(c, b) { this.value(c.value); b.colspan || this.colspan(c.cspan); b.rowspan || this.rowspan(c.rspan) }; g.prototype.dump = function() { var c = []; this.rows.forEach(function(b, d) { var a = b.map(function(a) { return a.dump() }); c.push(a) }); return { rows: c } }; g.prototype.load = function(c, b) { if (!c || !c.rows) throw "Invalid data format: rows expexted"; var d = c.rows, a = d[0].length; this.resize(1, a); for (var f = 0; f < d.length; ++f) { this.row_count <= f && this.insertEmptyRow(); for (var g = d[f], n = this.rows[f], p = 0; p < a; ++p) n[p].load(g[p], b) } }; g.prototype.insertRow = function(e, b) { if (0 != this.col_count && e.length != this.col_count) throw Error("Invalid number of cells in cells_data"); void 0 == b && (b = this.row_count); if (b < this.row_count) for (var d = this.col_count - 1; 0 <= d; --d) this.splitCell(b, d); for (var a = [], d = 0, f = e.length; d < f; ++d) a.push(new c(e[d])); this.rows.splice(b, 0, a); this.row_count += 1; this.col_count = a.length; this.trigger("row_inserted", b, a); this.trigger("state_change") }; g.prototype.insertColumn = function(e, b) { if (0 != this.row_count && e.length != this.row_count) throw Error("Invalid number of cells in inserted column"); void 0 == b && (b = this.col_count); if (b < this.col_count) for (var d = this.row_count - 1; 0 <= d; --d) this.splitCell(d, b); var a = []; this.rows.forEach(function(d, g) { var n = new c(e[g]); d.splice(b, 0, n); a.push(n) }); this.col_count += 1; this.row_count = e.length; this.trigger("column_inserted", b, a); this.trigger("state_change") }; g.prototype.insertEmptyColumn = function(c) { var b = this.rows.map(function() { return "" }); this.insertColumn(b, c) }; g.prototype.insertEmptyRow = function(c) { for (var b = [], d = 0, a = this.rows[0].length; d < a; ++d) b.push(""); this.insertRow(b, c) }; g.prototype.removeRow = function(c) { if (0 > c || c >= this.row_count) throw Error("Index out of bounds: " + c); if (1 != this.row_count) { for (var b = this.col_count - 1; 0 <= b; --b) this.splitCell(c, b); b = this.rows[c]; this.rows.splice(c, 1); this.row_count -= 1; this.trigger("row_removed", c, b); this.trigger("state_change") } }; g.prototype.removeColumn = function(c) { if (0 > c || c >= this.col_count) throw Error("Index out of bounds: " + c); if (1 != this.col_count) { for (var b = [], d = this.row_count - 1; 0 <= d; --d) { this.splitCell(d, c); var a = this.rows[d]; b.push(a[c]); a.splice(c, 1) } this.col_count -= 1; this.trigger("column_removed", c, b); this.trigger("state_change") } }; g.prototype.forEachCellInRow = function(c, b) { if (0 > c || c >= this.row_count) throw Error("Index out of bounds: " + c); this.rows[c].forEach(b) }; g.prototype.forEachCellInColumn = function(c, b) { if (0 > c || c >= this.col_count) throw Error("Index out of bounds: " + c); for (var d = 0; d < this.row_count; ++d) b(this.rows[d][c], d) }; g.prototype.forEachCellInRange = function(c, b, d, a, f) { for (; c <= d; ++c) for (var g = this.rows[c], n = b; n <= a; ++n) f(g[n], c, n) }; g.prototype.forEachCell = function(c) { this.forEachCellInRange(0, 0, this.row_count - 1, this.col_count - 1, c) }; g.prototype.getVisibleCellPos = function(c, b) { var d = this.getCell(c, b, !0); 0 > d.rowspan() && (c += d.rowspan()); 0 > d.colspan() && (b += d.colspan()); return { row: c, col: b } }; g.prototype.getColumn = function(c) { var b = []; this.forEachCellInColumn(c, function(c) { b.push(c) }); return b }; g.prototype.getCell = function(c, b, d) { if (0 > c || c >= this.row_count) throw Error("Row index out of bounds: " + c); if (0 > b || b >= this.col_count) throw Error("Index out of bounds: " + b); var a = this.rows[c][b]; a.isVisible() || d || (a = this.rows[c + Math.min(a.rowspan(), 0)][b + Math.min(a.colspan(), 0)]); return a }; g.prototype.mergeCells = function(c, b, d, a) { var f = a - b + 1, g = d - c + 1; if (!(1 >= f && 1 >= g)) { for (var n = c; n <= d; ++n) { for (var p = b; p <= a; ++p) this.splitCell(n, p); for (var m = this.rows[n], p = b; p <= a; ++p) { var q = m[p]; p == b ? q.colspan(f) : q.colspan(b - p); n == c ? q.rowspan(g) : q.rowspan(c - n) } } this.trigger("state_change") } }; g.prototype.splitCell = function(c, b) { var d = this.rows[c][b], a = d.colspan(), f = d.rowspan(); if (0 > a || 0 > f) 0 > a && (b += a), 0 > f && (c += f), this.splitCell(c, b); else if (1 < a || 1 < f) for (var g = c; g < c + f; ++g) for (var n = b; n < b + a; ++n) d = this.rows[g][n], d.colspan(1), d.rowspan(1); this.trigger("state_change") }; g.prototype.resize = function(c, b) { void 0 == c && (c = this.row_count); void 0 == b && (b = this.col_count); if (0 >= b || 0 >= c) throw Error("Illegal arguments - row_count: " + c + " col_count: " + b); var d = { row_count: this.row_count, col_count: this.col_count }, a = { row_count: c, col_count: b }; this.trigger("before_resize", d, a); var f = b - this.col_count; if (0 < f) for (var g = 0; g < f; ++g) this.insertEmptyColumn(); else if (0 > f) for (g = 0; g < -f; ++g) this.removeColumn(this.col_count - 1); f = c - this.row_count; if (0 < f) for (g = 0; g < f; ++g) this.insertEmptyRow(); else if (0 > f) for (g = 0; g < -f; ++g) this.removeRow(this.row_count - 1); this.trigger("after_resize", d, a) }; g.prototype.toString = function() { return this.rows.map(function(c) { return c.map(function(b) { return b.value() }).join(", ") }).join("\n") }; g.prototype.clear = function() { this.rows.forEach(function(c) { c.forEach(function(b) { b.value("") }) }); this.trigger("state_change") }; g.prototype.reset = function() { for (var c = 0; c < this.row_count; ++c) for (var b = 0; b < this.col_count; ++b) this.splitCell(c, b); this.clear() }; g.prototype.setRows = function(c) { var b = 0; c.forEach(function(a) { b = Math.max(b, a.length) }); this.resize(1, b); var d = this; c.forEach(function(a) { d.insertRow(a) }); this.removeRow(0) }; return g }(); var CellStyle = function() { function c(g) { this.cell_dom = g; this.borders = ""; this.font_style = {}; this.bg_color = this.text_color = ""; this.padding = $.extend({}, c.Padding); c.Padding && this.cell_dom.find(".wrap > div").css("margin", c.Padding.top + "px " + c.Padding.right + "px"); $.observable(this) } c.FontFamilies = { "ff-arial-black": '"Arial Black", Gadget, sans-serif !important;', "ff-arial": "Arial, Helvetica, sans-serif !important;", "ff-comic-sans-ms": '"Comic Sans MS", cursive, sans-serif !important;', "ff-courier-new": '"Courier New", Courier, monospace !important;', "ff-georgia": "Georgia, serif !important;", "ff-impact": "Impact, Charcoal, sans-serif !important;", "ff-lucida-console": '"Lucida Console", Monaco, monospace !important;', "ff-lucida-sans": '"Lucida Sans Unicode", "Lucida Grande", sans-serif !important;', "ff-palatino-linotype": '"Palatino Linotype", "Book Antiqua", Palatino, serif !important;', "ff-serif": "serif !important;", "ff-tahoma": "Tahoma, Geneva, sans-serif !important;", "ff-times-new-roman": '"Times New Roman", Times, serif !important;', "ff-trebuchet-ms": '"Trebuchet MS", Helvetica, sans-serif !important;', "ff-verdana": "Verdana, Geneva, sans-serif !important;" }; c.Padding = { top: 10, bottom: 10, left: 5, right: 5 }; c.prototype.dump = function() { return { borders: this.borders, font_style: $.extend({}, this.font_style), text_color: this.text_color, bg_color: this.bg_color, halign: this.getHorizontalAlign(), padding: $.extend({}, this.getPadding()) } }; c.prototype.toCSS = function() { var c = {}; $.extend(c, this.fontStyleToCSS()); $.extend(c, this.colorsToCSS()); $.extend(c, this.textAlignToCSS()); return c }; c.prototype.load = function(c, e) { void 0 == c.borders || e.borders || this.setBorders(c.borders); var b = c.font_style; if (void 0 != b && !e.font_style) { for (var d in this.font_style) this.font_style.hasOwnProperty(d) && this.removeFontStyle(d); for (d in b) b.hasOwnProperty(d) && this.addFontStyle(d, b[d]) } void 0 == c.text_color || e.text_color || this.setTextColor(c.text_color); void 0 == c.bg_color || e.bg_color || this.setBgColor(c.bg_color); void 0 != c.halign && this.setHorizontalAlign(c.halign); b = c.padding; void 0 != b && b.hasOwnProperty("top") && b.hasOwnProperty("right") && this.setPadding(b.top, b.right) }; c.prototype.setHorizontalAlign = function(c) { this.cell_dom.css("text-align", c); this.trigger("state_change") }; c.HorizontalAlignValues = ["left", "center", "right"]; c.prototype.getHorizontalAlign = function() { var g = this.cell_dom.css("text-align"), g = Math.max(0, c.HorizontalAlignValues.indexOf(g)); return c.HorizontalAlignValues[g] }; c.prototype.textAlignToCSS = function() { var c = {}, e = this.getHorizontalAlign(); "left" != e && (c["text-align"] = e); return c }; c.prototype.hasTextColor = function() { return this.text_color && "transparent" != this.text_color }; c.prototype.setTextColor = function(c) { "transparent" == c && (c = ""); this.text_color = c; this.cell_dom.css("color", c); this.trigger("state_change") }; c.prototype.getTextColor = function() { return this.text_color }; c.prototype.setPadding = function(g, e, b, d) { void 0 == e && (e = g); void 0 == b && (b = g); void 0 == d && (d = e); this.padding = { top: g, right: e, bottom: b, left: d }; b = c.Padding; JSON.stringify(this.padding) !== JSON.stringify(b) && (c.Padding = this.padding, this.cell_dom.parents("table").find(".wrap > div").css("margin", g + "px " + e + "px"), this.trigger("state_change"), this.trigger("padding_change", this.padding)) }; c.prototype.clearPadding = function() { this.setPadding(10, 5, 10, 5) }; c.prototype.getPadding = function() { return this.padding }; c.prototype.clearTextColor = function() { this.cell_dom.css("color", ""); this.text_color = ""; this.trigger("state_change") }; c.prototype.setBgColor = function(c) { "transparent" == c && (c = ""); this.bg_color = c; this.cell_dom.css("background-color", c); this.trigger("state_change") }; c.prototype.getBgColor = function() { return this.bg_color }; c.prototype.hasBgColor = function() { return this.bg_color && "transparent" != this.bg_color }; c.prototype.clearBgColor = function() { this.cell_dom.css("background-color", ""); this.bg_color = ""; this.trigger("state_change") }; c.prototype.colorsToCSS = function() { var c = {}; this.bg_color && "transparent" != this.bg_color && (c["background-color"] = this.bg_color); this.text_color && "transparent" != this.text_color && (c.color = this.text_color); return c }; c.prototype.setBorders = function(c) { if (!(0 < c.length) || c.match(/^[ltrb]+$/)) { var e = { l: "border_l", t: "border_t", r: "border_r", b: "border_b" }, b = this; b.borders.split("").forEach(function(c) { b.cell_dom.removeClass(e[c]) }); b.borders = c; b.borders.split("").forEach(function(c) { b.cell_dom.addClass(e[c]) }); this.trigger("state_change") } }; c.prototype.addBorder = function(c) { c = c[0]; - 1 == this.borders.indexOf(c) && (this.borders += c, this.cell_dom.addClass("border_" + c)); this.trigger("state_change") }; c.prototype.removeBorder = function(c) { c = c[0]; - 1 != this.borders.indexOf(c) && (this.borders = this.borders.replace(c, ""), this.cell_dom.removeClass("border_" + c)); this.trigger("state_change") }; c.prototype.hasBorder = function(c) { return -1 != this.borders.indexOf(c[0]) }; c.prototype.toggleBorder = function(c) { 0 < c.length && !c.match(/^[ltrb]+$/) || (-1 != this.borders.indexOf(c) ? this.setBorders(this.borders.replace(c, "")) : this.setBorders(this.borders + c)) }; c.prototype.reset = function() { this.setHorizontalAlign("left"); this.setBorders(""); for (var c in this.font_style) this.removeFontStyle(c); this.clearTextColor(); this.clearBgColor(); this.clearPadding() }; c.prototype.addFontStyle = function(c, e) { "bold" == c ? this.cell_dom.css("font-weight", "bold") : "italic" == c && this.cell_dom.css("font-style", "italic"); if ("font-family" == c) { var b = this.font_style["font-family"]; b && this.cell_dom.removeClass(b); this.cell_dom.addClass(e) } else "font-size" == c && ("inherit" == e ? this.cell_dom.css("font-size", "100%") : this.cell_dom.css("font-size", e)); this.font_style[c] = e || !0; this.trigger("state_change") }; c.prototype.fontStyleToCSS = function() { var g = {}, e = this.font_style; e.hasOwnProperty("bold") && (g["font-weight"] = "bold"); e.hasOwnProperty("italic") && (g["font-style"] = "italic"); e.hasOwnProperty("font-size") && (g["font-size"] = "inherit" == e["font-size"] ? "100%" : e["font-size"]); e.hasOwnProperty("font-family") && (g["font-family"] = c.FontFamilies[e["font-family"]]); return g }; c.prototype.hasFontStyle = function(c) { return this.font_style.hasOwnProperty(c) }; c.prototype.removeFontStyle = function(c) { this.hasFontStyle(c) && (delete this.font_style[c], "bold" == c ? this.cell_dom.css("font-weight", "normal") : "italic" == c && this.cell_dom.css("font-style", "normal")); this.trigger("state_change") }; c.prototype.toggleFontStyle = function(c) { this.hasFontStyle(c) ? this.removeFontStyle(c) : this.addFontStyle(c) }; return c }(); (function(c, g, e, b) { c.fn.borderEvents = function(b) { return this.each(function(a, e) { function g(a) { if (!b.deactivated && b.onBorderOver) { var c = m.outerWidth(), e = m.outerHeight(), f = m.offset(), k = a.pageX - f.left, f = a.pageY - f.top, n = null; 5 > k ? n = "left" : k > c - 5 ? n = "right" : 5 > f ? n = "top" : f > e - 5 && (n = "bottom"); if (b.onBorderLeave && q && n != q) b.onBorderLeave(a, q, m); if (n) b.onBorderOver(a, n, m); q = n } } function n(a) { if (b.onBorderLeave && q) b.onBorderLeave(a, q, m); q = null } function p(a) { if (!b.deactivated && q && b.onBorderClick) b.onBorderClick(a, q, m) } var m = c(e), q = null; 1 != m.data("borderEvents") && (m.mousemove(g).mouseleave(n).click(p), m.data("borderEvents", !0)) }) } })(jQuery); var TableView = function() { function c() { var a = window.navigator.userAgent, b = a.indexOf("MSIE "); return 0 < b || navigator.userAgent.match(/Trident.*rv\:11\./) ? -1 != a.indexOf(".", b) ? parseInt(a.substring(b + 5, a.indexOf(".", b))) : 1 : null } function g(a) { var b = this; b.cell = a; b.edit_in_progress = !1; b.ignore_model_change = !1; b.event_handlers_initialized = !1; var c = document.createElement("DIV"); c.innerHTML = textToHTML(a.value()); b.entry = $(c); c = $("
", { "class": "wrap" }); b.entry.appendTo(c); b.dom = $(document.createElement("TD")); c.appendTo(b.dom); $.observable(this); b.entry.on("paste", function(a) { b.onPasteContent(a) }); a.on("value_change", function(a) { b.ignore_model_change || b.entry.html(textToHTML(a)); b.trigger("state_change") }); a.on("colspan_change", function(a) { 0 < a && b.dom.attr("colspan", a); b.show() }); a.on("rowspan_change", function(a) { 0 < a && b.dom.attr("rowspan", a); b.show() }); b.style = new CellStyle(this.dom); b.style.on("state_change", function() { b.trigger("state_change") }) } function e() { if (window.getSelection) { var a = window.getSelection(); 0 < a.rangeCount && a.getRangeAt(0).collapse(!0) } } function b(a, b) { this.type = a; this.dom = $("
"); a.append(B("corner")); s.aux_row = a; for (var b = 1; b <= s.model.col_count; ++b) B("column"); s.dom.append(a) } function B(a, c) { var d = null; if ("row" == a) void 0 == c && (c = s.model.row_count), s.aux_cells.forEach(function(a) { a.onInsertRow(c) }), d = new b(a, c), d.dom.mousedown(function(a) { if (!d.dom.hasClass("aux-cell-selected") || 1 == a.which) { var b = R(d.dom).row; y(b, 0, b, s.model.col_count - 1, a.ctrlKey) } }), s.aux_col_cells.splice(c, 0, d); else if ("column" == a) { if (null == s.aux_row) return; void 0 == c && (c = s.aux_row.find("td").length - 1); s.aux_cells.forEach(function(a) { a.onInsertColumn(c) }); d = new b(a, c); d.dom.mousedown(function(a) { if (!d.dom.hasClass("aux-cell-selected") || 1 == a.which) { var b = R(d.dom).col; y(0, b, s.model.row_count - 1, b, a.ctrlKey) } }); s.aux_row.find("td").eq(c).after(d.dom); s.aux_row_cells.splice(c, 0, d); if (s.column_resize_enabled) d.draggable.on("drag_start", function(a, b) { var c = d; s.enableFixedLayout(!0); var e = c.dom.offset(); s.aux_row_cells.indexOf(c); var f = c.size_handle.width(); s.drag_start_pos = b; c.draggable.setBounds({ left: e.left + 20 - f + 1, right: e.left + 1E3 }); null == s.size_indicator && (s.size_indicator = $("
").addClass("size-tip").appendTo($("body"))); c.size_handle.addClass("size-indicator").css({ height: s.dom.height() }) }).on("drag_end", function(a) { a = d; if (void 0 !== s.drag_start_pos) { var b = a.size_handle.offset().left - s.drag_start_pos.left, c = s.aux_row_cells.indexOf(a), e = s.getColumnWidths(!0)[c + 1], b = Math.max(1, e + b); s.setSingleColumnWidth(c, b); a.size_handle.css({ position: "relative", top: 0, height: 20, left: 0 }).removeClass("size-indicator"); s.size_indicator.hide() } }).on("drag_move", function(a, b) { var c = d, c = c.size_handle.offset().left - s.drag_start_pos.left + c.dom.width(); s.size_indicator.text(c + "px").offset({ left: b.left - s.size_indicator.width() / 2, top: b.top - s.size_indicator.height() - 5 }).show() }) } else "corner" == a && (d = new b(a), d.dom.mousedown(function() { y(0, 0, s.model.row_count - 1, s.model.col_count - 1) })); var e = $("
"); s.hasFixedLayout() && (e.width(20), s.dom.width(s.dom.width() + 20)); "corner" == a ? s.colgroup.append(e) : "column" == a && s.colgroup.find("col").eq(c).after(e); return null != d ? (s.aux_cells.push(d), d.dom) : null } function v(a, b) { var c = null; s.aux_cells.forEach(function(d) { d.type == a && d.index == b && (c = d) }); "row" == a ? (s.aux_cells.forEach(function(a) { a.onRemoveRow(b) }), s.aux_col_cells.splice(b, 1)) : "column" == a && (s.aux_cells.forEach(function(a) { a.onRemoveColumn(b) }), s.aux_row.find("td").eq(b + 1).remove(), s.aux_row_cells.splice(b, 1)); if (null != c) { var d = 0, e = s.dom.width(); "column" == a ? (d = s.colgroup.find("col").eq(b + 1).width(), s.colgroup.find("col").eq(b + 1).remove()) : "corner" == a && (d = s.colgroup.find("col").eq(0).width(), s.colgroup.find("col").eq(0).remove()); var f = s.aux_cells.indexOf(c); - 1 != f && s.aux_cells.splice(f, 1); s.hasFixedLayout() && s.dom.css("width", e - d - 1) } } function C(a, b) { null == s.aux_row && x(); var c = $(""), d = B("row", a); c.append(d); b.forEach(function(a) { var b = m(a); c.append(b.dom); a.view = b }); s.dom.find("tr").eq(a).after(c); s.selection_bounds = null } function K(a, b, c) { a.view && a.view.select() && (a.view.areEventHandlersInitialized() || a.view.initEventHandlers(), s.selection_bounds = null, s.aux_col_cells[b].dom.addClass("aux-cell-selected"), s.aux_row_cells[c].dom.addClass("aux-cell-selected"), s.trigger("cell_selected", a, b, c)) } function A(a, b, c) { a.view.is_selected ? E(a, b, c) : K(a, b, c) } function y(a, b, d, f, g) { if (void 0 == d || d < a) d = a; if (void 0 == f || f < b) f = b; var k = K; g ? k = A : N(); s.model.forEachCellInRange(a, b, d, f, k); a = window.scrollX; b = window.scrollY; s.dom.focus(); e(); null === c() && window.scrollTo(a, b) } function E(a, b, c) { if (a.view.unselect()) { s.selection_bounds = null; var d = !1, e = !1; Z(function(a, f, g) { f == b && (d = !0); g == c && (e = !0) }); !d && b < s.aux_col_cells.length && s.aux_col_cells[b].dom.removeClass("aux-cell-selected"); !e && c < s.aux_row_cells.length && s.aux_row_cells[c].dom.removeClass("aux-cell-selected"); s.trigger("cell_unselected", a, b, c) } } function N() { var a = I(); a && (s.model.forEachCellInRange(a.top, a.left, a.bottom, a.right, E), s.selected_cells = {}) } function I() { if (null != s.selection_bounds) return s.selection_bounds; var a = s.model.col_count, b = -1, c = s.model.row_count, d = -1; s.model.forEachCell(function(e, f, g) { 1 == e.view.is_selected && (g < a && (a = g), g > b && (b = g), f < c && (c = f), f > d && (d = f)) }); return a <= b && c <= d ? (s.selection_bounds = { left: a, right: b, top: c, bottom: d }, s.selection_bounds) : null } function Z(a, b) { s.model.forEachCell(function(c, d, e) { if (1 == c.view.is_selected) if (b) for (var f = d; f < d + c.rowspan(); ++f) for (var g = e; g < e + c.colspan(); ++g) a(s.model.getCell(f, g, !0), f, g); else a(c, d, e) }) } function G() { var a = I(); return a && a.left == a.right && a.top == a.bottom } function P() { var a = I(), b = null; a && s.model.forEachCellInRange(a.top, a.left, a.bottom, a.right, function(a) { b = a }); return b } function U() { var a = P(); return null == a ? null : a.view } function Ba(a, b) { if (G()) { var c = I(), d = c.left + b, c = c.top + a; 0 > d ? (d = s.model.col_count - 1, c -= 1) : d == s.model.col_count && (d = 0, c += 1); 0 > c ? c = s.model.row_count - 1 : c >= s.model.row_count && (c = 0); N(); K(s.model.getCell(c, d), c, d) } } function R(a) { for (a = $(a); void 0 != a && a.get(0) && "td" != a.get(0).nodeName.toLowerCase();) a = a.parent(); return { col: a.index() - 1, row: $(a.parent()).index() - 1 } } function la() { if (G()) { s.forEachSelectedCellView(function(a) { a.endEditing() }); var a = I(); a.left < s.model.col_count - 1 ? Ba(0, 1) : a.bottom < s.model.row_count - 1 ? Ba(1, -s.model.col_count + 1) : (N(), K(0, 0)); s.forEachSelectedCellView(function(a) { a.startEditing() }) } } function Ha(a) { a = TableImport.extractTableFromString(a); var b = I(); if (a) { if (0 == b.left && 0 == b.top && b.left == b.right && b.top == b.bottom) { var c = 0; a.forEach(function(a) { c = Math.max(c, a.length) }); (a.length > s.model.row_count || c > s.model.col_count) && s.model.resize(Math.max(s.model.row_count, a.length), Math.max(s.model.col_count, c)) } for (var d = 0; d < a.length; ++d) for (var e = a[d], f = 0; f < e.length; ++f) if (d + b.top < s.model.row_count && f + b.left < s.model.col_count) { var g = s.model.getCell(d + b.top, f + b.left, !0); g.isVisible() && g.value(e[f]) } } } function J(a, b) { a = $(a); return a.prop("tagName") == b ? a : a.parents(b) } function ja(a) { s.left_pressed = 1 == a.which; var b = J(a.target, "TD"); if (b && !b.hasClass("aux-cell") && !s.isBorderEditEnabled() && 1 == a.which) { var b = R(a.target), c = I(); G() && c.left == b.col && c.top == b.row || (y(b.row, b.col, b.row, b.col, a.ctrlKey), s.trigger("single_cell_selected", s.model.getCell(b.row, b.col), b.row, b.col)) } } function ca(a) { var b = J(a.target, "TD"); if (b && !b.hasClass("aux-cell") && !s.isBorderEditEnabled() && s.left_pressed) { b = $(a.target); b.offset(); b.width(); b.height(); var b = R(a.target), c = !1, d = s.selection_prev; null == s.selection_root && (s.selection_root = b, c = !0); !d || d.row == b.row && d.col == b.col || (c = !0); if (c) { var e = b.row, d = b.col; a = a.ctrlKey; var c = Math.max(0, Math.min(e, s.selection_root.row)), e = Math.max(e, s.selection_root.row), f = Math.max(0, Math.min(d, s.selection_root.col)), d = Math.max(d, s.selection_root.col), g = I(); a || f <= g.left && c <= g.top && d >= g.right && e >= g.bottom || N(); s.model.forEachCellInRange(c, f, e, d, K) } s.selection_prev = b } } function aa(a) { if ((a = J(a.target, "TD")) && !a.hasClass("aux-cell")) U().onDblClick() } k = k || {}; var s = this; this.model = a; this.theme = this.style_class = null; this.dom; this.colgroup; this.left_pressed = !1; this.cell_border_events_options = { deactivated: !0, onBorderOver: function(a, b, c) { c.addClass("alert_border_" + b[0]) }, onBorderLeave: function(a, b, c) { s.dom.css("cursor", "default"); c.removeClass("alert_border_" + b[0]) }, onBorderClick: function(a, b, c) { c = R(c); c = s.model.getVisibleCellPos(c.row, c.col); var d = c.row, e = c.col; c = s.model.getCell(d, e); var f = !s.getCellView(d, e).style.hasBorder(b); if ("right" == b) for (c.colspan(), b = d + c.rowspan() - 1, a.shiftKey && (d = 0, b = s.model.row_count - 1); d <= b; ++d) a = e + c.colspan() - 1, q("right", d, a, b, f); else if ("left" == b) for (b = d + c.rowspan() - 1, a.shiftKey && (d = 0, b = s.model.row_count - 1); d <= b; ++d) q("left", d, e, b, f); else if ("top" == b) for (b = e + c.colspan() - 1, a.shiftKey && (e = 0, b = s.model.col_count - 1), a = e; a <= b; ++a) t("top", d, a, b, f); else if ("bottom" == b) for (c.rowspan(), b = e + c.colspan() - 1, a.shiftKey && (e = 0, b = s.model.col_count - 1), a = e; a <= b; ++a) e = d + c.rowspan() - 1, t("bottom", e, a, b, f) } }; this.aux_row = null; this.aux_cells = []; this.aux_col_cells = []; this.aux_row_cells = []; this.selection_bounds = this.selection_prev = this.selection_root = null; this.selected_cells = {}; this.size_indicator = null; this.column_resize_enabled = k.column_resize_enabled || !1; this.hasBorder = function(a, b, c, d) { if (0 > a || a >= s.model.row_count || 0 > b || b >= s.model.col_count) return !1; var e = s.model.getCell(a, b), f = s.model.getVisibleCellPos(a, b), g = s.getCellView(a, b); if ("top" == c && f.row == a && g.style.hasBorder("top") || "bottom" == c && f.row + e.rowspan() - 1 == a && g.style.hasBorder("bottom") || "left" == c && f.col == b && g.style.hasBorder("left") || "right" == c && f.col + e.colspan() - 1 == b && g.style.hasBorder("right")) return !0; if (!d) { if ("left" == c) return s.hasBorder(a, b - 1, "right", !0); if ("right" == c) return s.hasBorder(a, b + 1, "left", !0); if ("top" == c) return s.hasBorder(a - 1, b, "bottom", !0); if ("bottom" == c) return s.hasBorder(a + 1, b, "top", !0) } return !1 }; this.model.on("row_inserted", C); this.model.on("column_inserted", function(a, b) { B("column", a); s.dom.find("tr").each(function(c, d) { if (0 < c) { var e = b[c - 1], f = m(e); $(d).find("td").eq(a).after(f.dom); e.view = f } }); s.selection_bounds = null }); this.model.on("row_removed", function(a, b) { s.selection_bounds = null; v("row", a); b.forEach(function(b, c) { E(b, a, c); b.view && b.view.remove() }); s.dom.find("tr").eq(a + 1).remove() }); this.model.on("column_removed", function(a, b) { s.selection_bounds = null; b.forEach(function(b, c) { E(b, c, a); b.view && b.view.remove() }); v("column", a) }); this.getCellView = function(a, b, c) { return s.model.getCell(a, b, c).view }; s.selectCell = K; s.selectCells = y; s.clearSelection = N; s.getSelectionBounds = I; s.forEachSelectedCell = Z; s.getSelectedCell = P; s.hasFixedLayout = function() { return "fixed" == s.dom.css("table-layout") }; s.enableFixedLayout = function(a) { if (a && !s.hasFixedLayout()) { s.dom.width(); var b = [], c = 0; s.dom.find("tr:first td").each(function(a, d) { b.push($(d).width()); c += $(d).width() }); c += b.length; s.dom.hide(); s.dom.addClass("fixed-size"); s.dom.css({ "table-layout": "fixed", width: c }); s.colgroup.find("col").each(function(a, c) { c = $(c); c.css({ width: b[a] + 1 }) }); s.dom.show() } else a || (s.dom.hide(), s.dom.removeClass("fixed-size"), s.dom.css({ "table-layout": "auto", width: "auto" }), s.colgroup.find("col").each(function(a, b) { $(b).css({ width: "auto" }) }), s.dom.show()) }; s.getColumnWidths = function(a) { var b = []; s.dom.find("tr:first td").each(function(a, c) { b.push($(c).width()) }); return 1 == a ? b : b.slice(1) }; s.setColumnWidth = function(a, b) { b += 1; s.colgroup.find("col").eq(a + 1).css({ width: b }) }; s.setSingleColumnWidth = function(a, b) { s.dom.css({ "table-layout": "fixed" }); for (var c = s.dom.width(), d = s.getColumnWidths(!0), e = d[a + 1], f = 0; f < d.length; ++f); c += -e + b; s.dom.hide(); s.dom.css({ "table-layout": "fixed", width: c }); s.setColumnWidth(a, b); s.dom.show() }; (function() { s.dom = $("
").addClass("aux-cell").addClass("aux-cell-" + a); this.index_view = $("").appendTo(this.dom); this.size_handle = null; "column" == a && (this.size_handle = $("
").addClass("size-handle").appendTo(this.dom), this.size_handle.present("SimpleDraggable"), this.draggable = this.size_handle.data("SimpleDraggable")); this.index = -1; $.observable(this); this.setIndex(b) } function d(a, d, k) { function n(a) { if (!s.isBorderEditEnabled()) { var b = a.target.nodeName; if (9 == a.which) la(), a.preventDefault(); else if (37 <= a.which && 40 >= a.which) { var c = !1; s.forEachSelectedCellView(function(a) { c |= a.edit_in_progress }); c || (b = { 37: [0, -1], 38: [-1, 0], 39: [0, 1], 40: [1, 0] }[a.which], Ba(b[0], b[1]), a.preventDefault()) } else 13 == a.which ? (b = U(), G() && !b.edit_in_progress && (b.startEditing(), a.preventDefault())) : 86 == a.which && a.ctrlKey ? (b = U(), G() && !b.edit_in_progress && PasteHelper.start(Ha, b.dom)) : 46 == a.which ? s.forEachSelectedCellView(function(a) { 0 == a.edit_in_progress && a.cell.value("") }) : 225 == a.which ? a.preventDefault() : "TABLE" == b && (76 == a.which && a.ctrlKey ? (s.forEachSelectedCellView(function(a) { a.style.setHorizontalAlign("left") }), a.preventDefault()) : 69 == a.which && a.ctrlKey ? (s.forEachSelectedCellView(function(a) { a.style.setHorizontalAlign("center") }), a.preventDefault()) : 82 == a.which && a.ctrlKey ? (s.forEachSelectedCellView(function(a) { a.style.setHorizontalAlign("right") }), a.preventDefault()) : G() && !a.ctrlKey && 27 != a.which && 16 != a.which && 18 != a.which && 91 != a.which && s.forEachSelectedCellView(function(a) { a.startEditing(!0) })) } } function p() { s.trigger("state_change") } function m(a) { a = new g(a); a.on("state_change", p); s.trigger("cell_created", a); return a } function q(a, b, c, d, e) { void 0 == d && (d = s.model.row_count - 1); var f = s.model.getVisibleCellPos(b, c), g = s.model.getCell(b, c); f.row == b && f.row + g.rowspan() - 1 <= d && ("right" == a && f.col + g.colspan() - 1 == c || "left" == a && f.col == c) && (e ? s.getCellView(f.row, f.col).style.addBorder(a) : s.getCellView(f.row, f.col).style.removeBorder(a)) } function t(a, b, c, d, e) { void 0 == d && (d = s.model.col_count - 1); var f = s.model.getVisibleCellPos(b, c), g = s.model.getCell(b, c); f.col == c && f.col + g.colspan() - 1 <= d && ("top" == a && f.row == b || "bottom" == a && f.row + g.rowspan() - 1 == b) && (e ? s.getCellView(f.row, f.col).style.addBorder(a) : s.getCellView(f.row, f.col).style.removeBorder(a)) } function x() { var a = $("
", { "class": "tableview", tabindex: 1, cellspacing: 3 }); s.colgroup = $("").appendTo(s.dom); d = $(d) || $("body"); d.append(s.dom); s.model.on("state_change", p); $.observable(s); s.dom.mousedown(ja).mousemove(ca).mouseup(function(a) { s.left_pressed = s.left_pressed && 1 != a.which; s.selection_root = null }).mousedown(function(a) { a.preventDefault(); a.stopPropagation() }).dblclick(aa).mouseleave(function(a) { s.left_pressed = !1 }).keydown(n); for (var a = 0; a < s.model.row_count; ++a) C(a, s.model.rows[a]); 0 < s.model.row_count && 0 < s.model.col_count && K(s.model.getCell(0, 0), 0, 0) })() } navigator.userAgent.toLowerCase().indexOf("chrome"); g.read_only = !1; g.prototype.initEventHandlers = function() { var a = this; a.event_handlers_initialized || (a.entry.blur(function(a) { a.stopImmediatePropagation(); a.preventDefault() }).keydown(function(b) { if (27 == b.which) { b.preventDefault(); b = window.scrollX; var d = window.scrollY; a.endEditing(); a.dom.parents("table").focus(); e(); null === c() && window.scrollTo(b, d) } }).on("mousedown mouseup mousemove click dblclick", function(b) { a.edit_in_progress && b.stopImmediatePropagation() }), a.event_handlers_initialized = !0) }; g.prototype.areEventHandlersInitialized = function() { return self.event_handlers_initialized }; g.prototype.onDblClick = function() { this.startEditing() }; g.prototype.onPasteContent = function(a) { var b = this.entry, c = b.text(), d = window.scrollX, e = window.scrollY; setTimeout(function() { window.scrollTo(d, e); var a = b.text(), g = a.length, t = "", x = ""; if (0 < c.length) for (var B = 0; B <= c.length; ++B) { var t = c.substr(0, B), x = c.substr(B), v = a.substr(g - x.length); if (0 == a.indexOf(t) && v == x) { a = a.substr(B, g - c.length); break } x = t = "" } a = t + TableImport.extractCellsFromString(a) + x; b.html(a) }, 3) }; g.prototype.show = function() { this.cell.isVisible() ? this.dom.show() : this.dom.hide() }; g.prototype.dump = function() { return { style: this.style.dump() } }; g.prototype.load = function(a, b) { a && this.style.load(a.style, b) }; g.prototype.select = function() { return this.is_selected ? !1 : (this.dom.addClass("selected"), this.is_selected = !0) }; g.prototype.unselect = function() { return this.is_selected ? (this.edit_in_progress && this.endEditing(), this.dom.removeClass("selected"), this.is_selected = !1, !0) : !1 }; g.prototype.remove = function() { this.endEditing(); this.dom.remove() }; g.prototype.startEditing = function(a) { if (0 == g.read_only && !this.edit_in_progress) { this.entry.addClass("entry-editing").attr("contenteditable", !0).focus(); a && this.entry.text(""); a = this.entry.get(0); var b, c; document.body.createTextRange ? (b = document.body.createTextRange(), b.moveToElementText(a), b.select()) : window.getSelection && (c = window.getSelection(), c.removeAllRanges(), b = document.createRange(), 0 < $(a).text().length ? b.setStart(a, 1) : b.selectNodeContents(a), c.addRange(b)); this.edit_in_progress = !0 } }; g.prototype.endEditing = function() { if (1 == this.edit_in_progress) { e(); this.entry.attr("contenteditable", !1).removeClass("entry-editing"); this.edit_in_progress = !1; var a = this.entry.html(), a = a.replace(/(
(?!
))|(
)/ig, "\n").replace(/<\/?div>/ig, ""), a = a.split("\n"), a = a.map(htmlDecode), a = a.join("\n"); this.ignore_model_change = !0; this.cell.value(a); this.entry.html(textToHTML(a)); this.ignore_model_change = !1 } }; b.prototype.setIndex = function(a) { if (a != this.index) { this.index = a; if ("row" == this.type) a += 1; else { for (var b = 0 == a ? "A" : ""; 0 < a;) b = String.fromCharCode(Math.floor(65 + a % 26)) + b, a = Math.floor(a / 26); a = b } this.index_view.text(a) } }; b.prototype.onRemoveRow = function(a) { "row" == this.type && this.index > a && this.setIndex(this.index - 1) }; b.prototype.onInsertRow = function(a) { "row" == this.type && this.index >= a && this.setIndex(this.index + 1) }; b.prototype.onInsertColumn = function(a) { "column" == this.type && this.index >= a && this.setIndex(this.index + 1) }; b.prototype.onRemoveColumn = function(a) { "column" == this.type && this.index > a && this.setIndex(this.index - 1) }; d.prototype.isSelectionRectangular = function() { var a = this.getSelectionBounds(); if (!a) return !1; for (var b = a.top; b <= a.bottom; ++b) for (var c = a.left; c <= a.right; ++c) if (!this.model.getCell(b, c).view.is_selected) return !1; return !0 }; d.prototype.mergeSelectedCells = function() { if (this.isSelectionRectangular()) { var a = this.getSelectionBounds(); this.clearSelection(); this.model.mergeCells(a.top, a.left, a.bottom, a.right); this.selectCell(this.model.getCell(a.top, a.left), a.top, a.left) } }; d.prototype.splitSelectedCell = function() { if (this.isSelectionRectangular()) { var a = this.getSelectionBounds(), b = this.model.getCell(a.top, a.left), c = b.rowspan(), b = b.colspan(); this.model.splitCell(a.top, a.left); this.selectCells(a.top, a.left, a.top + c - 1, a.left + b - 1) } }; d.prototype.forEachCellInColumn = function(a, b) { this.model.forEachCellInColumn(a, function(a) { b(a.view) }) }; d.prototype.forEachCellInRow = function(a, b) { this.model.forEachCellInRow(a, function(a, c) { b(a.view, c) }) }; d.prototype.forEachCellInRange = function(a, b, c, d, e) { this.model.forEachCellInRange(a, b, c, d, function(a, b, c) { e(a.view, b, c) }) }; d.prototype.forEachCell = function(a) { for (var b = 0; b < this.model.row_count; ++b) this.model.forEachCellInRow(b, function(c, d) { a(c.view, b, d) }) }; d.prototype.enableBorderEdit = function(a) { if (a) { this.dom.css("border-collapse", "separate"); this.dom.css("border-spacing", 3); this.dom.addClass("border-edit"); var b = this.cell_border_events_options; this.forEachCellView(function(a) { a.dom.borderEvents(b) }) } else this.dom.css("border-collapse", "collapse"), this.dom.removeClass("border-edit"); this.cell_border_events_options.deactivated = !a }; d.prototype.isBorderEditEnabled = function() { return !this.cell_border_events_options.deactivated }; d.prototype.forEachSelectedCellView = function(a, b, c) { this.forEachSelectedCell(function(b) { a(b.view) }, c) }; d.prototype.forEachCellViewInRange = function(a, b, c, d, e, g) { g = g || !1; var q = []; e = Math.min(e + 1, this.model.col_count); for (d = Math.min(d + 1, this.model.row_count); b < d; ++b) for (var t = c; t < e; ++t) { var x = this.model.getCell(b, t, !0), B = 0, v = 0; 0 == x.isVisible() && 0 == g && (v = Math.min(x.colspan(), 0), B = Math.min(x.rowspan(), 0)); x = this.getCellView(b + B, t + v, g); - 1 == q.indexOf(x) && (a(x, b, t), q.push(x)) } }; d.prototype.forEachCellView = function(a, b) { this.forEachCellViewInRange(a, 0, 0, this.model.row_count - 1, this.model.col_count - 1, b) }; d.prototype.copySelected = function() { var a = [], b = -1, c = []; this.forEachSelectedCell(function(d, e, g) { b != e && -1 != b && (a.push(c), c = []); b = e; c.push(d.value()) }); a.push(c); for (var d = [], e = 0; e < a.length; ++e) d.push(a[e].join("\t")); return d.join("\n") }; d.prototype.cutSelected = function() { var a = this.copySelected(); this.forEachSelectedCell(function(a) { a.value("") }); this.trigger("state_change"); return a }; d.prototype.reset = function() { this.clearSelection(); this.enableFixedLayout(!1); this.model.reset(); this.model.forEachCellInRange(0, 0, this.model.row_count - 1, this.model.col_count - 1, function(a) { a.view.style.reset() }); this.selectCells(0, 0, 0, 0); this.setTheme(null); this.trigger("onload") }; d.prototype.setStyleClass = function(a) { null != this.style_class && this.dom.removeClass(this.style_class); (this.style_class = a) && this.dom.addClass(a) }; d.prototype.setTheme = function(a, b) { (this.theme = a) && !b ? this.setStyleClass(TableThemes.createTheme(a)) : this.setStyleClass(null); this.trigger("theme_set", a) }; d.prototype.removeSelectedColumns = function() { var a = []; this.forEachSelectedCell(function(b, c, d) { -1 == a.indexOf(d) && a.push(d) }); a.sort(function(a, b) { return a - b }); for (var b = a.length - 1; 0 <= b; --b) this.model.removeColumn(a[b]) }; d.prototype.removeSelectedRows = function() { var a = []; this.forEachSelectedCell(function(b, c, d) { -1 == a.indexOf(c) && a.push(c) }); a.sort(function(a, b) { return a - b }); for (var b = a.length - 1; 0 <= b; --b) this.model.removeRow(a[b]) }; d.prototype.dump = function() { for (var a = this.model.row_count, b = this.model.col_count, c = [], d = 0; d < a; ++d) { for (var e = [], g = 0; g < b; ++g) { var q = this.model.getCell(d, g, !0).view; q && e.push(q.dump()) } c.push(e) } a = { rows_views: c, model: this.model.dump(), theme: this.theme, fixed_layout: this.hasFixedLayout() }; this.hasFixedLayout() && (a.col_widths = this.getColumnWidths()); return a }; d.prototype.setLoadIgnore = function(a) { this.load_ignore = a }; d.prototype.load = function(a) { var b = this.load_ignore || {}; if (a && a.model && a.rows_views) { var c = this.getSelectionBounds(); this.model.load(a.model, b); for (var d = this.model.row_count, e = this.model.col_count, g = 0; g < d; ++g) for (var q = a.rows_views[g], t = 0; t < e; ++t) this.getCellView(g, t, !0).load(q[t], b); a.theme && this.setTheme(a.theme, b.theme); if (1 == a.fixed_layout && $.isArray(a.col_widths) && !b.fixed_layout) { this.enableFixedLayout(!0); b = Math.min(a.col_widths.length, this.model.col_count); for (e = d = 0; e < b; ++e) d += a.col_widths[e]; d += this.dom.find("col:first").width(); this.dom.css({ "table-layout": "fixed", width: d }); for (e = 0; e < b; ++e) this.setColumnWidth(e, a.col_widths[e]) } c && c.right < this.model.col_count && c.bottom < this.model.row_count ? this.selectCells(c.top, c.left, c.bottom, c.right) : this.selectCells(0, 0, 0, 0); this.trigger("onload") } }; d.prototype.setReadOnly = function(a) { g.read_only = a }; return d }(); var TTable = function() { return function(c) { var g = new TableModel; g.insertRow(["Pet", "Name"]); g.insertColumn(["Age"]); g.insertRow(["Snake", "Jimmy", 2]); g.insertRow(["Cow", "Molly", 11], 1); var e = new TableView(g, c); g.insertRow(["Cat", "Jinks", 7], 2); g.rows[1][1].value = "Jolly"; g.insertColumn(["Sex", "F", "M", "M"]); g.mergeCells(1, 0, 1, 1); g.splitCell(1, 0); g.mergeCells(1, 0, 2, 1); g.mergeCells(0, 0, 3, 1); g.splitCell(0, 0); g.mergeCells(0, 0, g.row_count - 1, g.col_count - 1); g.splitCell(0, 0); g.insertColumn(["x", "x", "x", "x"]); $('').appendTo($(c)).click(function() { g.insertEmptyColumn() }); $('').appendTo($(c)).click(function() { g.insertEmptyRow() }); $("
").appendTo($(c)); $("").appendTo($(c)).click(function() { var b = e.selection; b && b.top == b.bottom && g.removeRow(b.top) }); $("").appendTo($(c)).click(function() { var b = e.selection; b && b.left == b.right && g.removeColumn(b.left) }); $("").appendTo($(c)).click(e.mergeSelectedCells.bind(e)); $("").appendTo($(c)).click(e.splitSelectedCell.bind(e)) } }(); var TableThemes = function() { function c(a, b) { b = b || $.extend(!0, {}, k); for (var d in b) if (b.hasOwnProperty(d)) { var e = b[d]; "object" == typeof e ? b[d] = c(a, e) : "string" == typeof e && "$" == e.substr(0, 1) && a.hasOwnProperty(e.substr(1)) && (b[d] = a[e.substr(1)]) } return b } function g(a) { var b = 0, c, d; if (0 == a.length) return b; c = 0; for (var e = a.length; c < e; c++) d = a.charCodeAt(c), b = (b << 5) - b + d, b |= 0; return b } function e(a) { for (var b = {}, c = 0; c < a.length; ++c) $.extend(!0, b, a[c]); return b } function b(a, c, d, e, f) { e = e || !1; c = c || ""; 0 < c.length && (c += " "); var g = [], k; for (k in a) if (a.hasOwnProperty(k) && ("_" != k[0] || a[k]._active && f)) { var n = a[k]; "object" == typeof n ? ("_" == k[0] && (k = k.substr(1)), e ? (g.push(c + k + "{"), n = b(n, null, !0), g = g.concat(n), g.push("}")) : (n = b(n, null, !0), g.push(c + k + "{" + n.join("") + "}"))) : "_" != k[0] && g.push((e ? "\t" : "") + k + ":" + n + ";") } return d ? g : g.join("\n") } var d = { " ": { _active: !0, "border-collapse": "collapse", "border-spacing": 0 }, td: { "font-family": "Arial, sans-serif", "font-size": "14px", padding: "10px 5px", "border-style": "solid", "border-width": "0px", overflow: "hidden", "word-break": "normal" }, th: { "font-family": "Arial, sans-serif", "font-size": "14px", "font-weight": "normal", padding: "10px 5px", "border-style": "solid", "border-width": "0px", overflow: "hidden", "word-break": "normal" }, _row_odd_td: { _active: !1 }, "_tr:nth-child(odd) td": { _active: !1 }, "_tr:nth-child(2) td": { _active: !0 }, _col_even_td: { _active: !1 }, "_td:nth-child(odd)": { _active: !1 }, "_tr:hover td": { _active: !1 } }, a = { "No borders": { " ": { border: "none" } }, "All borders": { td: { "border-width": "1px" }, th: { "border-width": "1px" } }, Horizontal: { td: { "border-top-width": "1px", "border-bottom-width": "1px" }, th: { "border-top-width": "1px", "border-bottom-width": "1px" } }, Outer: { " ": { "border-width": "1px", "border-style": "solid" } } }, f = { "No alternate": {}, "Alternate rows": { "_tr:nth-child(odd) td": { _active: !0 }, "_tr:nth-child(2) td": { _active: !0 }, _row_odd_td: { _active: !0 } }, "Alternate columns": { _col_even_td: { _active: !0 }, "_td:nth-child(odd)": { _active: !0 }, "_tr:nth-child(2) td": { _active: !0 } } }, k = { " ": { "border-color": "$border_color" }, td: { "border-color": "$border_color", color: "$td_text_color", "background-color": "$td_bg_color" }, th: { "border-color": "$border_color", color: "$th_text_color", "background-color": "$th_bg_color" }, "_tr:nth-child(2) td": { color: "$th_text_color", "background-color": "$th_bg_color" }, _row_odd_td: { "background-color": "$td_alt_bg_color" }, _col_even_td: { "background-color": "$td_alt_bg_color" }, "_td:nth-child(odd)": { "background-color": "$td_alt_bg_color" }, "_tr:nth-child(odd) td": { "background-color": "$td_alt_bg_color" }, "_tr:hover td": { "background-color": "$td_hover_bg_color", color: "$td_hover_text_color" } }, n = { Default: {}, Light: c({ border_color: "#ccc", td_text_color: "#333", td_bg_color: "#fff", th_text_color: "#333", th_bg_color: "#f0f0f0", td_alt_bg_color: "#f9f9f9", td_hover_bg_color: "#f0f0f0", td_hover_text_color: "#222" }), Orange: c({ border_color: "#aaa", td_text_color: "#333", td_bg_color: "#fff", th_text_color: "#fff", th_bg_color: "#f38630", td_alt_bg_color: "#FCFBE3", td_hover_bg_color: "#FFC950", td_hover_text_color: "#222" }), Blue: c({ border_color: "#999", td_text_color: "#444", td_bg_color: "#F7FDFA", th_text_color: "#fff", th_bg_color: "#26ADE4", td_alt_bg_color: "#D2E4FC", td_hover_bg_color: "#FFCC00", td_hover_text_color: "#333" }), Violet: c({ border_color: "#aabcfe", td_text_color: "#669", td_bg_color: "#e8edff", th_text_color: "#039", th_bg_color: "#b9c9fe", td_alt_bg_color: "#D2E4FC", td_hover_bg_color: "#d0dafd", td_hover_text_color: "#339" }), Green: c({ border_color: "#bbb", td_text_color: "#594F4F", td_bg_color: "#E0FFEB", th_text_color: "#493F3F", th_bg_color: "#9DE0AD", td_alt_bg_color: "#C2FFD6", td_hover_bg_color: "#E5FCC2", td_hover_text_color: "#333" }) }, p = { None: {}, Highlight: { _hover_theme: { _active: !0 } } }, m = {}; return { ColorThemes: n, BorderThemes: a, HoverThemes: p, "Alternate Rows/Columns Themes": f, combineThemes: e, createTheme: function(c) { var k = "theme" + Math.abs(g(JSON.stringify(c))); if (!m.hasOwnProperty(k)) { var x = [d]; c["Alternate Rows/Columns Theme"] && x.push(f[c["Alternate Rows/Columns Theme"]]); c.ColorTheme && x.push(n[c.ColorTheme]); c.HoverTheme && x.push(p[c.HoverTheme]); c.BorderTheme && x.push(a[c.BorderTheme]); c = e(x); m[k] = c; c = b(c, "." + k, !1, !1, !0); x = document.createElement("div"); c = c.replace(/padding: 10px/, "padding: 0px"); x.innerHTML = '­"; document.body.appendChild(x.childNodes[1]) } return k }, getThemeById: function(a) { return m[a] }, themeToStr: b } }(); (function(c, g, e, b) { function d(a, b) { this.el = a; this.$el = c(a); this.max_rows = b.max_rows; this.max_cols = b.max_cols; this.max_visible_rows = b.max_visible_rows || 15; this.max_visible_cols = b.max_visible_cols || 15; this.$table = null; this.hover_range = { row: -1, col: -1 }; this.size = { rows: b.rows, cols: b.cols }; this.select_size_callback = b.onSetSize; this.$el.data("SizeChooser", this); this.init() } d.prototype.init = function() { function a() { q.addClass("display-block") } function b() { q.removeClass("display-block") } function d(a) { 13 == a.which && (m.setSize(parseInt(m.rows_input.val()), parseInt(m.cols_input.val())), b()) } for (var e = c("
", { "class": "SizeChooser" }), g = c("
").appendTo(e), m = this, q = m.$el.parents(".dropdown-menu"), t = 0; t < this.max_visible_rows; ++t) { for (var x = c(""), B = 0; B < this.max_visible_cols; ++B) { var v = c(""); x.append(v); v.mousemove(function(a) { m.onCellMousemove(a) }) } g.append(x) } this.$table = g; this.$el.append(e); this.$size_form = c("").appendTo(e); this.rows_input = c("").val(this.size.rows).keydown(d).on("focus", a).on("blur", b).appendTo(this.$size_form); this.$size_form.append(c(" x ")); this.cols_input = c("").val(this.size.cols).keydown(d).on("focus", a).on("blur", b).appendTo(this.$size_form); this.setSize(this.size.rows, this.size.cols, !0); g.mousedown(function(a) { m.onMousedown(a) }); g.mouseleave(function() { m.setSize(m.size.rows, m.size.cols, !0); m.setHoverRange(m.size.rows - 1, m.size.cols - 1) }); this.rows_cache = null }; d.prototype.forEachCell = function(a) { if (null == this.rows_cache) { var b = []; this.$table.find("tr").each(function(a, d) { var e = []; c(d).find("td").each(function(a, b) { e.push(b) }); b.push(e) }); this.rows_cache = b } for (var d = 0; d < this.rows_cache.length; ++d) for (var e = this.rows_cache[d], g = 0; g < e.length; ++g) a(e[g], d, g) }; d.prototype.onCellMousemove = function(a) { var b; b = a.target; for (b = c(b); "td" != b.get(0).nodeName.toLowerCase();) b = b.parent(); a = b.index(); b = c(b.parent()).index(); this.setHoverRange(b, a) }; d.prototype.onMousedown = function(a) { 0 <= this.hover_range.col && 0 <= this.hover_range.row && this.setSize(this.hover_range.row + 1, this.hover_range.col + 1) }; d.prototype.setHoverRange = function(a, b) { if (this.hover_range.row != a || this.hover_range.col != b) this.forEachCell(function(d, e, g) { e <= a && g <= b ? c(d).addClass("SizeChooser-hover") : c(d).removeClass("SizeChooser-hover") }), this.hover_range.row = a, this.hover_range.col = b, this.rows_input.val(a + 1), this.cols_input.val(b + 1) }; d.prototype.setSize = function(a, b, d) { a = a || this.size.rows; b = b || this.size.cols; a = Math.max(1, Math.min(this.max_rows, a)); b = Math.max(1, Math.min(this.max_cols, b)); this.forEachCell(function(d, e, g) { e < a && g < b ? c(d).addClass("SizeChooser-selected") : c(d).removeClass("SizeChooser-selected") }); this.size.rows = a; this.size.cols = b; this.rows_input.val(a); this.cols_input.val(b); !d && this.select_size_callback && this.select_size_callback(a, b) }; c.fn.SizeChooser = function(a) { return this.each(function() { c.data(this, "SizeChooser") || c.data(this, "SizeChooser", new d(this, a)) }) } })(jQuery, window, document, void 0); (function(c) { function g(e, b) { this.el = c(e); this.onChange = b.onChange; this.init() } g.prototype = { init: function() { var e = this, b = e.el, d = e.el.parents(".dropdown-menu"); e.el.on("mouseenter", function() { d.addClass("display-block") }).on("mouseleave", function() { d.removeClass("display-block") }); c("
CompanyQ1Q2Q3
Microsoft20.330.523.5
Google50.240.6345.23
Apple25.430.233.3
").addClass(q).appendTo(g).click(function() { e.theme_selector.addTheme(a, b) }); e.theme_selector.on("theme_added", function(c, d) { if (a == c) b == d ? t.addClass("selected") : t.removeClass("selected"); else { m[c + "Theme"] = d; var e = TableThemes.createTheme(m); t.removeClass(q).addClass(e); q = e } }); e.theme_selector.on("theme_set", function(a) { a[d] == b ? t.addClass("selected") : t.removeClass("selected"); m = c.extend({}, a); m[d] = b; a = TableThemes.createTheme(m); t.removeClass(q).addClass(a); q = a }) }) }); b.appendTo(c("body")); b.present("SimpleAccordion", { item_header_selector: "h3" }); this.theme_chooser = b; e.theme_selector.setTheme(e.theme_selector.themes) } var d = c("#theme-select").offset(); this.theme_chooser.css({ left: c(".tableview").first().offset().left, top: d.top + 30 }).fadeIn() }; g.prototype.initResultControlPanel = function() { ZeroClipboard.config({ swfPath: "/static/ZeroClipboard.swf" }); var e = this; (new ZeroClipboard(c(".with-zero-clipboard"))).on("copy", function(b) { b = c(b.target).data("action-id"); "cell_contents_cut" == b ? (b = e.table_view.cutSelected(), ZeroClipboard.setData("text/plain", b)) : "cell_contents_copy" == b ? ZeroClipboard.setData("text/plain", e.table_view.copySelected()) : "copy-to-clipboard" == b && (b = c("#result-code").text(), -1 != navigator.appVersion.indexOf("Win") && (b = b.replace(/\n/g, "\r\n")), ZeroClipboard.setData("text/plain", b)) }) }; g.prototype.initUndoRedo = function() { var e = new UnReDo(this.table_view); this.unredo = e; e.addChange(); c(document).keydown(function(b) { b.ctrlKey && 90 == b.which && "DIV" != b.target.nodeName ? e.undo() : b.ctrlKey && 89 == b.which && "DIV" != b.target.nodeName && e.redo() }); c("#edit_undo").click(function() { e.undo() }); c("#edit_redo").click(function() { e.redo() }) }; g.prototype.initTableSave = function() { var e = this; c("#table-name").keydown(function(b) { 13 == b.which && b.preventDefault() }); c("#table-save-link").click(function() { var b = JSON.stringify(e.table_view.dump()), b = b.replace(/[\\]/g, "\\\\").replace(/[\"]/g, '\\"').replace(/[\']/g, "\\'").replace(/[\/]/g, "\\/").replace(/[\b]/g, "\\b").replace(/[\f]/g, "\\f").replace(/[\n]/g, "\\n").replace(/[\r]/g, "\\r").replace(/[\t]/g, "\\t"); c("#table-save-data").val(b); b = c("#table-save-form").serialize(); c.fileDownload("/table-save", { dialogOptions: { modal: !1 }, httpMethod: "POST", data: b, successCallback: function() { c("#save_table_dialog").modal("hide") } }); return !1 }) }; g.prototype.initTableAutosave = function() { function e() { c("#edit_autosave i").removeClass("icon-check-minus").addClass("icon-check") } function b() { c("#edit_autosave i").removeClass("icon-check").addClass("icon-check-minus") } var d = this, a = docCookies.getItem("tg-autosave"), f = null === a || "1" === a; f ? e() : b(); c("#edit_autosave").click(function() { f ? (f = !1, docCookies.setItem("tg-autosave", "0", Infinity), DB("tg-table").put(""), d.persistence.disable(), b()) : (f = !0, docCookies.setItem("tg-autosave", "1", Infinity), d.persistence.enable(), e()) }); f && (a = PersistenceHelper.load(), null != a && this.table_view.load(a)) }; g.prototype.initTableCellContextMenu = function() { var c = this.table_view, b = c.dom; b.get(0).oncontextmenu = function() { return !1 }; b.contextmenu({ target: "#table-cell-menu" }); this.observable.on("cell_contents_cut", function(b) { b = c.copySelected(); console.log("Cutting text: " + b); ZeroClipboard.setData("text/txt", "dupa") }); this.observable.on("cell_contents_copy", function(c) { b.contextmenu("hide") }) }; g.prototype.init_table_context_menus = function() { function e() { c.each(c(".aux-cell-column"), function(a, b) { c(b).contextmenu({ target: "#table-aux-col-menu" }) }) } function b() { c.each(c(".aux-cell-row"), function(a, b) { c(b).contextmenu({ target: "#table-aux-row-menu" }) }) } var d = this, a = d.table_view, f = d.table_view.model; c("#table-aux-col-menu").present("SimpleMenu", { menu_item_id_attr: "data-menu-item-id" }); var g = c("#table-aux-col-menu").data("SimpleMenu"); g && (c('*[data-menu-item-id="add_to_the_left"]').click(function() { var b = a.getSelectionBounds(); b && f.insertEmptyColumn(b.left) }), c('*[data-menu-item-id="add_to_the_right"]').click(function() { var b = a.getSelectionBounds(); b && f.insertEmptyColumn(b.right + 1) }), c('*[data-menu-item-id="remove_column"]').click(function() { a.removeSelectedColumns() }), c('*[data-menu-item-id="set_column_width"]').click(function() { d.show_column_width_dialog() }), e()); c("#table-aux-row-menu").present("SimpleMenu", { menu_item_id_attr: "data-menu-item-id" }); if (g = c("#table-aux-row-menu").data("SimpleMenu")) c('*[data-menu-item-id="add_row_above"]').click(function() { var b = a.getSelectionBounds(); b && f.insertEmptyRow(b.top) }), c('*[data-menu-item-id="add_row_below"]').click(function() { var b = a.getSelectionBounds(); b && f.insertEmptyRow(b.bottom + 1) }), c('*[data-menu-item-id="remove_row"]').click(function() { a.removeSelectedRows() }), b(); f.on("row_inserted", b); f.on("column_inserted", e) }; g.prototype.initColumnWidthDialog = function() { function e() { for (var c = parseInt(a.val()), e = b.table_view, g = e.getSelectionBounds(), p = g.left; p <= g.right; ++p) e.setSingleColumnWidth(p, c); d.modal("hide") } var b = this, d = c("#column_width_dialog"), a = c('input[type="number"]', d); c('input[type="number"]', d).keydown(function(a) { 13 == a.which && (a.preventDefault(), e()) }); c('input[type="submit"]', d).click(function(a) { a.preventDefault(); e() }) }; g.prototype.show_column_width_dialog = function() { var e = c("#column_width_dialog"); if (null != this.table_view.getSelectedCell()) { var b = this.table_view.getSelectionBounds(), b = this.table_view.getColumnWidths()[b.left]; c('input[type="number"]', e).val(b); e.modal("show") } }; g.prototype.initTableShare = function() { function e(a) { c("#table-share-link-btn").hide(); c("#share-table-error").text(a).show() } function b(a) { 2E3 >= a.length ? (c("#table-share-data").val(a), a = c("#table-share-form").serialize(), c.ajax({ url: "/table-share", type: "POST", data: a, success: function(a, b, d) { c("#table-share-link-btn").removeClass("btn-warning").addClass("btn-primary").hide(); a.success && a.short_url ? (c("#share-table-link").attr("href", a.short_url).text(a.short_url), c("#share-table-result").show()) : e(a.error) }, error: function(a, b, c) {} })) : e("We are sorry but only small tables can be shared") } var d = this.table_view; c("#share-table-btn").click(function() { c("#share-table-error").hide(); c("#share-table-result").hide(); c("#table-share-link-btn").removeClass("btn-warning").addClass("btn-primary").text("Get link to your table").show(); c("#share_table_dialog").modal("show") }); c("#table-share-link-btn").click(function() { c(this).removeClass("btn-info").addClass("btn-warning").text("Please wait..."); var a = d.dump(); CompressUtils.compress_str_64(JSON.stringify(a), b) }); c("#share-table-link").click(function() { var a = c(this).attr("href"); window.open(a, "_blank").focus() }) }; return g }(jQuery); function DB(c) { var g = window.localStorage || {}; return { get: function() { return JSON.parse(g[c] || "{}") }, put: function(e) { g[c] = JSON.stringify(e) } } }; var UnReDo = function() { function c(c) { var e = this; this.curr_state = null; this.undo_list = []; this.redo_list = []; this.table_view = c; this.ignore_next_change = !1; this.size_limit = 10; var b = null; c.on("state_change", function() { null != b && window.clearTimeout(b); b = setTimeout(function() { e.ignore_next_change || e.addChange(); e.ignore_next_change = !1 }, 600) }) } c.prototype.addChange = function() { var c = this.table_view.dump(); null == this.curr_state ? this.curr_state = c : (this.undo_list.length == this.size_limit && this.undo_list.splice(0, 1), this.undo_list.push(this.curr_state), this.curr_state = c, this.redo_list.splice(0, this.redo_list.length)) }; c.prototype.undo = function() { 0 != this.undo_list.length && (this.redo_list.push(this.curr_state), this.curr_state = this.undo_list.pop(), this.ignore_next_change = !0, this.table_view.load(this.curr_state)) }; c.prototype.redo = function() { 0 != this.redo_list.length && (this.undo_list.push(this.curr_state), this.curr_state = this.redo_list.pop(), this.ignore_next_change = !0, this.table_view.load(this.curr_state)) }; c.prototype.clear = function() { this.undo_list.length = 0; this.redo_list.length = 0; this.curr_state = null }; return c }(), PersistenceHelper = function() { function c(c) { this.table_view = c; this.timeout = null; this.storage = DB("tg-table"); this.enabled = !0 } c.prototype.run = function() { null != this.timeout && window.clearInterval(this.timeout); this.save(); var c = this; this.timeout = setInterval(function() { c.enabled && c.save() }, 4E3) }; c.prototype.save = function() { var c = this.table_view.dump(); this.storage.put(c) }; c.load = function() { return DB("tg-table").get() }; c.prototype.disable = function() { this.enabled = !1 }; c.prototype.enable = function() { this.enabled = !0 }; return c }(); var HTMLExportOptions = { CENTERING: "Center table horizontally" }, HTMLExport = function() { function c(b, a) { var c = [], e; for (e in b) b.hasOwnProperty(e) && "_" != String(e).substr(0, 1) && c.push(e + ":" + b[e]); c = c.join(";"); return a ? c : "{" + c + "}" } function g(b) { if (null == b || "object" != typeof b) return b; if (b instanceof Date) { var a = new Date; a.setTime(b.getTime()); return a } if (b instanceof Array) { for (var a = [], c = 0, e = b.length; c < e; c++) a[c] = g(b[c]); return a } if (b instanceof Object) { a = {}; for (c in b) b.hasOwnProperty(c) && (a[c] = g(b[c])); return a } throw Error("Unable to copy obj! Its type isn't supported."); } function e(b, a) { for (var c = [], e = 0; e < a; ++e) c.push(b); return c } function b(b, a) { var c = "\n"; b && (c += TableThemes.themeToStr(b, ".tg") + "\n"); for (var e in a) a.hasOwnProperty(e) && (c += e + a[e] + "\n"); return Utils.format_tag("style", c, { type: "text/css" }) } return function(d, a, f, k, n) { f = f || !1; void 0 == k && (k = "\n"); var p = d.model, m = [], q = "" == k ? 0 : 2, t = d.style_class, x = !a && t && -1 == t.indexOf("zerocss"); a = {}; var B = {}, v = {}, C = 0, K = g(TableThemes.getThemeById(t)), A = d.getCellView(0, 0).style; A && (A = A.getPadding(), void 0 != A.top && (K.td.padding = A.top + "px " + A.left + "px", K.th.padding = A.top + "px " + A.left + "px")); for (var y = 0; y < p.row_count; ++y) { var E = e(" ", 2 * q).join(""), N = []; p.forEachCellInRow(y, function(a, b) { if (a.isVisible()) { var d = {}; 1 == y % 2 && K && K.hasOwnProperty("_row_odd_td") && K._row_odd_td._active ? d = TableThemes.combineThemes([d, K._row_odd_td]) : 0 < y && 1 == b % 2 && K && K.hasOwnProperty("_col_even_td") && K._col_even_td._active && (d = TableThemes.combineThemes([d, K._col_even_td])); var d = TableThemes.combineThemes([d, a.view.style.toCSS()]), e = String; var g = JSON.stringify(d), k = 0, n, p; if (0 != g.length) { n = 0; for (var m = g.length; n < m; n++) p = g.charCodeAt(n), k = (k << 5) - k + p, k |= 0 } e = e(k); if (!B.hasOwnProperty(e)) { B[e] = d; ++C; g = Math.abs(e); k = Math.pow(36, 4); g %= k; k = ""; for (n = 0; 4 > n; ++n) k += "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" [g % 36], g = Math.floor(g / 36); k = k.split("").reverse().join(""); v[e] = "tg-" + k } g = {}; x && !f && (g["class"] = v[e]); x && f && (d = TableThemes.combineThemes([K[0 == y ? "th" : "td"], d ]), g.style = c(d, !0)); d = y; e = g; void 0 == e && (e = {}); 1 < a.colspan() && (e.colspan = a.colspan()); 1 < a.rowspan() && (e.rowspan = a.rowspan()); g = textToHTML(a.value().toString()); d = Utils.format_tag(0 == d ? "th" : "td", g, e); N.push(E + d) } }); E = e(" ", q).join(""); m.push([].concat([E + ""], N, [E + ""]).join(k)) } - 1 != n.indexOf(HTMLExportOptions.CENTERING) && (K[" "].margin = "0px auto"); n = ""; p = m.join(k); m = [""]; q = {}; if (x && !f) { for (var I in B) B.hasOwnProperty(I) && (n = c(B[I]), "{}" != n && (a[".tg ." + v[I]] = n)); q["class"] = "tg"; t = t.split("-"); t = t[t.length - 1]; n = b(K, a) } else x && f && (q.style = c(K[" "], !0)); if (d.hasFixedLayout()) { d = d.getColumnWidths(); t = []; for (y = a = 0; y < d.length; ++y) d[y] += 1, t.push(''), a += d[y]; m.push(""); m.push(t.join(k)); m.push(""); q.style += ";table-layout: fixed; width: " + a.toFixed(0) + "px" } m.push(p); m.push(""); d = Utils.format_tag("table", m.join(k), q); m = []; n && m.push(n); m.push(d); return m.join(k) } }(); var LaTeXExportOptions = { CAPTION_ABOVE: "Caption above", CAPTION_BELOW: "Caption below", CENTERING: "Center table horizontally", SCALE_TABLE: "Scale table to text width" }, LaTeXExport = function() { function c(a, b) { if (!a) throw b || "Assertion failed"; } function g(a, b) { for (var c = !1, d = 0; d < b.length && !c; ++d) b[d].val == a && (b[d].count += 1, c = !0); c || b.push({ val: a, count: 1 }) } function e(a) { this.table_view = a; for (var b = this.table = a.model, c = p(function() { return p(0, b.col_count + 1) }, b.row_count), d = 0; d < b.row_count; ++d) for (var e = 0; e < b.col_count; ++e) { var f = b.getCell(d, e, !0); if (f.isVisible()) for (var g = a.getCellView(d, e, !0).style, k = g.hasBorder("left"), g = g.hasBorder("right"), n = 0; n < f.rowspan(); ++n) for (var m = d + n, q = 0; q < f.colspan(); ++q) { var t = e + q; c[m][t] |= k; c[m][t + 1] |= g } } for (d = 0; d < b.row_count; ++d) for (e = 1; e < b.col_count; ++e) 0 < c[d][e - 1] && 0 < c[d][e] && (c[d][e] = 2); a = []; for (e = 0; e <= b.col_count; ++e) { f = !0; for (d = 0; d < b.row_count; ++d) f &= 0 < c[d][e]; a.push(f) } this.vlines = c; this.continuous_vlines = a } function b(a) { this.table_view = a; this.table = a.model; this.colors_used = !1; var b = this.table, c = [], d = p(function() { return p(null, b.col_count) }, b.row_count); this.fg_colors = d; for (var e = 0; e < b.row_count; ++e) { for (var f = [], k = 0; k < b.col_count; ++k) { var n = a.getCellView(e, k, !1).style; n.hasBgColor() ? (f.push(n.getBgColor()), this.colors_used = !0) : f.push(null); n.hasTextColor() && (d[e][k] = n.getTextColor(), this.colors_used = !0) } c.push(f) } f = []; for (k = 0; k < b.col_count; ++k) { a = []; for (e = 0; e < b.row_count; ++e) g(c[e][k], a); for (var d = null, n = !1, m = 0; m < a.length; ++m) { var q = a[m]; null == d ? d = q : q.count > d.count && (d = q); null == q.val && (n = !0) } f.push(null); !n && null != d && d.count >= b.row_count / 2 && (f[k] = d.val) } this.column_colors = f; f = []; for (e = 0; e < b.row_count; ++e) { a = []; for (k = 0; k < b.col_count; ++k) g(c[e][k], a); d = null; n = !1; for (m = 0; m < a.length; ++m) q = a[m], null == d ? d = q : q.count > d.count && (d = q), null == q.val && (n = !0); f.push(null); !n && null != d && d.count >= b.col_count / 2 && (f[e] = d.val) } this.row_colors = f; for (e = a = f = 0; e < b.row_count; ++e) for (k = 0; k < b.col_count; ++k) d = this.table.getCell(e, k), d = 1 < d.rowspan() || 1 < d.colspan(), (null == this.column_colors[k] || d || c[e][k] != this.column_colors[k]) && ++f, (null == this.row_colors[e] || d || c[e][k] != this.row_colors[e]) && ++a; if (a < f) for (k = 0; k < b.col_count; ++k) this.column_colors[k] = null; else for (e = 0; e < b.row_count; ++e) this.row_colors[e] = null } function d(a, b, c) { var d = [], e = C.getColumnsVLines(); b.forEach(function(a, b) { d.push(e[b]); d.push(c.addColumnColor(a[0], b)) }); d.push(e[e.length - 1]); return d.join("") } function a(a) { for (var b = [], c = 0, d = a.model.col_count; c < d; ++c) b.push(f(a, c)); return b } function f(a, b) { var c = { left: 0, center: 0, right: 0 }; a.forEachCellInColumn(b, function(a) { a.cell.isVisible() && (c[a.style.getHorizontalAlign()] += Math.max(0, a.cell.rowspan())) }); return ["left", "center", "right"].sort(function(a, b) { return -(c[a] - c[b]) })[0] } function k(a) { a = a.split(/(?:(^|[^\\]))(\$[^\$]+\$)/g); return $.map(a, function(a) { return 0 < a.length && "$" == a[0] && "$" == a[a.length - 1] ? a : a.replace(/(^|[^\\])([&%_#\{\}\$])/g, "$1\\$2").replace(/([\[\]])/g, "{$1}").replace(//g, "\\textgreater") }).join("") } function n(a, b, c) { for (var d = c[b], e = 1; e < a.colspan(); ++e) d += c[b + e]; return d } function p(a, b) { var c = []; if ("function" == typeof a) for (var d = 0; d < b; ++d) c.push(a()); else for (d = 0; d < b; ++d) c.push(a); return c } function m(a, b) { for (var c = p(0, a.col_count), d = 0; d < a.row_count; ++d) { var e = 0, f = b[d]; a.forEachCellInRow(d, function(a, b) { 1 == a.colspan() && (c[b] = Math.max(c[b], f[e].length)); 1 <= a.colspan() && ++e }) } for (d = 0; d < a.row_count; ++d) e = 0, a.forEachCellInRow(d, function(a, f) { var g = a.colspan(); if (1 < g) { var k = b[d][e].length - n(a, f, c), k = k - (g - 1) * K; if (0 < k) for (var m = Math.floor(k / g), k = k % g, p = 0; p < g; ++p) c[f + p] += m, 0 < k && (c[f + p] += 1, k -= 1) } 1 <= g && e++ }); return c } function q(a, b) { for (var c = m(b, a), d = [], e = 0; e < b.row_count; ++e) { var f = 0, g = a[e], k = []; b.forEachCellInRow(e, function(a, b) { if (1 <= a.colspan()) { var d = g[f], e = n(a, b, c); 1 < a.colspan() && (e += (a.colspan() - 1) * K); ++f; k.push(t(d, e)) } }); d.push(k) } return d } function t(a, b) { if (a.length < b) { for (var c = [], d = a.length; d < b; ++d) c.push(" "); a += c.join("") } return a } function x(a, b, c, d) { if (-1 == a.indexOf(!1)) return b ? 0 == c ? " \\toprule" : c == d ? " \\bottomrule" : " \\midrule" : " \\hline"; c = ""; d = 0; for (var e = !1, f = b ? "\\cmidrule" : "\\cline", g = "", k = 0; k < a.length; ++k) !e && a[k] ? (d = k, e = !0, b && 0 < d && (g += "l")) : e && !a[k] && (b && k < a.length && (g += "r", g = "(" + g + ")"), c += " " + f + g + "{" + (d + 1) + "-" + k + "}", e = !1, g = ""); e && (b && (g = "(" + g + ")"), c += " " + f + g + "{" + (d + 1) + "-" + a.length + "} "); return c } var B = ["\\caption{My caption}", "\\label{my-label}"]; e.prototype = { cellNeedsLeftBorder: function(a, b, c) { return 1 == this.vlines[a][b] && 0 == b && (0 == this.continuous_vlines[b] || c) }, cellNeedsRightBorder: function(a, b, c) { return 0 < this.vlines[a][b + 1] && (0 == this.continuous_vlines[b + 1] || c) }, getColumnsVLines: function() { return this.continuous_vlines.map(function(a) { return 1 == a ? "|" : "" }) } }; b.prototype = { addCellColorCode: function(a, b, c, d) { var e = this.table.getCell(b, c); if (e.isVisible()) { var f = this.fg_colors[b][c]; f && (a = "{\\color" + this.genLaTeXColor(f) + " " + a + "}"); e = 1 < e.rowspan() || 1 < e.colspan(); f = this.table_view.getCellView(b, c, !0).style; f = f.hasBgColor() ? f.getBgColor() : null; c = this.column_colors[c]; b = this.row_colors[b]; f && (f != c && f != b || e) ? a = "\\cellcolor" + this.genLaTeXColor(f) + a : d && (f || c) && (a = "\\cellcolor" + this.genLaTeXColor(f || c) + a); return a } }, genLaTeXColor: function(a) { c(a); a = String(a); "#" == a.substr(0, 1) && (a = a.substr(1).toUpperCase()); return "[HTML]{" + a + "}" }, addColumnColor: function(a, b) { c(0 <= b && b < this.table.col_count); var d = a, e = this.column_colors[b]; e && (d = "\n>{\\columncolor" + this.genLaTeXColor(e) + "}" + a + " "); return d }, addRowColor: function(a, b) { c(0 <= b && b < this.table.row_count); var d = a, e = this.row_colors[b]; e && (d = "\\rowcolor" + this.genLaTeXColor(e) + " " + a); return d }, areColorsUsed: function() { return this.colors_used } }; var v = null, C = null, K = 3; return function(c, f, g, n, m) { f = f || !1; g = g || !1; m = m || []; var p = [], t = !n; n = -1 != m.indexOf(LaTeXExportOptions.SCALE_TABLE); var P = c.model, U = [], K = [], R = a(c); v = new b(c); C = new e(c); for (var la = 0; la < P.row_count; ++la) { var Ha = [], J = [], ja = la == P.row_count - 1; P.forEachCellInRow(la, function(a, b) { c.getCellView(la, b, !0); var d; d = a; var e = la, f = g; if (0 > d.colspan()) d = null; else { var n = d.rowspan(), m = 1 < n, p = !0; if (1 != d.rowspan()) if (p = !1, v.areColorsUsed()) if (1 < d.rowspan()) m = !1; else { var q = c.model.getCell(e, b); q.rowspan() == -d.rowspan() + 1 && (m = p = !0, n = -q.rowspan()); e += d.rowspan(); d = q } else 1 < d.rowspan() ? p = !0 : (q = c.model.getCell(e, b), e += d.rowspan(), d = q); var q = c.getCellView(e, b, !0).style.getHorizontalAlign(), t = ""; p && (t = d.isVisible() ? d.value().toString() : "", t = t.trim(), f && (t = k(t)), -1 != t.indexOf("\n") && (f = q, t = t.split(/\n/g), f = f ? f[0] : "c", t = "\\begin{tabular}[c]{@{}" + f + "@{}}" + t.join("\\\\ ") + "\\end{tabular}"), f = c.getCellView(e, b).style, f.hasFontStyle("bold") && (t = "\\textbf{" + t + "}"), f.hasFontStyle("italic") && (t = "\\textit{" + t + "}")); f = e; p = c.model; if (0 > f || f >= p.row_count || 0 > b || b >= p.col_count) f = !1; else var p = p.getCell(f, b, !0), P = c.getCellView(f, b).style.getHorizontalAlign(), f = 1 < p.colspan() || C.cellNeedsLeftBorder(f, b, !1) || C.cellNeedsRightBorder(f, b, !1) || P != R[b]; t = v.addCellColorCode(t, e, b, f); t.match(/^\s+$/) && (t = "~"); m && (t = "\\multirow{" + n + "}{*}{" + t + "}"); f ? (q = q[0], C.cellNeedsLeftBorder(e, b, !0) && (q = "|" + q), C.cellNeedsRightBorder(e, b, !0) && (q += "|"), t = "\\multicolumn{" + Math.max(1, d.colspan()) + "}{" + q + "}{" + t + "}") : 0 > d.rowspan() && (t = ""); d = t } null != d && Ha.push(d); J.push(c.hasBorder(la, b, "top")); ja && K.push(c.hasBorder(la, b, "bottom")) }); p.push(Ha); var ca = x(J, f, la, P.row_count); U.push(ca); ja && (ca = x(K, f, la + 1, P.row_count), U.push(ca)) } t && (p = q(p, P)); var t = d(c, R, v), aa = []; aa.push("\\begin{table}[h]"); - 1 != m.indexOf(LaTeXExportOptions.CENTERING) && aa.push("\\centering"); - 1 != m.indexOf(LaTeXExportOptions.CAPTION_ABOVE) && (aa = aa.concat(B)); f && (t = "@{}" + t + "@{}"); n && aa.push("\\resizebox{\\textwidth}{!}{%"); aa.push("\\begin{tabular}{" + t + "}"); 0 < U[0].length && aa.push($.trim(U[0])); p.forEach(function(a, b) { var c = a.join(" & "); if (b + 1 < P.row_count || 0 != $.trim(U[b + 1]).length) c += " \\\\"; var d = v.addRowColor("", b); 0 < d.length && aa.push(d); c += U[b + 1]; aa.push(c) }); aa.push("\\end{tabular}"); n && aa.push("}"); - 1 != m.indexOf(LaTeXExportOptions.CAPTION_BELOW) && (aa = aa.concat(B)); aa.push("\\end{table}"); m = aa.join("\n"); p = []; f && p.push("% \\usepackage{booktabs}"); - 1 != m.search("\\multirow") && p.push("% \\usepackage{multirow}"); n && p.push("% \\usepackage{graphicx}"); v.areColorsUsed() && (p.push("% \\usepackage[table,xcdraw]{xcolor}"), p.push('% If you use beamer only pass "xcolor=table" option, i.e. \\documentclass[xcolor=table]{beamer}')); 0 < p.length && (m = "% Please add the following required packages to your document preamble:\n" + p.join("\n") + "\n" + m); return m } }(); var TextExport = function() { function c(a, b, c) { for (var d = c[b], e = 1; e < a.colspan(); ++e) d += c[b + e]; return d += a.colspan() - 1 } function g(a, b, c, f) { for (var g = f[b] + 1, k = [], B = 0; B < g; ++B) { var v = d("", c.length); k.push(v) } a.forEachCellInRow(b, function(v, B) { var A = !1; if (v.isVisible()) A = 1 == v.rowspan(), e(v).forEach(function(a, b) { b >= g || (k[b][B] = a) }); else if (0 < v.colspan() && 0 > v.rowspan()) { for (var y = a.getCell(b, B), E = e(y), N = 0, I = 0; I < -v.rowspan(); ++I) N += f[b - (I + 1)] + 1; for (var Z = Math.min(E.length, N + g), I = N; I < Z; ++I) k[I - N][B] = E[I]; y.rowspan() == -v.rowspan() + 1 && (A = !0) } if (A) { for (I = A = 0; I < v.colspan(); ++I) A += c[B + I]; A += v.colspan() - 1; I = d("-", A).join(""); k[g - 1][B] = I } }); return k } function e(a) { a = a.value().toString(); a = a.replace(/ /ig, " ").replace(/\n$/, ""); var b = []; a.split("\n").forEach(function(a) { b.push(" " + a + " ") }); return b } function b(a) { var b = 0; e(a).forEach(function(a) { b = Math.max(b, wcwidth(a)) }); return b } function d(a, b) { for (var c = [], d = 0; d < b; ++d) c.push(a); return c } function a(a) { for (var e = d(0, a.col_count), f = 0; f < a.row_count; ++f) a.forEachCellInRow(f, function(a, c) { if (1 == a.colspan()) { var d = b(a); e[c] = Math.max(e[c], d) } }); for (f = 0; f < a.row_count; ++f) a.forEachCellInRow(f, function(a, d) { if (!(1 >= a.colspan())) { var f = b(a) - c(a, d, e); if (0 < f) for (var g = Math.floor(f / a.colspan()), f = f % a.colspan(), k = 0; k < a.colspan(); ++k) e[d + k] += g, 0 < f && (e[d + k] += 1, f -= 1) } }); return e } function f(a) { for (var b = [], c = 0; c < a.row_count; ++c) { var d = 0; a.forEachCellInRow(c, function(a) { 1 < a.rowspan() || (d = Math.max(d, e(a).length)) }); b.push(d) } for (c = 0; c < a.row_count; ++c) a.forEachCellInRow(c, function(a) { if (!(1 >= a.rowspan())) { for (var d = e(a).length, f = 0, g = 0; g < a.rowspan(); ++g) f += b[c + g]; f += a.rowspan() - 1; g = d - f; if (0 < g) for (d = Math.floor(g / a.rowspan()), f = g % a.rowspan(), g = 0; g < a.rowspan(); ++g) b[c + g] += d, 0 < f && (b[c + g] += 1, f -= 1) } }); return b } function k(a, b, c) { "left" == c ? (c = wcwidth(a), c < b && (a += d(" ", b - c).join(""))) : "right" == c ? (c = wcwidth(a), c < b && (a = d(" ", b - c).join("") + a)) : "center" == c && (c = wcwidth(a), b -= c, 0 < b && (c = Math.floor(b / 2), a = d(" ", Math.floor(b / 2) + b % 2).join("") + a + d(" ", c).join(""))); return a } return function(b) { var e = b.model, m = a(e), q = f(e), t = [], x = [""]; e.forEachCellInRow(0, function(a, b) { if (!(1 > a.colspan())) { var e = c(a, b, m); x.push(d("-", e).join("")) } }); x.push(""); t.push(x.join("+")); for (var B = 0; B < e.row_count; ++B) { var v = g(e, B, m, q); v.forEach(function(a, d) { var f = [""]; a.forEach(function(a, d) { var g = e.getCell(B, d, !0); if (!(1 > g.colspan())) { var g = c(g, d, m), q = b.getCellView(B, d).style; f.push(k(a, g, q.getHorizontalAlign())) } }); f.push(""); t.push(f.join(d < v.length - 1 ? "|" : "+")) }) } return t.join("\n") } }(); var MarkdownExport = function() { function c(a, b, c) { for (var d = c[b], e = 1; e < a.colspan(); ++e) d += c[b + e]; return d += a.colspan() - 1 } function g(a, b, c, f) { var g = f[b]; 0 == b && ++g; for (var k = [], B = 0; B < g; ++B) { var v = d("", c.length); k.push(v) } a.forEachCellInRow(b, function(v, B) { var A = 0 == b; if (v.isVisible()) e(v).forEach(function(a, b) { b >= g || (k[b][B] = a) }); else if (0 < v.colspan() && 0 > v.rowspan()) { for (var y = a.getCell(b, B), E = e(y), N = 0, y = 0; y < -v.rowspan(); ++y) N += f[b - (y + 1)] + 1; for (var I = Math.min(E.length, N + g), y = N; y < I; ++y) k[y - N][B] = E[y] } if (A) { for (y = A = 0; y < v.colspan(); ++y) A += c[B + y]; A += v.colspan() - 1; A = d("-", A).join(""); k[g - 1][B] = A } }); return k } function e(a) { a = a.value().toString(); a = a.replace(/ /ig, " ").replace(/\n$/, ""); a = a.replace(/\n/g, " "); var b = []; a.split("\n").forEach(function(a) { b.push(" " + a + " ") }); return b } function b(a) { var b = 0; e(a).forEach(function(a) { b = Math.max(b, wcwidth(a)) }); return b } function d(a, b) { for (var c = [], d = 0; d < b; ++d) c.push(a); return c } function a(a) { for (var e = d(0, a.col_count), f = 0; f < a.row_count; ++f) a.forEachCellInRow(f, function(a, c) { if (1 == a.colspan()) { var d = b(a); e[c] = Math.max(e[c], d) } }); for (f = 0; f < a.row_count; ++f) a.forEachCellInRow(f, function(a, d) { if (!(1 >= a.colspan())) { var f = b(a) - c(a, d, e); if (0 < f) for (var g = Math.floor(f / a.colspan()), f = f % a.colspan(), k = 0; k < a.colspan(); ++k) e[d + k] += g, 0 < f && (e[d + k] += 1, f -= 1) } }); for (a = 0; a < e.length; ++a) e[a] = Math.max(e[a], 3); return e } function f(a) { for (var b = [], c = 0; c < a.row_count; ++c) { var d = 0; a.forEachCellInRow(c, function(a) { 1 < a.rowspan() || (d = Math.max(d, e(a).length)) }); b.push(d) } for (c = 0; c < a.row_count; ++c) a.forEachCellInRow(c, function(a) { if (!(1 >= a.rowspan())) { for (var d = e(a).length, f = 0, g = 0; g < a.rowspan(); ++g) f += b[c + g]; f += a.rowspan() - 1; g = d - f; if (0 < g) for (d = Math.floor(g / a.rowspan()), f = g % a.rowspan(), g = 0; g < a.rowspan(); ++g) b[c + g] += d, 0 < f && (b[c + g] += 1, f -= 1) } }); return b } function k(a, b, c, e) { if ("left" == c) { var f = wcwidth(a); f < b && (a += d(" ", b - f).join("")) } else "right" == c ? (f = wcwidth(a), f < b && (a = d(" ", b - f).join("") + a)) : "center" == c && (f = wcwidth(a), b -= f, 0 < b && (f = Math.floor(b / 2), a = d(" ", Math.floor(b / 2) + b % 2).join("") + a + d(" ", f).join(""))); 1 == e && ("right" == c ? a = a.substring(0, a.length - 1) + ":" : "center" == c && (a = ":" + a.substring(1, a.length - 1) + ":")); return a } return function(b, d, e) { for (var q = b.model, t = a(q), x = f(q), B = [], v = 0; v < q.row_count; ++v) g(q, v, t, x).forEach(function(a, f) { var g = [], x = 0 == v && 1 == f; a.forEach(function(a, d) { var f = q.getCell(v, d, !0); if (!(1 > f.colspan())) { var p = c(f, d, t); 1 == e && (p = f.value().toString().length + 1); f = b.getCellView(v, d).style; g.push(k(a, p, f.getHorizontalAlign(), x)) } }); g.push(""); B.push("|" + g.join(d ? "\t|" : "|")) }); return B.join("\n") } }(); var MediaWikiExport = function() { function c(b) { var c = []; b.forEach(function(a, b) { c.push(g(a, b)) }); return '{| class="wikitable"\n' + (0 < c.length ? c.join("\n|-\n") : "") + "\n|}" } function g(b, c, a) { var f = [], g = 0 == c ? "! " : "| "; b.forEach(function(a, b) { a.isVisible() && f.push(g + e(a)) }); return f.join(a ? " || " : "\n") } function e(b) { var c = b.value().toString(), c = c.replace(/ /g, " "), c = $.trim(c), a = []; 1 < b.rowspan() && a.push('rowspan="' + b.rowspan() + '"'); 1 < b.colspan() && a.push('colspan="' + b.colspan() + '"'); b = b.view.style; var e = [], g = b.getHorizontalAlign(); "left" != g && e.push("text-align: " + g + ";"); b.font_style.hasOwnProperty("bold") && b.font_style.bold && e.push("font-weight: bold;"); b.font_style.hasOwnProperty("italic") && b.font_style.italic && e.push("font-style: italic;"); b = e.join(" "); "" != b && a.push('style="' + b + '"'); b = ""; 0 < a.length && (b = a.join(" ") + " | "); return b + c } return function(b) { return c(b.model.rows) } }(); var init_latex_tables_ui = function(c) { function g() { var b = c("#latex_table_style").val(), b = LaTeXExport(d, "booktabs" == b, c("#escape-special-tex-symbols").is(":checked"), c("#compress-tex-whitespace").is(":checked"), a); c("#result-code").text(b); Prism.highlightElement(c("#result-code")[0]) } function e(d) { c("#escape-special-tex-symbols").change(g); c("#compress-tex-whitespace").change(g); c('').appendTo(c("#edited_table_container")).click(g); c("#latex_table_style").selectpicker(); c("#latex_table_style").change(function() { "booktabs" == c(this).val() && (d.forEachCellInRow(0, function(a) { a.style.setBorders("tb") }), d.forEachCellInRow(d.model.row_count - 1, function(a) { a.style.setBorders("b") })); g() }); c("#show_example_btn").click(function() { b(d); g() }); var e = [LaTeXExportOptions.CAPTION_ABOVE, LaTeXExportOptions.CAPTION_BELOW], n = !1; c("#extra-options").selectpicker().change(function() { if (n) return !1; var b = c(this).val() || [], d = b.diff(a); a = b; d = 0 < d.length ? d[0] : null; - 1 != e.indexOf(d) && (b = b.diff(e), b.push(d), n = !0, c(this).selectpicker("val", b), n = !1, c(this).selectpicker("refresh"), a = b); g() }) } function b(a) { a.reset(); var b = a.model; b.setRows([ ["Item", "", ""], ["Animal", "Description", "Price ($)"], ["Gnat", "per gram", "13.65"], ["", "each", "0.01"], ["Gnu", "stuffed", "92.50"], ["Emu", "stuffed", "33.33"], ["Armadillo", "frozen", "8.99"] ]); b.mergeCells(0, 0, 0, 1); a.forEachCellViewInRange(function(a) { a.style.setHorizontalAlign("right") }, 0, 2, 6, 2); a.getCellView(0, 0).style.setHorizontalAlign("center"); a.clearSelection(); a.forEachCellInRow(0, function(a) { a.style.setBorders("t") }); a.forEachCellInRange(1, 0, 1, 1, function(a) { a.style.setBorders("t") }); a.forEachCellInRow(2, function(a) { a.style.setBorders("t") }); a.forEachCellInRow(6, function(a) { a.style.setBorders("b") }) } var d = null, a = []; return function(a, b) { var c = new TableModel; c.insertRow([""]); c.resize(4, 5); d = new TableView(c, "#edited_table_container"); d.setLoadIgnore({ theme: !0, fixed_layout: !0 }); e(d); new MainUI(d); a && Main.init_table_from_json(d, a); b && (c = jQuery.parseJSON(b), d.load(c)); g() } }($); var html_tables_ui = function(c) { function g(b, d, a) { function f() { var a = x.is(":checked"); return HTMLExport(p, t.is(":checked"), a, a ? "" : "\n", q) } function g() { var a = f(); c("#result-code").text(a); 16384 > a.length && Prism.highlightElement(c("#result-code")[0]) } var n = new TableModel; n.insertRow([""]); var p = new TableView(n, b, { column_resize_enabled: !0 }), m = new MainUI(p), q = []; p.on("theme_set", function(a) { null == a ? p.setTheme({ ColorTheme: "Default", BorderTheme: "All borders" }) : m.theme_selector.setTheme(a) }); p.theme || p.setTheme({ ColorTheme: "Default", BorderTheme: "All borders" }); c('').appendTo(c("#edited_table_container")).click(g); b = c("
", { "class": "tab-gen-opt-box" }).appendTo(c("#edited_table_container")); var t = c(''); c("