PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.86
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.86
51.1.86 51.1.84 51.1.85 51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 51.1.45 All 40 releases
← All changes | includes/widgets/Data_Table/preview-handler.js +68 -0 51.1.2 → 51.1.86 View file →
@@ -1,0 +1,68 @@
1 +"use strict";
2 +(function ($) {
3 + const FLAG = "kingAddonsDataTablePreviewBound";
4 + let activeView = null;
5 +
6 + /**
7 + * Export currently active table as CSV.
8 + *
9 + * @returns {void}
10 + */
11 + const exportActiveTable = () => {
12 + if (!activeView) {
13 + return;
14 + }
15 +
16 + const rows = activeView.$el.find(".king-addons-data-table .king-addons-table-row");
17 + const data = [];
18 +
19 + rows.each((_, row) => {
20 + const cols = row.querySelectorAll(".king-addons-table-text");
21 + const rowData = Array.from(cols, (col) => col.innerText).join(",");
22 + data.push(rowData);
23 + });
24 +
25 + const csvContent = data.join("\n");
26 + const blob = new Blob([csvContent], { type: "text/csv" });
27 + const url = URL.createObjectURL(blob);
28 +
29 + const downloadLink = document.createElement("a");
30 + downloadLink.download = "placeholder.csv";
31 + downloadLink.href = url;
32 + downloadLink.style.display = "none";
33 +
34 + document.body.appendChild(downloadLink);
35 + downloadLink.click();
36 + document.body.removeChild(downloadLink);
37 + URL.revokeObjectURL(url);
38 + };
39 +
40 + /**
41 + * Bind editor listeners once.
42 + *
43 + * @returns {void}
44 + */
45 + const bindOnce = () => {
46 + if (window[FLAG]) {
47 + return;
48 + }
49 + window[FLAG] = true;
50 +
51 + $(window).on("elementor:init", () => {
52 + elementor.channels.editor.off("king-addons-data-table-export.kingAddonsDataTable");
53 + elementor.channels.editor.on(
54 + "king-addons-data-table-export.kingAddonsDataTable",
55 + exportActiveTable
56 + );
57 +
58 + elementor.hooks.addAction(
59 + "panel/open_editor/widget/king-addons-data-table",
60 + (panel, model, view) => {
61 + activeView = view;
62 + }
63 + );
64 + });
65 + };
66 +
67 + bindOnce();
68 +})(jQuery);