PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.83
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.83
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 51.1.46 All 39 releases
← All changes | includes/widgets/Data_Table/preview-handler.js +67 -35 51.1.3551.1.83 View file →
@@ -1,36 +1,68 @@
1 -"use strict";
2 -(function ($) {
3 - $(window).on('elementor:init', () => {
4 - elementor.hooks.addAction('panel/open_editor/widget/king-addons-data-table', (panel, model, view) => {
5 - elementor.channels.editor.on('king-addons-data-table-export', () => {
6 -
7 - // Retrieve all table rows
8 - const rows = view.$el.find('.king-addons-data-table .king-addons-table-row');
9 - const data = [];
10 -
11 - // Iterate over each row and collect text from relevant cells
12 - rows.each((_, row) => {
13 - const cols = row.querySelectorAll('.king-addons-table-text');
14 - const rowData = Array.from(cols, col => col.innerText).join(',');
15 - data.push(rowData);
16 - });
17 -
18 - // Construct CSV content from array of rows
19 - const csvContent = data.join('\n');
20 -
21 - // Create a Blob from CSV data and generate a download link
22 - const blob = new Blob([csvContent], { type: 'text/csv' });
23 - const downloadLink = document.createElement('a');
24 - downloadLink.download = 'placeholder.csv';
25 - downloadLink.href = URL.createObjectURL(blob);
26 - downloadLink.style.display = 'none';
27 -
28 - // Append link to DOM, trigger download, and then remove the link
29 - document.body.appendChild(downloadLink);
30 - downloadLink.click();
31 - document.body.removeChild(downloadLink);
32 - URL.revokeObjectURL(downloadLink.href);
33 - });
34 - });
35 - });
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();
36 68 })(jQuery);