").attr({
"class": "loading-indicator"
}).appendTo(c("body")));
a.css({
left: b.left + "px",
top: b.top + "px"
}).show()
}
var b = this.table_view,
d = this.table;
c("#table_reset").click(function() {
b.reset()
});
c("#table_add_all_borders").click(function(a) {
var c = function(a) {
a.style.setBorders("ltrb")
};
a.ctrlKey ?
b.forEachCellView(c, !0) : b.forEachSelectedCellView(c, null, !0)
});
c("#table_add_vert_borders").click(function() {
b.forEachCell(function(a) {
a.style.setBorders("lr")
})
});
c("#table_add_horizontal_borders").click(function() {
b.forEachCell(function(a) {
a.style.setBorders("tb")
})
});
c("#table_remove_all_borders").click(function(a) {
var c = function(a) {
a.style.setBorders("")
};
a.ctrlKey ? b.forEachCellView(c, !0) : b.forEachSelectedCellView(c, null, !0)
});
var a = null;
c(".table_size_chooser").SizeChooser({
max_cols: 20,
max_rows: 200,
cols: d.col_count,
rows: d.row_count,
onSetSize: function(c, g) {
400 < Math.max(d.col_count * d.row_count, c * g) ? (e(b.dom), window.setTimeout(function() {
d.resize(c, g);
a && a.hide()
}, 100)) : d.resize(c, g)
}
});
c("#table_resize").mouseover(function() {
c(".table_size_chooser").data("SizeChooser").setSize(d.row_count, d.col_count, !0)
});
c("#cell-spacing-panel").CellSpacingPanel({
onChange: function(a, c) {
b.forEachCellView(function(b) {
b.style.setPadding(c, a)
})
}
});
b.on("onload", function() {
var a = b.getCellView(0, 0).style.getPadding(),
d = c("#cell-spacing-panel").data("CellSpacingPanel");
a && d && (void 0 != a.left && d.setHorizontalSpacing(a.left), void 0 != a.top && d.setVerticalSpacing(a.top))
})
};
g.prototype.initColumnMenu = function() {
var e = this.table_view,
b = this.table;
c("#col_insert_left").click(function() {
var a = e.getSelectionBounds();
a && b.insertEmptyColumn(a.left)
});
c("#col_insert_right").click(function() {
var a = e.getSelectionBounds();
a && b.insertEmptyColumn(a.right + 1)
});
c("#col_remove").click(function() {
e.removeSelectedColumns()
});
var d = this;
c("#col_align_left").click(function() {
d.setSelColumnsHAlign("left")
});
c("#col_align_center").click(function() {
d.setSelColumnsHAlign("center")
});
c("#col_align_right").click(function() {
d.setSelColumnsHAlign("right")
})
};
g.prototype.initRowMenu = function() {
var e = this.table_view,
b = this.table;
c("#row_insert_below").click(function() {
var c = e.getSelectionBounds();
c && b.insertEmptyRow(c.bottom + 1)
});
c("#row_insert_above").click(function() {
var c = e.getSelectionBounds();
c && b.insertEmptyRow(c.top)
});
c("#row_remove").click(function() {
var c =
e.getSelectionBounds();
if (c)
for (var a = c.bottom, c = c.top; a >= c; --a) b.removeRow(a)
})
};
g.prototype.initCellMenu = function() {
var e = this.table_view;
c("#cell_merge").click(e.mergeSelectedCells.bind(e));
c("#cell_split").click(e.splitSelectedCell.bind(e))
};
g.prototype.initToolbar = function() {
var e = this.table_view;
c("#table_add_all_borders_btn").click(function(a) {
var b = function(a) {
a.style.setBorders("ltrb")
};
a.ctrlKey ? e.forEachCellView(b, !0) : e.forEachSelectedCellView(b, null, !0)
});
c("#table_remove_all_borders_btn").click(function(a) {
var b =
function(a) {
a.style.setBorders("")
};
a.ctrlKey ? e.forEachCellView(b, !0) : e.forEachSelectedCellView(b, null, !0)
});
c("#table_merge_cells_btn").click(e.mergeSelectedCells.bind(e));
c("#table_split_cells_btn").click(e.splitSelectedCell.bind(e));
c("#edit_grid_btn").click(function() {
e.isBorderEditEnabled() ? (e.enableBorderEdit(!1), c(this).find("i:first").removeClass("grid-edit-on-icon").addClass("grid-edit-off-icon")) : (e.enableBorderEdit(!0), c(this).find("i:first").removeClass("grid-edit-off-icon").addClass("grid-edit-on-icon"))
});
c("#left_align_btn").click(function() {
e.forEachSelectedCellView(function(a) {
a.style.setHorizontalAlign("left")
})
});
c("#right_align_btn").click(function() {
e.forEachSelectedCellView(function(a) {
a.style.setHorizontalAlign("right")
})
});
c("#center_align_btn").click(function() {
e.forEachSelectedCellView(function(a) {
a.style.setHorizontalAlign("center")
})
});
c("#table_bold_font_btn").click(function() {
e.forEachSelectedCellView(function(a) {
a.style.toggleFontStyle("bold")
})
});
c("#table_italic_font_btn").click(function() {
e.forEachSelectedCellView(function(a) {
a.style.toggleFontStyle("italic")
})
});
var b = "#ffffff #ffccc9 #ffce93 #fffc9e #ffffc7 #9aff99 #96fffb #ECF4FF #cbcefb #efefef #fd6864 #fe996b #fffe65 #fcff2f #67fd9a #38fff8 #BBDAFF #9698ed #c0c0c0 #fe0000 #f8a102 #ffcc67 #f8ff00 #34ff34 #68cbd0 #34cdf9 #6665cd #9b9b9b #cb0000 #f56b00 #ffcb2f #ffc702 #32cb00 #00d2cb #3166ff #6434fc #656565 #9a0000 #ce6301 #cd9934 #999903 #009901 #329a9d #3531ff #6200c9 #343434 #680100 #963400 #986536 #646809 #036400 #34696d #00009b #303498 #000000 #330001 #643403 #663234 #343300 #013300 #003532 #010066 #340096".split(" "),
d = c("#fg-color-picker");
d.spectrum({
color: "#000",
showInput: !0,
className: "color-picker",
showInitial: !0,
showPalette: !0,
showSelectionPalette: !0,
maxPaletteSize: 10,
preferredFormat: "hex",
localStorageKey: "tg.spectrum",
change: function(a) {
var b = a.toHexString();
e.forEachSelectedCellView(function(a) {
a.style.setTextColor(b)
})
},
palette: b,
extraReplacerAttr: {
rel: "tooltip",
title: "Set text color of selected cells"
}
});
var a = d.next().find(".sp-dd");
a.after('
');
a.remove();
var f = c("#bg-color-picker");
f.spectrum({
color: "#FFF",
showInput: !0,
className: "color-picker",
showInitial: !0,
showPalette: !0,
showSelectionPalette: !0,
maxPaletteSize: 10,
preferredFormat: "hex",
localStorageKey: "tg.spectrum",
change: function(a) {
var b = a.toHexString();
e.forEachSelectedCellView(function(a) {
a.style.setBgColor(b)
})
},
palette: b,
extraReplacerAttr: {
rel: "tooltip",
title: "Set background color of selected cells"
}
});
c("#color-clear").click(function() {
e.forEachSelectedCellView(function(a) {
a.style.clearBgColor();
a.style.clearTextColor()
})
});
b = f.next().find(".sp-dd");
b.after('
');
b.remove();
var g = !1;
c("#font-family-select").selectpicker();
c("#font-family-select").change(function() {
var a = c(this).val();
!g && 0 < a.length && e.forEachSelectedCellView(function(b) {
b.style.addFontStyle("font-family", a)
})
});
e.on("single_cell_selected", function(a) {
var b = a.view.style,
e = b.font_style["font-family"] || "ff-serif";
g = !0;
c("#font-family-select").selectpicker("val", e);
(e = b.bg_color) ||
(e = a.view.dom.css("background-color"));
e && f.spectrum("set", e);
(b = b.text_color) || (b = a.view.dom.css("color"));
b && d.spectrum("set", b);
g = !1
});
for (var b = "xx-small x-small small medium large x-large xx-large".split(" "), a = [10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 26, 28, 32, 36], n = c("#font-size-select"), p = 0; p < a.length; ++p) n.append(c("
").attr("value", a[p] + "px").addClass("font-size-" + a[p]).text(a[p] + "px"));
n.append(c("
").attr("value", "inherit").text("Default font size"));
for (p = 0; p < b.length; ++p) n.append(c("
").attr("value",
b[p]).addClass("font-size-" + b[p]).text(b[p]));
n.selectpicker();
n.change(function() {
if (!g) {
var a = c(this).val();
e.forEachSelectedCellView(function(b) {
b.style.addFontStyle("font-size", a)
})
}
});
e.on("single_cell_selected", function(a) {
a = a.view.style.font_style["font-size"] || "inherit";
g = !0;
n.selectpicker("val", a);
g = !1
});
this.initThemeSelection()
};
g.prototype.initThemeSelection = function() {
var e = this;
e.theme_selector = {
themes: {},
addTheme: function(b, c) {
this.themes[b + "Theme"] = c;
this.trigger("theme_added", b, c)
},
setTheme: function(b) {
this.themes = b;
this.trigger("theme_set", b)
}
};
c.observable(e.theme_selector);
c("#theme-select").click(function() {
e.showThemeChooser()
})
};
g.prototype.showThemeChooser = function() {
var e = this;
if (!this.theme_chooser) {
var b = c("
").addClass("theme-chooser");
c("
").addClass("close-btn").text("Close [X]").click(function() {
e.table_view.setTheme(e.theme_selector.themes);
b.hide()
}).appendTo(b);
c("
Select table theme ").appendTo(b);
c("
").text("Please, click on your chosen table styles below to compose a final table theme.").appendTo(b);
["Color", "Border", "Alternate Rows/Columns "].forEach(function(a) {
var d = a + "Theme";
c("
").html('
' + a + " Theme").appendTo(b);
var g = c("
").appendTo(b);
c.each(TableThemes[a + "Themes"], function(b, p) {
var m = {};
m[d] = b;
var q = TableThemes.createTheme(m),
t = c("
Company Q1 Q2 Q3 Microsoft 20.3 30.5 23.5 Google 50.2 40.63 45.23 Apple 25.4 30.2 33.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('
Generate').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('
Generate').appendTo(c("#edited_table_container")).click(g);
b = c("
", {
"class": "tab-gen-opt-box"
}).appendTo(c("#edited_table_container"));
var t = c('
');
c("
", {
"class": "checkbox tab-gen-option"
}).text("Do not generate CSS").append(t).appendTo(b);
t.change(g);
var x = c('
');
c("
", {
"class": "checkbox tab-gen-option"
}).text("Compact mode").attr("title", "Useful for embedding tables into e-mails - puts styles inline & joins code into a single line").append(x).appendTo(b);
x.change(g);
c("#show_example_btn").click(function() {
e(p);
g()
});
d && Main.init_table_from_json(p, d);
a && p.load(jQuery.parseJSON(a));
c("#preview-table-btn").click(function() {
var a = f();
g();
var b = window.open("", "Preview", "width=640,height=400,scrollbars=1");
b.document.write("" + a + "");
b.focus()
});
c("#extra-options").selectpicker().change(function() {
q = c(this).val() || [];
g()
});
g()
}
function e(b) {
b.reset();
b.setTheme({
ColorTheme: "Violet",
BorderTheme: "All borders",
"Alternate Rows/Columns Theme": "Alternate rows"
});
var c = b.model;
c.setRows(["Results ".split(" "), "No Competition John Adam Robert Paul".split(" "), "1 Swimming 1:30 2:05 1:15 1:41".split(" "), "2 Running 15:30 14:10 15:45 16:00".split(" "), "3 Shooting 70% 55% 90% 88%".split(" ")]);
c.mergeCells(0, 0, 0, 5);
b.forEachCellViewInRange(function(a) {
a.style.setHorizontalAlign("right")
}, 2, 2, 4, 5);
b.getCellView(0, 0).style.setHorizontalAlign("center")
}
return function(b, c) {
g("#edited_table_container", b, c)
}
}(jQuery);
(function(c, g) {
"function" == typeof define && define.amd ? define(c) : g.rangy = c()
})(function() {
function c(a, b) {
var c = typeof a[b];
return "function" == c || !("object" != c || !a[b]) || "unknown" == c
}
function g(a, b) {
return !("object" != typeof a[b] || !a[b])
}
function e(a, b) {
return "undefined" != typeof a[b]
}
function b(a) {
return function(b, c) {
for (var d = c.length; d--;)
if (!a(b, c[d])) return !1;
return !0
}
}
function d(a) {
return a && C(a, v) && A(a, B)
}
function a(a) {
return g(a, "body") ? a.body : a.getElementsByTagName("body")[0]
}
function f(a) {
g(window,
"console") && c(window.console, "log") && window.console.log(a)
}
function k(a) {
E.initialized = !0;
E.supported = !1;
a = "Rangy is not supported on this page in your browser. Reason: " + a;
E.config.alertOnFail ? window.alert(a) : f(a)
}
function n() {
if (!E.initialized) {
var b, e = !1,
g = !1;
c(document, "createRange") && (b = document.createRange(), C(b, x) && A(b, t) && (e = !0));
if ((b = a(document)) && "body" == b.nodeName.toLowerCase())
if (b && c(b, "createTextRange") && (b = b.createTextRange(), d(b) && (g = !0)), e || g) {
E.initialized = !0;
E.features = {
implementsDomRange: e,
implementsTextRange: g
};
var m, n;
for (n in y)(m = y[n]) instanceof p && m.init(m, E);
g = 0;
for (m = I.length; g < m; ++g) try {
I[g](E)
} catch (q) {
e = "Rangy init listener threw an exception. Continuing. Detail: " + (q.message || q.description || String(q)), f(e)
}
} else k("Neither Range nor TextRange are available");
else k("No body element found")
}
}
function p(a, b, c) {
this.name = a;
this.dependencies = b;
this.supported = this.initialized = !1;
this.initializer = c
}
function m(a, b, c, d) {
a = new p(b, c, function(a) {
if (!a.initialized) {
a.initialized = !0;
try {
d(E, a), a.supported = !0
} catch (c) {
f("Module '" + b + "' failed to load: " + (c.message || c.description || String(c)))
}
}
});
y[b] = a
}
function q() {}
var t = "startContainer startOffset endContainer endOffset collapsed commonAncestorContainer".split(" "),
x = "setStart setStartBefore setStartAfter setEnd setEndBefore setEndAfter collapse selectNode selectNodeContents compareBoundaryPoints deleteContents extractContents cloneContents insertNode surroundContents cloneRange toString detach".split(" "),
B = "boundingHeight boundingLeft boundingTop boundingWidth htmlText text".split(" "),
v = "collapse compareEndPoints duplicate moveToElementText parentElement select setEndPoint getBoundingClientRect".split(" "),
C = b(c),
K = b(g),
A = b(e),
y = {},
E = {
version: "1.3alpha.20140801",
initialized: !1,
supported: !0,
util: {
isHostMethod: c,
isHostObject: g,
isHostProperty: e,
areHostMethods: C,
areHostObjects: K,
areHostProperties: A,
isTextRange: d,
getBody: a
},
features: {},
modules: y,
config: {
alertOnFail: !0,
alertOnWarn: !1,
preferTextRange: !1,
autoInitialize: "undefined" == typeof rangyAutoInitialize ? !0 : rangyAutoInitialize
}
};
E.fail =
k;
E.warn = function(a) {
a = "Rangy warning: " + a;
E.config.alertOnWarn ? window.alert(a) : f(a)
};
({}).hasOwnProperty ? E.util.extend = function(a, b, c) {
var d, e, f;
for (f in b) b.hasOwnProperty(f) && (d = a[f], e = b[f], c && null !== d && "object" == typeof d && null !== e && "object" == typeof e && E.util.extend(d, e, !0), a[f] = e);
b.hasOwnProperty("toString") && (a.toString = b.toString);
return a
} : k("hasOwnProperty not supported");
(function() {
var a = document.createElement("div");
a.appendChild(document.createElement("span"));
var b = [].slice,
c;
try {
1 ==
b.call(a.childNodes, 0)[0].nodeType && (c = function(a) {
return b.call(a, 0)
})
} catch (d) {}
c || (c = function(a) {
for (var b = [], c = 0, d = a.length; c < d; ++c) b[c] = a[c];
return b
});
E.util.toArray = c
})();
var N;
c(document, "addEventListener") ? N = function(a, b, c) {
a.addEventListener(b, c, !1)
} : c(document, "attachEvent") ? N = function(a, b, c) {
a.attachEvent("on" + b, c)
} : k("Document does not have required addEventListener or attachEvent method");
E.util.addListener = N;
var I = [];
E.init = n;
E.addInitListener = function(a) {
E.initialized ? a(E) : I.push(a)
};
var Z = [];
E.addShimListener = function(a) {
Z.push(a)
};
E.shim = E.createMissingNativeApi = function(a) {
a = a || window;
n();
for (var b = 0, c = Z.length; b < c; ++b) Z[b](a)
};
p.prototype = {
init: function() {
for (var a = this.dependencies || [], b = 0, c = a.length, d, e; b < c; ++b) {
e = a[b];
d = y[e];
if (!(d && d instanceof p)) throw Error("required module '" + e + "' not found");
d.init();
if (!d.supported) throw Error("required module '" + e + "' not supported");
}
this.initializer(this)
},
fail: function(a) {
this.initialized = !0;
this.supported = !1;
throw Error("Module '" +
this.name + "' failed to load: " + a);
},
warn: function(a) {
E.warn("Module " + this.name + ": " + a)
},
deprecationNotice: function(a, b) {
E.warn("DEPRECATED: " + a + " in module " + this.name + "is deprecated. Please use " + b + " instead")
},
createError: function(a) {
return Error("Error in Rangy " + this.name + " module: " + a)
}
};
E.createModule = function(a) {
var b, c;
2 == arguments.length ? (b = arguments[1], c = []) : (b = arguments[2], c = arguments[1]);
b = m(!1, a, c, b);
E.initialized && b.init()
};
E.createCoreModule = function(a, b, c) {
m(!0, a, b, c)
};
E.RangePrototype =
q;
E.rangePrototype = new q;
E.selectionPrototype = new function() {};
var G = !1,
K = function(a) {
G || (G = !0, !E.initialized && E.config.autoInitialize && n())
};
if ("undefined" == typeof window) k("No window found");
else if ("undefined" == typeof document) k("No document found");
else return c(document, "addEventListener") && document.addEventListener("DOMContentLoaded", K, !1), N(window, "load", K), E.createCoreModule("DomUtil", [], function(a, b) {
function c(a) {
for (var b = 0; a = a.previousSibling;) ++b;
return b
}
function d(a, b) {
var c = [],
e;
for (e =
a; e; e = e.parentNode) c.push(e);
for (e = b; e; e = e.parentNode)
if (A(c, e)) return e;
return null
}
function e(a, b, c) {
for (b = c ? b : b.parentNode; b;) {
if (b === a) return !0;
b = b.parentNode
}
return !1
}
function f(a, b, c) {
for (c = c ? a : a.parentNode; c;) {
a = c.parentNode;
if (a === b) return c;
c = a
}
return null
}
function g(a) {
a = a.nodeType;
return 3 == a || 4 == a || 8 == a
}
function k(a, b) {
var c = b.nextSibling,
d = b.parentNode;
c ? d.insertBefore(a, c) : d.appendChild(a);
return a
}
function m(a) {
if (9 == a.nodeType) return a;
if ("undefined" != typeof a.ownerDocument) return a.ownerDocument;
if ("undefined" != typeof a.document) return a.document;
if (a.parentNode) return m(a.parentNode);
throw b.createError("getDocument: no document found for node");
}
function n(a) {
a = m(a);
if ("undefined" != typeof a.defaultView) return a.defaultView;
if ("undefined" != typeof a.parentWindow) return a.parentWindow;
throw b.createError("Cannot get a window object for node");
}
function q(a) {
if ("undefined" != typeof a.contentDocument) return a.contentDocument;
if ("undefined" != typeof a.contentWindow) return a.contentWindow.document;
throw b.createError("getIframeDocument: No Document object found for iframe element");
}
function p(a) {
return a && M.isHostMethod(a, "setTimeout") && M.isHostObject(a, "document")
}
function t(a) {
return a ? g(a) ? '"' + a.data + '"' : 1 == a.nodeType ? "<" + a.nodeName + (a.id ? ' id="' + a.id + '"' : "") + ">[index:" + c(a) + ",length:" + a.childNodes.length + "][" + (a.innerHTML || "[innerHTML not supported]").slice(0, 25) + "]" : a.nodeName : "[No node]"
}
function v(a) {
this._next = this.root = a
}
function x(a, b) {
this.node = a;
this.offset = b
}
function w(a) {
this.code =
this[a];
this.codeName = a;
this.message = "DOMException: " + this.codeName
}
var M = a.util;
M.areHostMethods(document, ["createDocumentFragment", "createElement", "createTextNode"]) || b.fail("document missing a Node creation method");
M.isHostMethod(document, "getElementsByTagName") || b.fail("document missing getElementsByTagName method");
var y = document.createElement("div");
M.areHostMethods(y, ["insertBefore", "appendChild", "cloneNode"]) || b.fail("Incomplete Element implementation");
M.isHostProperty(y, "innerHTML") || b.fail("Element is missing innerHTML property");
y = document.createTextNode("test");
M.areHostMethods(y, ["splitText", "deleteData", "insertData", "appendData", "cloneNode"]) || b.fail("Incomplete Text Node implementation");
var A = function(a, b) {
for (var c = a.length; c--;)
if (a[c] === b) return !0;
return !1
},
B = !1;
(function() {
var b = document.createElement("b");
b.innerHTML = "1";
b.innerHTML = "
";
B = !1;
a.features.crashyTextNodes = B
})();
var C;
"undefined" != typeof window.getComputedStyle ? C = function(a, b) {
return n(a).getComputedStyle(a, null)[b]
} : "undefined" != typeof document.documentElement.currentStyle ?
C = function(a, b) {
return a.currentStyle[b]
} : b.fail("No means of obtaining computed style properties found");
v.prototype = {
_current: null,
hasNext: function() {
return !!this._next
},
next: function() {
var a = this._current = this._next,
b;
if (this._current) {
b = a.firstChild;
if (!b)
for (b = null; a !== this.root && !(b = a.nextSibling);) a = a.parentNode;
this._next = b
}
return this._current
},
detach: function() {
this._current = this._next = this.root = null
}
};
x.prototype = {
equals: function(a) {
return !!a && this.node === a.node && this.offset == a.offset
},
inspect: function() {
return "[DomPosition(" + t(this.node) + ":" + this.offset + ")]"
},
toString: function() {
return this.inspect()
}
};
w.prototype = {
INDEX_SIZE_ERR: 1,
HIERARCHY_REQUEST_ERR: 3,
WRONG_DOCUMENT_ERR: 4,
NO_MODIFICATION_ALLOWED_ERR: 7,
NOT_FOUND_ERR: 8,
NOT_SUPPORTED_ERR: 9,
INVALID_STATE_ERR: 11,
INVALID_NODE_TYPE_ERR: 24
};
w.prototype.toString = function() {
return this.message
};
a.dom = {
arrayContains: A,
isHtmlNamespace: function(a) {
var b;
return "undefined" == typeof a.namespaceURI || null === (b = a.namespaceURI) || "http://www.w3.org/1999/xhtml" ==
b
},
parentElement: function(a) {
a = a.parentNode;
return 1 == a.nodeType ? a : null
},
getNodeIndex: c,
getNodeLength: function(a) {
switch (a.nodeType) {
case 7:
case 10:
return 0;
case 3:
case 8:
return a.length;
default:
return a.childNodes.length
}
},
getCommonAncestor: d,
isAncestorOf: e,
isOrIsAncestorOf: function(a, b) {
return e(a, b, !0)
},
getClosestAncestorIn: f,
isCharacterDataNode: g,
isTextOrCommentNode: function(a) {
if (!a) return !1;
a = a.nodeType;
return 3 == a || 8 == a
},
insertAfter: k,
splitDataNode: function(a, b, d) {
var e = a.cloneNode(!1);
e.deleteData(0,
b);
a.deleteData(b, a.length - b);
k(e, a);
if (d)
for (var f = 0, g; g = d[f++];) g.node == a && g.offset > b ? (g.node = e, g.offset -= b) : g.node == a.parentNode && g.offset > c(a) && ++g.offset;
return e
},
getDocument: m,
getWindow: n,
getIframeWindow: function(a) {
if ("undefined" != typeof a.contentWindow) return a.contentWindow;
if ("undefined" != typeof a.contentDocument) return a.contentDocument.defaultView;
throw b.createError("getIframeWindow: No Window object found for iframe element");
},
getIframeDocument: q,
getBody: M.getBody,
isWindow: p,
getContentDocument: function(a,
b, c) {
var d;
a ? M.isHostProperty(a, "nodeType") ? d = 1 == a.nodeType && "iframe" == a.tagName.toLowerCase() ? q(a) : m(a) : p(a) && (d = a.document) : d = document;
if (!d) throw b.createError(c + "(): Parameter must be a Window object or DOM node");
return d
},
getRootContainer: function(a) {
for (var b; b = a.parentNode;) a = b;
return a
},
comparePoints: function(a, e, g, k) {
var m;
if (a == g) return e === k ? 0 : e < k ? -1 : 1;
if (m = f(g, a, !0)) return e <= c(m) ? -1 : 1;
if (m = f(a, g, !0)) return c(m) < k ? -1 : 1;
e = d(a, g);
if (!e) throw Error("comparePoints error: nodes have no common ancestor");
a = a === e ? e : f(a, e, !0);
g = g === e ? e : f(g, e, !0);
if (a === g) throw b.createError("comparePoints got to case 4 and childA and childB are the same!");
for (e = e.firstChild; e;) {
if (e === a) return -1;
if (e === g) return 1;
e = e.nextSibling
}
},
isBrokenNode: function(a) {
return !1
},
inspectNode: t,
getComputedStyleProperty: C,
fragmentFromNodeChildren: function(a) {
for (var b = m(a).createDocumentFragment(), c; c = a.firstChild;) b.appendChild(c);
return b
},
createIterator: function(a) {
return new v(a)
},
DomPosition: x
};
a.DOMException = w
}), E.createCoreModule("DomRange", ["DomUtil"], function(a, b) {
function c(a, b) {
return 3 != a.nodeType && (V(a, b.startContainer) || V(a, b.endContainer))
}
function d(a) {
return a.document || Da(a.startContainer)
}
function e(a) {
return new H(a.parentNode, oa(a))
}
function f(a) {
return new H(a.parentNode, oa(a) + 1)
}
function g(a, b, c) {
var d = 11 == a.nodeType ? a.firstChild : a;
L(b) ? c == b.length ? z.insertAfter(a, b) : b.parentNode.insertBefore(a, 0 == c ? b : Ia(b, c)) : c >= b.childNodes.length ? b.appendChild(a) : b.insertBefore(a, b.childNodes[c]);
return d
}
function k(a, b, c) {
Q(a);
Q(b);
if (d(b) != d(a)) throw new na("WRONG_DOCUMENT_ERR");
var e = O(a.startContainer, a.startOffset, b.endContainer, b.endOffset);
a = O(a.endContainer, a.endOffset, b.startContainer, b.startOffset);
return c ? 0 >= e && 0 <= a : 0 > e && 0 < a
}
function m(a) {
for (var b, c, e = d(a.range).createDocumentFragment(); c = a.next();) {
b = a.isPartiallySelectedSubtree();
c = c.cloneNode(!b);
b && (b = a.getSubtreeIterator(), c.appendChild(m(b)), b.detach());
if (10 == c.nodeType) throw new na("HIERARCHY_REQUEST_ERR");
e.appendChild(c)
}
return e
}
function n(a, b, c) {
var d,
e;
for (c = c || {
stop: !1
}; d = a.next();)
if (a.isPartiallySelectedSubtree())
if (!1 === b(d)) {
c.stop = !0;
break
} else {
if (d = a.getSubtreeIterator(), n(d, b, c), d.detach(), c.stop) break
} else
for (d = z.createIterator(d); e = d.next();)
if (!1 === b(e)) {
c.stop = !0;
return
}
}
function q(a) {
for (var b; a.next();) a.isPartiallySelectedSubtree() ? (b = a.getSubtreeIterator(), q(b), b.detach()) : a.remove()
}
function p(a) {
for (var b, c = d(a.range).createDocumentFragment(), e; b = a.next();) {
a.isPartiallySelectedSubtree() ? (b = b.cloneNode(!1), e = a.getSubtreeIterator(),
b.appendChild(p(e)), e.detach()) : a.remove();
if (10 == b.nodeType) throw new na("HIERARCHY_REQUEST_ERR");
c.appendChild(b)
}
return c
}
function t(a, b, c) {
var d = !(!b || !b.length),
e, f = !!c;
d && (e = new RegExp("^(" + b.join("|") + ")$"));
var g = [];
n(new x(a, !1), function(b) {
if (!d || e.test(b.nodeType))
if (!f || c(b)) {
var h = a.startContainer;
b == h && L(h) && a.startOffset == h.length || (h = a.endContainer, b == h && L(h) && 0 == a.endOffset || g.push(b))
}
});
return g
}
function v(a) {
return "[" + ("undefined" == typeof a.getName ? "Range" : a.getName()) + "(" + z.inspectNode(a.startContainer) +
":" + a.startOffset + ", " + z.inspectNode(a.endContainer) + ":" + a.endOffset + ")]"
}
function x(a, b) {
this.range = a;
this.clonePartiallySelectedTextNodes = b;
if (!a.collapsed) {
this.sc = a.startContainer;
this.so = a.startOffset;
this.ec = a.endContainer;
this.eo = a.endOffset;
var c = a.commonAncestorContainer;
this.sc === this.ec && L(this.sc) ? (this.isSingleCharacterDataNode = !0, this._first = this._last = this._next = this.sc) : (this._first = this._next = this.sc !== c || L(this.sc) ? Aa(this.sc, c, !0) : this.sc.childNodes[this.so], this._last = this.ec !==
c || L(this.ec) ? Aa(this.ec, c, !0) : this.ec.childNodes[this.eo - 1])
}
}
function w(a) {
return function(b, c) {
for (var d, e = c ? b : b.parentNode; e;) {
d = e.nodeType;
if (wa(a, d)) return e;
e = e.parentNode
}
return null
}
}
function M(a, b) {
if (Oa(a, b)) throw new na("INVALID_NODE_TYPE_ERR");
}
function y(a, b) {
if (!wa(b, a.nodeType)) throw new na("INVALID_NODE_TYPE_ERR");
}
function A(a, b) {
if (0 > b || b > (L(a) ? a.length : a.childNodes.length)) throw new na("INDEX_SIZE_ERR");
}
function B(a, b) {
if (u(a, !0) !== u(b, !0)) throw new na("WRONG_DOCUMENT_ERR");
}
function C(a) {
if (ea(a, !0)) throw new na("NO_MODIFICATION_ALLOWED_ERR");
}
function E(a, b) {
if (!a) throw new na(b);
}
function I(a) {
return Ea && z.isBrokenNode(a) || !wa(ua, a.nodeType) && !u(a, !0)
}
function G(a, b) {
return b <= (L(a) ? a.length : a.childNodes.length)
}
function xa(a) {
return !!a.startContainer && !!a.endContainer && !I(a.startContainer) && !I(a.endContainer) && G(a.startContainer, a.startOffset) && G(a.endContainer, a.endOffset)
}
function Q(a) {
if (!xa(a)) throw Error("Range error: Range is no longer valid after DOM mutation (" +
a.inspect() + ")");
}
function F(a, b) {
Q(a);
var c = a.startContainer,
d = a.startOffset,
e = a.endContainer,
f = a.endOffset,
g = c === e;
L(e) && 0 < f && f < e.length && Ia(e, f, b);
L(c) && 0 < d && d < c.length && (c = Ia(c, d, b), g ? (f -= d, e = c) : e == c.parentNode && f >= oa(c) && f++, d = 0);
a.setStartAndEnd(c, d, e, f)
}
function h(a) {
Q(a);
var b = a.commonAncestorContainer.parentNode.cloneNode(!1);
b.appendChild(a.cloneContents());
return b.innerHTML
}
function K(a) {
a.START_TO_START = 0;
a.START_TO_END = 1;
a.END_TO_END = 2;
a.END_TO_START = 3;
a.NODE_BEFORE = 0;
a.NODE_AFTER = 1;
a.NODE_BEFORE_AND_AFTER = 2;
a.NODE_INSIDE = 3
}
function N(a) {
K(a);
K(a.prototype)
}
function Z(a, b) {
return function() {
Q(this);
var c = this.startContainer,
d = this.startOffset,
e = this.commonAncestorContainer,
g = new x(this, !0);
c !== e && (c = Aa(c, e, !0), d = f(c), c = d.node, d = d.offset);
n(g, C);
g.reset();
e = a(g);
g.detach();
b(this, c, d, c, d);
return e
}
}
function ha(b, d) {
function g(a, b) {
return function(c) {
y(c, pa);
y(ga(c), ua);
c = (a ? e : f)(c);
(b ? h : k)(this, c.node, c.offset)
}
}
function h(a, b, c) {
var e = a.endContainer,
f = a.endOffset;
if (b !== a.startContainer ||
c !== a.startOffset) {
if (ga(b) != ga(e) || 1 == O(b, c, e, f)) e = b, f = c;
d(a, b, c, e, f)
}
}
function k(a, b, c) {
var e = a.startContainer,
f = a.startOffset;
if (b !== a.endContainer || c !== a.endOffset) {
if (ga(b) != ga(e) || -1 == O(b, c, e, f)) e = b, f = c;
d(a, e, f, b, c)
}
}
var r = function() {};
r.prototype = a.rangePrototype;
b.prototype = new r;
ma.extend(b.prototype, {
setStart: function(a, b) {
M(a, !0);
A(a, b);
h(this, a, b)
},
setEnd: function(a, b) {
M(a, !0);
A(a, b);
k(this, a, b)
},
setStartAndEnd: function() {
var a = arguments,
b = a[0],
c = a[1],
e = b,
f = c;
switch (a.length) {
case 3:
f =
a[2];
break;
case 4:
e = a[2], f = a[3]
}
d(this, b, c, e, f)
},
setBoundary: function(a, b, c) {
this["set" + (c ? "Start" : "End")](a, b)
},
setStartBefore: g(!0, !0),
setStartAfter: g(!1, !0),
setEndBefore: g(!0, !1),
setEndAfter: g(!1, !1),
collapse: function(a) {
Q(this);
a ? d(this, this.startContainer, this.startOffset, this.startContainer, this.startOffset) : d(this, this.endContainer, this.endOffset, this.endContainer, this.endOffset)
},
selectNodeContents: function(a) {
M(a, !0);
d(this, a, 0, a, ta(a))
},
selectNode: function(a) {
M(a, !1);
y(a, pa);
var b = e(a);
a = f(a);
d(this, b.node, b.offset, a.node, a.offset)
},
extractContents: Z(p, d),
deleteContents: Z(q, d),
canSurroundContents: function() {
Q(this);
C(this.startContainer);
C(this.endContainer);
var a = new x(this, !0),
b = a._first && c(a._first, this) || a._last && c(a._last, this);
a.detach();
return !b
},
splitBoundaries: function() {
F(this)
},
splitBoundariesPreservingPositions: function(a) {
F(this, a)
},
normalizeBoundaries: function() {
Q(this);
var a = this.startContainer,
b = this.startOffset,
c = this.endContainer,
e = this.endOffset,
f = function(a) {
var b =
a.nextSibling;
b && b.nodeType == a.nodeType && (c = a, e = a.length, a.appendData(b.data), b.parentNode.removeChild(b))
},
g = function(d) {
var f = d.previousSibling;
if (f && f.nodeType == d.nodeType) {
a = d;
var g = d.length;
b = f.length;
d.insertData(0, f.data);
f.parentNode.removeChild(f);
a == c ? (e += b, c = a) : c == d.parentNode && (f = oa(d), e == f ? (c = d, e = g) : e > f && e--)
}
},
h = !0;
L(c) ? c.length == e && f(c) : (0 < e && (h = c.childNodes[e - 1]) && L(h) && f(h), h = !this.collapsed);
h ? L(a) ? 0 == b && g(a) : b < a.childNodes.length && (f = a.childNodes[b]) && L(f) && g(f) : (a = c, b = e);
d(this,
a, b, c, e)
},
collapseToPoint: function(a, b) {
M(a, !0);
A(a, b);
this.setStartAndEnd(a, b)
}
});
N(b)
}
function da(a) {
a.collapsed = a.startContainer === a.endContainer && a.startOffset === a.endOffset;
a.commonAncestorContainer = a.collapsed ? a.startContainer : z.getCommonAncestor(a.startContainer, a.endContainer)
}
function ia(a, b, c, d, e) {
a.startContainer = b;
a.startOffset = c;
a.endContainer = d;
a.endOffset = e;
a.document = z.getDocument(b);
da(a)
}
function qa(a) {
this.startContainer = a;
this.startOffset = 0;
this.endContainer = a;
this.endOffset = 0;
this.document = a;
da(this)
}
var z = a.dom,
ma = a.util,
H = z.DomPosition,
na = a.DOMException,
L = z.isCharacterDataNode,
oa = z.getNodeIndex,
V = z.isOrIsAncestorOf,
Da = z.getDocument,
O = z.comparePoints,
Ia = z.splitDataNode,
Aa = z.getClosestAncestorIn,
ta = z.getNodeLength,
wa = z.arrayContains,
ga = z.getRootContainer,
Ea = a.features.crashyTextNodes;
x.prototype = {
_current: null,
_next: null,
_first: null,
_last: null,
isSingleCharacterDataNode: !1,
reset: function() {
this._current = null;
this._next = this._first
},
hasNext: function() {
return !!this._next
},
next: function() {
var a = this._current = this._next;
a && (this._next = a !== this._last ? a.nextSibling : null, L(a) && this.clonePartiallySelectedTextNodes && (a === this.ec && (a = a.cloneNode(!0)).deleteData(this.eo, a.length - this.eo), this._current === this.sc && (a = a.cloneNode(!0)).deleteData(0, this.so)));
return a
},
remove: function() {
var a = this._current,
b, c;
!L(a) || a !== this.sc && a !== this.ec ? a.parentNode && a.parentNode.removeChild(a) : (b = a === this.sc ? this.so : 0, c = a === this.ec ? this.eo : a.length, b != c && a.deleteData(b, c - b))
},
isPartiallySelectedSubtree: function() {
return c(this._current,
this.range)
},
getSubtreeIterator: function() {
var a;
if (this.isSingleCharacterDataNode) a = this.range.cloneRange(), a.collapse(!1);
else {
a = new qa(d(this.range));
var b = this._current,
c = b,
e = 0,
f = b,
g = ta(b);
V(b, this.sc) && (c = this.sc, e = this.so);
V(b, this.ec) && (f = this.ec, g = this.eo);
ia(a, c, e, f, g)
}
return new x(a, this.clonePartiallySelectedTextNodes)
},
detach: function() {
this.range = this._current = this._next = this._first = this._last = this.sc = this.so = this.ec = this.eo = null
}
};
var pa = [1, 3, 4, 5, 7, 8, 10],
ua = [2, 9, 11],
D = [1, 3, 4, 5, 7, 8, 10,
11
],
r = [1, 3, 4, 5, 7, 8],
u = w([9, 11]),
ea = w([5, 6, 10, 12]),
Oa = w([6, 10, 12]),
Pa = document.createElement("style"),
Qa = !1;
try {
Pa.innerHTML = "
x ", Qa = 3 == Pa.firstChild.nodeType
} catch (Fa) {}
a.features.htmlParsingConforms = Qa;
var Na = "startContainer startOffset endContainer endOffset collapsed commonAncestorContainer".split(" ");
ma.extend(a.rangePrototype, {
compareBoundaryPoints: function(a, b) {
Q(this);
B(this.startContainer, b.startContainer);
var c = 3 == a || 0 == a ? "start" : "end",
d = 1 == a || 0 == a ? "start" : "end";
return O(this[c + "Container"],
this[c + "Offset"], b[d + "Container"], b[d + "Offset"])
},
insertNode: function(a) {
Q(this);
y(a, D);
C(this.startContainer);
if (V(a, this.startContainer)) throw new na("HIERARCHY_REQUEST_ERR");
a = g(a, this.startContainer, this.startOffset);
this.setStartBefore(a)
},
cloneContents: function() {
Q(this);
var a, b;
if (this.collapsed) return d(this).createDocumentFragment();
if (this.startContainer === this.endContainer && L(this.startContainer)) return a = this.startContainer.cloneNode(!0), a.data = a.data.slice(this.startOffset, this.endOffset),
b = d(this).createDocumentFragment(), b.appendChild(a), b;
b = new x(this, !0);
a = m(b);
b.detach();
return a
},
canSurroundContents: function() {
Q(this);
C(this.startContainer);
C(this.endContainer);
var a = new x(this, !0),
b = a._first && c(a._first, this) || a._last && c(a._last, this);
a.detach();
return !b
},
surroundContents: function(a) {
y(a, r);
if (!this.canSurroundContents()) throw new na("INVALID_STATE_ERR");
var b = this.extractContents();
if (a.hasChildNodes())
for (; a.lastChild;) a.removeChild(a.lastChild);
g(a, this.startContainer, this.startOffset);
a.appendChild(b);
this.selectNode(a)
},
cloneRange: function() {
Q(this);
for (var a = new qa(d(this)), b = Na.length, c; b--;) c = Na[b], a[c] = this[c];
return a
},
toString: function() {
Q(this);
var a = this.startContainer;
if (a === this.endContainer && L(a)) return 3 == a.nodeType || 4 == a.nodeType ? a.data.slice(this.startOffset, this.endOffset) : "";
var b = [],
a = new x(this, !0);
n(a, function(a) {
3 != a.nodeType && 4 != a.nodeType || b.push(a.data)
});
a.detach();
return b.join("")
},
compareNode: function(a) {
Q(this);
var b = a.parentNode,
c = oa(a);
if (!b) throw new na("NOT_FOUND_ERR");
a = this.comparePoint(b, c);
b = this.comparePoint(b, c + 1);
return 0 > a ? 0 < b ? 2 : 0 : 0 < b ? 1 : 3
},
comparePoint: function(a, b) {
Q(this);
E(a, "HIERARCHY_REQUEST_ERR");
B(a, this.startContainer);
return 0 > O(a, b, this.startContainer, this.startOffset) ? -1 : 0 < O(a, b, this.endContainer, this.endOffset) ? 1 : 0
},
createContextualFragment: Qa ? function(a) {
var b = this.startContainer,
c = Da(b);
if (!b) throw new na("INVALID_STATE_ERR");
var d = null;
1 == b.nodeType ? d = b : L(b) && (d = z.parentElement(b));
d = null === d || "HTML" == d.nodeName && z.isHtmlNamespace(Da(d).documentElement) &&
z.isHtmlNamespace(d) ? c.createElement("body") : d.cloneNode(!1);
d.innerHTML = a;
return z.fragmentFromNodeChildren(d)
} : function(a) {
var b = d(this).createElement("body");
b.innerHTML = a;
return z.fragmentFromNodeChildren(b)
},
toHtml: function() {
return h(this)
},
intersectsNode: function(a, b) {
Q(this);
E(a, "NOT_FOUND_ERR");
if (Da(a) !== d(this)) return !1;
var c = a.parentNode,
e = oa(a);
E(c, "NOT_FOUND_ERR");
var f = O(c, e, this.endContainer, this.endOffset),
c = O(c, e + 1, this.startContainer, this.startOffset);
return b ? 0 >= f && 0 <= c : 0 > f && 0 <
c
},
isPointInRange: function(a, b) {
Q(this);
E(a, "HIERARCHY_REQUEST_ERR");
B(a, this.startContainer);
return 0 <= O(a, b, this.startContainer, this.startOffset) && 0 >= O(a, b, this.endContainer, this.endOffset)
},
intersectsRange: function(a) {
return k(this, a, !1)
},
intersectsOrTouchesRange: function(a) {
return k(this, a, !0)
},
intersection: function(a) {
if (this.intersectsRange(a)) {
var b = O(this.startContainer, this.startOffset, a.startContainer, a.startOffset),
c = O(this.endContainer, this.endOffset, a.endContainer, a.endOffset),
d = this.cloneRange(); - 1 == b && d.setStart(a.startContainer, a.startOffset);
1 == c && d.setEnd(a.endContainer, a.endOffset);
return d
}
return null
},
union: function(a) {
if (this.intersectsOrTouchesRange(a)) {
var b = this.cloneRange(); - 1 == O(a.startContainer, a.startOffset, this.startContainer, this.startOffset) && b.setStart(a.startContainer, a.startOffset);
1 == O(a.endContainer, a.endOffset, this.endContainer, this.endOffset) && b.setEnd(a.endContainer, a.endOffset);
return b
}
throw new na("Ranges do not intersect");
},
containsNode: function(a, b) {
return b ?
this.intersectsNode(a, !1) : 3 == this.compareNode(a)
},
containsNodeContents: function(a) {
return 0 <= this.comparePoint(a, 0) && 0 >= this.comparePoint(a, ta(a))
},
containsRange: function(a) {
var b = this.intersection(a);
return null !== b && a.equals(b)
},
containsNodeText: function(a) {
var b = this.cloneRange();
b.selectNode(a);
var c = b.getNodes([3]);
return 0 < c.length ? (b.setStart(c[0], 0), a = c.pop(), b.setEnd(a, a.length), this.containsRange(b)) : this.containsNodeContents(a)
},
getNodes: function(a, b) {
Q(this);
return t(this, a, b)
},
getDocument: function() {
return d(this)
},
collapseBefore: function(a) {
this.setEndBefore(a);
this.collapse(!1)
},
collapseAfter: function(a) {
this.setStartAfter(a);
this.collapse(!0)
},
getBookmark: function(b) {
var c = d(this),
e = a.createRange(c);
b = b || z.getBody(c);
e.selectNodeContents(b);
var c = this.intersection(e),
f = 0,
g = 0;
c && (e.setEnd(c.startContainer, c.startOffset), f = e.toString().length, g = f + c.toString().length);
return {
start: f,
end: g,
containerNode: b
}
},
moveToBookmark: function(a) {
var b = a.containerNode,
c = 0;
this.setStart(b, 0);
this.collapse(!0);
for (var b = [b],
d, e = !1, f = !1, g, h; !f && (d = b.pop());)
if (3 == d.nodeType) g = c + d.length, !e && a.start >= c && a.start <= g && (this.setStart(d, a.start - c), e = !0), e && a.end >= c && a.end <= g && (this.setEnd(d, a.end - c), f = !0), c = g;
else
for (h = d.childNodes, g = h.length; g--;) b.push(h[g])
},
getName: function() {
return "DomRange"
},
equals: function(a) {
return qa.rangesEqual(this, a)
},
isValid: function() {
return xa(this)
},
inspect: function() {
return v(this)
},
detach: function() {}
});
ha(qa, ia);
ma.extend(qa, {
rangeProperties: Na,
RangeIterator: x,
copyComparisonConstants: N,
createPrototypeRange: ha,
inspect: v,
toHtml: h,
getRangeDocument: d,
rangesEqual: function(a, b) {
return a.startContainer === b.startContainer && a.startOffset === b.startOffset && a.endContainer === b.endContainer && a.endOffset === b.endOffset
}
});
a.DomRange = qa
}), E.createCoreModule("WrappedRange", ["DomRange"], function(a, b) {
var c, d, e = a.dom,
f = a.util,
g = e.DomPosition,
k = a.DomRange,
m = e.getBody,
n = e.getContentDocument,
q = e.isCharacterDataNode;
a.features.implementsDomRange && function() {
function d(a) {
for (var b = q.length, c; b--;) c = q[b],
a[c] = a.nativeRange[c];
a.collapsed = a.startContainer === a.endContainer && a.startOffset === a.endOffset
}
var g, q = k.rangeProperties,
p;
c = function(a) {
if (!a) throw b.createError("WrappedRange: Range must be specified");
this.nativeRange = a;
d(this)
};
k.createPrototypeRange(c, function(a, b, c, d, e) {
var f = a.startContainer !== b || a.startOffset != c,
g = a.endContainer !== d || a.endOffset != e,
k = !a.equals(a.nativeRange);
if (f || g || k) a.setEnd(d, e), a.setStart(b, c)
});
g = c.prototype;
g.selectNode = function(a) {
this.nativeRange.selectNode(a);
d(this)
};
g.cloneContents = function() {
return this.nativeRange.cloneContents()
};
g.surroundContents = function(a) {
this.nativeRange.surroundContents(a);
d(this)
};
g.collapse = function(a) {
this.nativeRange.collapse(a);
d(this)
};
g.cloneRange = function() {
return new c(this.nativeRange.cloneRange())
};
g.refresh = function() {
d(this)
};
g.toString = function() {
return this.nativeRange.toString()
};
var s = document.createTextNode("test");
m(document).appendChild(s);
var t = document.createRange();
t.setStart(s, 0);
t.setEnd(s, 0);
try {
t.setStart(s,
1), g.setStart = function(a, b) {
this.nativeRange.setStart(a, b);
d(this)
}, g.setEnd = function(a, b) {
this.nativeRange.setEnd(a, b);
d(this)
}, p = function(a) {
return function(b) {
this.nativeRange[a](b);
d(this)
}
}
} catch (x) {
g.setStart = function(a, b) {
try {
this.nativeRange.setStart(a, b)
} catch (c) {
this.nativeRange.setEnd(a, b), this.nativeRange.setStart(a, b)
}
d(this)
}, g.setEnd = function(a, b) {
try {
this.nativeRange.setEnd(a, b)
} catch (c) {
this.nativeRange.setStart(a, b), this.nativeRange.setEnd(a, b)
}
d(this)
}, p = function(a, b) {
return function(c) {
try {
this.nativeRange[a](c)
} catch (e) {
this.nativeRange[b](c),
this.nativeRange[a](c)
}
d(this)
}
}
}
g.setStartBefore = p("setStartBefore", "setEndBefore");
g.setStartAfter = p("setStartAfter", "setEndAfter");
g.setEndBefore = p("setEndBefore", "setStartBefore");
g.setEndAfter = p("setEndAfter", "setStartAfter");
g.selectNodeContents = function(a) {
this.setStartAndEnd(a, 0, e.getNodeLength(a))
};
t.selectNodeContents(s);
t.setEnd(s, 3);
p = document.createRange();
p.selectNodeContents(s);
p.setEnd(s, 4);
p.setStart(s, 2); - 1 == t.compareBoundaryPoints(t.START_TO_END, p) && 1 == t.compareBoundaryPoints(t.END_TO_START,
p) ? g.compareBoundaryPoints = function(a, b) {
b = b.nativeRange || b;
a == b.START_TO_END ? a = b.END_TO_START : a == b.END_TO_START && (a = b.START_TO_END);
return this.nativeRange.compareBoundaryPoints(a, b)
} : g.compareBoundaryPoints = function(a, b) {
return this.nativeRange.compareBoundaryPoints(a, b.nativeRange || b)
};
p = document.createElement("div");
p.innerHTML = "123";
var v = p.firstChild,
y = m(document);
y.appendChild(p);
t.setStart(v, 1);
t.setEnd(v, 2);
t.deleteContents();
"13" == v.data && (g.deleteContents = function() {
this.nativeRange.deleteContents();
d(this)
}, g.extractContents = function() {
var a = this.nativeRange.extractContents();
d(this);
return a
});
y.removeChild(p);
y = null;
f.isHostMethod(t, "createContextualFragment") && (g.createContextualFragment = function(a) {
return this.nativeRange.createContextualFragment(a)
});
m(document).removeChild(s);
g.getName = function() {
return "WrappedRange"
};
a.WrappedRange = c;
a.createNativeRange = function(a) {
a = n(a, b, "createNativeRange");
return a.createRange()
}
}();
if (a.features.implementsTextRange) {
var p = function(a, b, c, d, f) {
var k =
a.duplicate();
k.collapse(c);
var m = k.parentElement();
e.isOrIsAncestorOf(b, m) || (m = b);
if (!m.canHaveHTML) return m = new g(m.parentNode, e.getNodeIndex(m)), {
boundaryPosition: m,
nodeInfo: {
nodeIndex: m.offset,
containerElement: m.node
}
};
b = e.getDocument(m).createElement("span");
b.parentNode && b.parentNode.removeChild(b);
var n, p = c ? "StartToStart" : "StartToEnd",
t = f && f.containerElement == m ? f.nodeIndex : 0,
x = m.childNodes.length,
v = x;
for (f = v;;) {
f == x ? m.appendChild(b) : m.insertBefore(b, m.childNodes[f]);
k.moveToElementText(b);
n = k.compareEndPoints(p, a);
if (0 == n || t == v) break;
else if (-1 == n)
if (v == t + 1) break;
else t = f;
else v = v == t + 1 ? t : f;
f = Math.floor((t + v) / 2);
m.removeChild(b)
}
p = b.nextSibling;
if (-1 == n && p && q(p)) {
k.setEndPoint(c ? "EndToStart" : "EndToEnd", a);
if (/[\r\n]/.test(p.data))
for (c = k.duplicate(), d = c.text.replace(/\r\n/g, "\r").length, d = c.moveStart("character", d); - 1 == c.compareEndPoints("StartToEnd", c);) d++, c.moveStart("character", 1);
else d = k.text.length;
c = new g(p, d)
} else a = (d || !c) && b.previousSibling, c = (c = (d || c) && b.nextSibling) && q(c) ?
new g(c, 0) : a && q(a) ? new g(a, a.data.length) : new g(m, e.getNodeIndex(b));
b.parentNode.removeChild(b);
return {
boundaryPosition: c,
nodeInfo: {
nodeIndex: f,
containerElement: m
}
}
},
t = function(a, b) {
var c, d, f = a.offset,
g = e.getDocument(a.node),
k = m(g).createTextRange(),
n = q(a.node);
n ? (c = a.node, d = c.parentNode) : (c = a.node.childNodes, c = f < c.length ? c[f] : null, d = a.node);
g = g.createElement("span");
g.innerHTML = "feff;";
c ? d.insertBefore(g, c) : d.appendChild(g);
k.moveToElementText(g);
k.collapse(!b);
d.removeChild(g);
if (n) k[b ? "moveStart" :
"moveEnd"]("character", f);
return k
};
d = function(a) {
this.textRange = a;
this.refresh()
};
d.prototype = new k(document);
d.prototype.refresh = function() {
var a, b, c;
c = this.textRange;
a = c.parentElement();
var d = c.duplicate();
d.collapse(!0);
b = d.parentElement();
d = c.duplicate();
d.collapse(!1);
c = d.parentElement();
b = b == c ? b : e.getCommonAncestor(b, c);
b = b == a ? b : e.getCommonAncestor(a, b);
a = this.textRange;
0 == a.compareEndPoints("StartToEnd", a) ? b = a = p(this.textRange, b, !0, !0).boundaryPosition : (c = p(this.textRange, b, !0, !1), a = c.boundaryPosition,
b = p(this.textRange, b, !1, !1, c.nodeInfo).boundaryPosition);
this.setStart(a.node, a.offset);
this.setEnd(b.node, b.offset)
};
d.prototype.getName = function() {
return "WrappedTextRange"
};
k.copyComparisonConstants(d);
var x = function(a) {
if (a.collapsed) return t(new g(a.startContainer, a.startOffset), !0);
var b = t(new g(a.startContainer, a.startOffset), !0),
c = t(new g(a.endContainer, a.endOffset), !1);
a = m(k.getRangeDocument(a)).createTextRange();
a.setEndPoint("StartToStart", b);
a.setEndPoint("EndToEnd", c);
return a
};
d.rangeToTextRange =
x;
d.prototype.toTextRange = function() {
return x(this)
};
a.WrappedTextRange = d;
if (!a.features.implementsDomRange || a.config.preferTextRange) {
var v = function() {
return this
}();
"undefined" == typeof v.Range && (v.Range = d);
a.createNativeRange = function(a) {
a = n(a, b, "createNativeRange");
return m(a).createTextRange()
};
a.WrappedRange = d
}
}
a.createRange = function(c) {
c = n(c, b, "createRange");
return new a.WrappedRange(a.createNativeRange(c))
};
a.createRangyRange = function(a) {
a = n(a, b, "createRangyRange");
return new k(a)
};
a.createIframeRange =
function(c) {
b.deprecationNotice("createIframeRange()", "createRange(iframeEl)");
return a.createRange(c)
};
a.createIframeRangyRange = function(c) {
b.deprecationNotice("createIframeRangyRange()", "createRangyRange(iframeEl)");
return a.createRangyRange(c)
};
a.addShimListener(function(b) {
var c = b.document;
"undefined" == typeof c.createRange && (c.createRange = function() {
return a.createRange(c)
});
c = b = null
})
}), E.createCoreModule("WrappedSelection", ["DomRange", "WrappedRange"], function(a, b) {
function c(a) {
return "string" ==
typeof a ? /^backward(s)?$/i.test(a) : !!a
}
function d(a, c) {
if (a) {
if (G.isWindow(a)) return a;
if (a instanceof w) return a.win;
var e = G.getContentDocument(a, b, c);
return G.getWindow(e)
}
return window
}
function e(a) {
return d(a, "getWinSelection").getSelection()
}
function f(a) {
return d(a, "getDocSelection").document.selection
}
function g(a) {
var b = !1;
a.anchorNode && (b = 1 == G.comparePoints(a.anchorNode, a.anchorOffset, a.focusNode, a.focusOffset));
return b
}
function k(a, b, c) {
var d = c ? "end" : "start";
c = c ? "start" : "end";
a.anchorNode =
b[d + "Container"];
a.anchorOffset = b[d + "Offset"];
a.focusNode = b[c + "Container"];
a.focusOffset = b[c + "Offset"]
}
function m(a) {
a.anchorNode = a.focusNode = null;
a.anchorOffset = a.focusOffset = 0;
a.rangeCount = 0;
a.isCollapsed = !0;
a._ranges.length = 0
}
function n(b) {
var c;
b instanceof Q ? (c = a.createNativeRange(b.getDocument()), c.setEnd(b.endContainer, b.endOffset), c.setStart(b.startContainer, b.startOffset)) : b instanceof F ? c = b.nativeRange : ha.implementsDomRange && b instanceof G.getWindow(b.startContainer).Range && (c = b);
return c
}
function p(a) {
var c = a.getNodes(),
d;
a: if (c.length && 1 == c[0].nodeType) {
d = 1;
for (var e = c.length; d < e; ++d)
if (!G.isAncestorOf(c[0], c[d])) {
d = !1;
break a
}
d = !0
} else d = !1;
if (!d) throw b.createError("getSingleElementFromRange: range " + a.inspect() + " did not consist of a single element");
return c[0]
}
function q(a) {
return !!a && "undefined" != typeof a.text
}
function t(a, b) {
var c = new F(b);
a._ranges = [c];
k(a, c, !1);
a.rangeCount = 1;
a.isCollapsed = c.collapsed
}
function v(b) {
b._ranges.length = 0;
if ("None" == b.docSelection.type) m(b);
else {
var c = b.docSelection.createRange();
if (q(c)) t(b, c);
else {
b.rangeCount = c.length;
for (var d, e = da(c.item(0)), f = 0; f < b.rangeCount; ++f) d = a.createRange(e), d.selectNode(c.item(f)), b._ranges.push(d);
b.isCollapsed = 1 == b.rangeCount && b._ranges[0].collapsed;
k(b, b._ranges[b.rangeCount - 1], !1)
}
}
}
function x(a, c) {
for (var d = a.docSelection.createRange(), e = p(c), f = da(d.item(0)), f = ia(f).createControlRange(), g = 0, h = d.length; g < h; ++g) f.add(d.item(g));
try {
f.add(e)
} catch (k) {
throw b.createError("addRange(): Element within the specified Range could not be added to control selection (does it have layout?)");
}
f.select();
v(a)
}
function w(a, b, c) {
this.nativeSelection = a;
this.docSelection = b;
this._ranges = [];
this.win = c;
this.refresh()
}
function y(a) {
a.win = a.anchorNode = a.focusNode = a._ranges = null;
a.rangeCount = a.anchorOffset = a.focusOffset = 0;
a.detached = !0
}
function A(a, b) {
for (var c = ga.length, d, e; c--;)
if (d = ga[c], e = d.selection, "deleteAll" == b) y(e);
else if (d.win == a) return "delete" == b ? (ga.splice(c, 1), !0) : e;
"deleteAll" == b && (ga.length = 0);
return null
}
function B(a, c) {
for (var d = da(c[0].startContainer), d = ia(d).createControlRange(),
e = 0, f, g = c.length; e < g; ++e) {
f = p(c[e]);
try {
d.add(f)
} catch (h) {
throw b.createError("setRanges(): Element within one of the specified Ranges could not be added to control selection (does it have layout?)");
}
}
d.select();
v(a)
}
function C(a, b) {
if (a.win.document != da(b)) throw new h("WRONG_DOCUMENT_ERR");
}
function E(b) {
return function(c, d) {
var e;
this.rangeCount ? (e = this.getRangeAt(0), e["set" + (b ? "Start" : "End")](c, d)) : (e = a.createRange(this.win.document), e.setStartAndEnd(c, d));
this.setSingleRange(e, this.isBackward())
}
}
function I(a) {
var b = [],
c = new Z(a.anchorNode, a.anchorOffset),
d = new Z(a.focusNode, a.focusOffset),
e = "function" == typeof a.getName ? a.getName() : "Selection";
if ("undefined" != typeof a.rangeCount)
for (var f = 0, g = a.rangeCount; f < g; ++f) b[f] = Q.inspect(a.getRangeAt(f));
return "[" + e + "(Ranges: " + b.join(", ") + ")(anchor: " + c.inspect() + ", focus: " + d.inspect() + "]"
}
a.config.checkSelectionRanges = !0;
var G = a.dom,
K = a.util,
N = K.isHostMethod,
Q = a.DomRange,
F = a.WrappedRange,
h = a.DOMException,
Z = G.DomPosition,
La, Ma, ha = a.features,
da = G.getDocument,
ia = G.getBody,
qa = Q.rangesEqual,
z = N(window, "getSelection"),
ma = K.isHostObject(document, "selection");
ha.implementsWinGetSelection = z;
var H = (ha.implementsDocSelection = ma) && (!z || a.config.preferTextRange);
H ? (La = f, a.isSelectionValid = function(a) {
a = d(a, "isSelectionValid").document;
var b = a.selection;
return "None" != b.type || da(b.createRange().parentElement()) == a
}) : z ? (La = e, a.isSelectionValid = function() {
return !0
}) : b.fail("Neither document.selection or window.getSelection() detected.");
a.getNativeSelection = La;
var z =
La(),
na = a.createNativeRange(document),
L = ia(document),
oa = K.areHostProperties(z, ["anchorNode", "focusNode", "anchorOffset", "focusOffset"]);
ha.selectionHasAnchorAndFocus = oa;
var V = N(z, "extend");
ha.selectionHasExtend = V;
var Da = "number" == typeof z.rangeCount;
ha.selectionHasRangeCount = Da;
var O = !1,
Ia = !0,
Aa = V ? function(b, c) {
var d = Q.getRangeDocument(c),
d = a.createRange(d);
d.collapseToPoint(c.endContainer, c.endOffset);
b.addRange(n(d));
b.extend(c.startContainer, c.startOffset)
} : null;
K.areHostMethods(z, ["addRange", "getRangeAt",
"removeAllRanges"
]) && "number" == typeof z.rangeCount && ha.implementsDomRange && function() {
var b = window.getSelection();
if (b) {
for (var c = b.rangeCount, d = 1 < c, e = [], f = g(b), h = 0; h < c; ++h) e[h] = b.getRangeAt(h);
var h = ia(document),
k = h.appendChild(document.createElement("div"));
k.contentEditable = "false";
var m = k.appendChild(document.createTextNode("\u00a0\u00a0\u00a0")),
n = document.createRange();
n.setStart(m, 1);
n.collapse(!0);
b.addRange(n);
Ia = 1 == b.rangeCount;
b.removeAllRanges();
d || ((d = window.navigator.appVersion.match(/Chrome\/(.*?) /)) &&
36 <= parseInt(d[1]) ? O = !1 : (d = n.cloneRange(), n.setStart(m, 0), d.setEnd(m, 3), d.setStart(m, 2), b.addRange(n), b.addRange(d), O = 2 == b.rangeCount));
h.removeChild(k);
b.removeAllRanges();
for (h = 0; h < c; ++h) 0 == h && f ? Aa ? Aa(b, e[h]) : (a.warn("Rangy initialization: original selection was backwards but selection has been restored forwards because the browser does not support Selection.extend"), b.addRange(e[h])) : b.addRange(e[h])
}
}();
ha.selectionSupportsMultipleRanges = O;
ha.collapsedNonEditableSelectionsSupported = Ia;
var ta = !1;
L && N(L, "createControlRange") && (L = L.createControlRange(), K.areHostProperties(L, ["item", "add"]) && (ta = !0));
ha.implementsControlRange = ta;
Ma = oa ? function(a) {
return a.anchorNode === a.focusNode && a.anchorOffset === a.focusOffset
} : function(a) {
return a.rangeCount ? a.getRangeAt(a.rangeCount - 1).collapsed : !1
};
var wa;
N(z, "getRangeAt") ? wa = function(a, b) {
try {
return a.getRangeAt(b)
} catch (c) {
return null
}
} : oa && (wa = function(b) {
var c = da(b.anchorNode),
c = a.createRange(c);
c.setStartAndEnd(b.anchorNode, b.anchorOffset, b.focusNode,
b.focusOffset);
c.collapsed !== this.isCollapsed && c.setStartAndEnd(b.focusNode, b.focusOffset, b.anchorNode, b.anchorOffset);
return c
});
w.prototype = a.selectionPrototype;
var ga = [],
Ea = function(a) {
if (a && a instanceof w) return a.refresh(), a;
a = d(a, "getNativeSelection");
var b = A(a),
c = La(a),
e = ma ? f(a) : null;
b ? (b.nativeSelection = c, b.docSelection = e, b.refresh()) : (b = new w(c, e, a), ga.push({
win: a,
selection: b
}));
return b
};
a.getSelection = Ea;
a.getIframeSelection = function(c) {
b.deprecationNotice("getIframeSelection()", "getSelection(iframeEl)");
return a.getSelection(G.getIframeWindow(c))
};
L = w.prototype;
if (!H && oa && K.areHostMethods(z, ["removeAllRanges", "addRange"])) L.removeAllRanges = function() {
this.nativeSelection.removeAllRanges();
m(this)
}, L.addRange = Da ? function(b, d) {
if (ta && ma && "Control" == this.docSelection.type) x(this, b);
else if (c(d) && V) Aa(this.nativeSelection, b), this.refresh();
else {
var e;
O ? e = this.rangeCount : (this.removeAllRanges(), e = 0);
this.nativeSelection.addRange(n(b).cloneRange());
this.rangeCount = this.nativeSelection.rangeCount;
this.rangeCount ==
e + 1 ? (a.config.checkSelectionRanges && (e = wa(this.nativeSelection, this.rangeCount - 1)) && !qa(e, b) && (b = new F(e)), this._ranges[this.rangeCount - 1] = b, k(this, b, D(this.nativeSelection)), this.isCollapsed = Ma(this)) : this.refresh()
}
} : function(a, b) {
c(b) && V ? Aa(this.nativeSelection, a) : this.nativeSelection.addRange(n(a));
this.refresh()
}, L.setRanges = function(a) {
if (ta && ma && 1 < a.length) B(this, a);
else {
this.removeAllRanges();
for (var b = 0, c = a.length; b < c; ++b) this.addRange(a[b])
}
};
else if (N(z, "empty") && N(na, "select") && ta && H) L.removeAllRanges =
function() {
try {
if (this.docSelection.empty(), "None" != this.docSelection.type) {
var a;
if (this.anchorNode) a = da(this.anchorNode);
else if ("Control" == this.docSelection.type) {
var b = this.docSelection.createRange();
b.length && (a = da(b.item(0)))
}
a && (ia(a).createTextRange().select(), this.docSelection.empty())
}
} catch (c) {}
m(this)
}, L.addRange = function(b) {
"Control" == this.docSelection.type ? x(this, b) : (a.WrappedTextRange.rangeToTextRange(b).select(), this._ranges[0] = b, this.rangeCount = 1, this.isCollapsed = this._ranges[0].collapsed,
k(this, b, !1))
}, L.setRanges = function(a) {
this.removeAllRanges();
var b = a.length;
1 < b ? B(this, a) : b && this.addRange(a[0])
};
else return b.fail("No means of selecting a Range or TextRange was found"), !1;
L.getRangeAt = function(a) {
if (0 > a || a >= this.rangeCount) throw new h("INDEX_SIZE_ERR");
return this._ranges[a].cloneRange()
};
var pa;
if (H) pa = function(b) {
var c;
a.isSelectionValid(b.win) ? c = b.docSelection.createRange() : (c = ia(b.win.document).createTextRange(), c.collapse(!0));
"Control" == b.docSelection.type ? v(b) : q(c) ? t(b,
c) : m(b)
};
else if (N(z, "getRangeAt") && "number" == typeof z.rangeCount) pa = function(b) {
if (ta && ma && "Control" == b.docSelection.type) v(b);
else if (b._ranges.length = b.rangeCount = b.nativeSelection.rangeCount, b.rangeCount) {
for (var c = 0, d = b.rangeCount; c < d; ++c) b._ranges[c] = new a.WrappedRange(b.nativeSelection.getRangeAt(c));
k(b, b._ranges[b.rangeCount - 1], D(b.nativeSelection));
b.isCollapsed = Ma(b)
} else m(b)
};
else if (oa && "boolean" == typeof z.isCollapsed && "boolean" == typeof na.collapsed && ha.implementsDomRange) pa = function(a) {
var b;
b = a.nativeSelection;
b.anchorNode ? (b = wa(b, 0), a._ranges = [b], a.rangeCount = 1, b = a.nativeSelection, a.anchorNode = b.anchorNode, a.anchorOffset = b.anchorOffset, a.focusNode = b.focusNode, a.focusOffset = b.focusOffset, a.isCollapsed = Ma(a)) : m(a)
};
else return b.fail("No means of obtaining a Range or TextRange from the user's selection was found"), !1;
L.refresh = function(a) {
var b = a ? this._ranges.slice(0) : null,
c = this.anchorNode,
d = this.anchorOffset;
pa(this);
if (a) {
a = b.length;
if (a != this._ranges.length || this.anchorNode != c || this.anchorOffset !=
d) return !0;
for (; a--;)
if (!qa(b[a], this._ranges[a])) return !0;
return !1
}
};
var ua = function(a, b) {
var c = a.getAllRanges();
a.removeAllRanges();
for (var d = 0, e = c.length; d < e; ++d) qa(b, c[d]) || a.addRange(c[d]);
a.rangeCount || m(a)
};
L.removeRange = ta && ma ? function(a) {
if ("Control" == this.docSelection.type) {
var b = this.docSelection.createRange();
a = p(a);
for (var c = da(b.item(0)), c = ia(c).createControlRange(), d, e = !1, f = 0, g = b.length; f < g; ++f) d = b.item(f), d !== a || e ? c.add(b.item(f)) : e = !0;
c.select();
v(this)
} else ua(this, a)
} : function(a) {
ua(this,
a)
};
var D;
!H && oa && ha.implementsDomRange ? (D = g, L.isBackward = function() {
return D(this)
}) : D = L.isBackward = function() {
return !1
};
L.isBackwards = L.isBackward;
L.toString = function() {
for (var a = [], b = 0, c = this.rangeCount; b < c; ++b) a[b] = "" + this._ranges[b];
return a.join("")
};
L.collapse = function(b, c) {
C(this, b);
var d = a.createRange(b);
d.collapseToPoint(b, c);
this.setSingleRange(d);
this.isCollapsed = !0
};
L.collapseToStart = function() {
if (this.rangeCount) {
var a = this._ranges[0];
this.collapse(a.startContainer, a.startOffset)
} else throw new h("INVALID_STATE_ERR");
};
L.collapseToEnd = function() {
if (this.rangeCount) {
var a = this._ranges[this.rangeCount - 1];
this.collapse(a.endContainer, a.endOffset)
} else throw new h("INVALID_STATE_ERR");
};
L.selectAllChildren = function(b) {
C(this, b);
var c = a.createRange(b);
c.selectNodeContents(b);
this.setSingleRange(c)
};
L.deleteFromDocument = function() {
if (ta && ma && "Control" == this.docSelection.type) {
for (var a = this.docSelection.createRange(), b; a.length;) b = a.item(0), a.remove(b), b.parentNode.removeChild(b);
this.refresh()
} else if (this.rangeCount &&
(a = this.getAllRanges(), a.length)) {
this.removeAllRanges();
b = 0;
for (var c = a.length; b < c; ++b) a[b].deleteContents();
this.addRange(a[c - 1])
}
};
L.eachRange = function(a, b) {
for (var c = 0, d = this._ranges.length; c < d; ++c)
if (a(this.getRangeAt(c))) return b
};
L.getAllRanges = function() {
var a = [];
this.eachRange(function(b) {
a.push(b)
});
return a
};
L.setSingleRange = function(a, b) {
this.removeAllRanges();
this.addRange(a, b)
};
L.callMethodOnEachRange = function(a, b) {
var c = [];
this.eachRange(function(d) {
c.push(d[a].apply(d, b))
});
return c
};
L.setStart = E(!0);
L.setEnd = E(!1);
a.rangePrototype.select = function(a) {
Ea(this.getDocument()).setSingleRange(this, a)
};
L.changeEachRange = function(a) {
var b = [],
c = this.isBackward();
this.eachRange(function(c) {
a(c);
b.push(c)
});
this.removeAllRanges();
c && 1 == b.length ? this.addRange(b[0], "backward") : this.setRanges(b)
};
L.containsNode = function(a, b) {
return this.eachRange(function(c) {
return c.containsNode(a, b)
}, !0) || !1
};
L.getBookmark = function(a) {
return {
backward: this.isBackward(),
rangeBookmarks: this.callMethodOnEachRange("getBookmark", [a])
}
};
L.moveToBookmark = function(b) {
for (var c = [], d = 0, e, f; e = b.rangeBookmarks[d++];) f = a.createRange(this.win), f.moveToBookmark(e), c.push(f);
b.backward ? this.setSingleRange(c[0], "backward") : this.setRanges(c)
};
L.toHtml = function() {
var a = [];
this.eachRange(function(b) {
a.push(Q.toHtml(b))
});
return a.join("")
};
ha.implementsTextRange && (L.getNativeTextRange = function() {
var c;
if (c = this.docSelection) {
c = c.createRange();
if (q(c)) return c;
throw b.createError("getNativeTextRange: selection is a control selection");
}
if (0 <
this.rangeCount) return a.WrappedTextRange.rangeToTextRange(this.getRangeAt(0));
throw b.createError("getNativeTextRange: selection contains no range");
});
L.getName = function() {
return "WrappedSelection"
};
L.inspect = function() {
return I(this)
};
L.detach = function() {
A(this.win, "delete");
y(this)
};
w.detachAll = function() {
A(null, "deleteAll")
};
w.inspect = I;
w.isDirectionBackward = c;
a.Selection = w;
a.selectionPrototype = L;
a.addShimListener(function(a) {
"undefined" == typeof a.getSelection && (a.getSelection = function() {
return Ea(a)
});
a = null
})
}), E
}, this);