{"version":3,"file":"data_table-X-mD1wrR.js","sources":["../assets/elementor/js/apex-chart/DataTable.js"],"sourcesContent":["// Class specifically for Data table\nexport default class DataTable {\n constructor() {\n this.tableHandlers = {};\n this.init();\n this.observer = {}; // For IntersectionObserver\n }\n\n // Initialize the class by setting up handlers and events\n init() {\n this.setUpTableHandler();\n this.bindEventHandlers();\n }\n\n // Bind event listeners\n bindEventHandlers() {\n jQuery(window).on('elementor/frontend/init', this.handleElementorWidgetInit.bind(this));\n jQuery(window).on('elementor/editor/init', this.handleElementorWidgetInit.bind(this));\n }\n\n\n handleElementorWidgetInit() {\n elementorFrontend.hooks.addAction('frontend/element_ready/widget', ($scope) => {\n const chartElement = $scope.find('.graphina-jquery-data-table');\n if (chartElement.length > 0) {\n this.initializeTables(chartElement);\n }\n });\n }\n\n initializeTables(chartElement) {\n const chartType = chartElement.data('chart_type');\n if (this.tableHandlers[chartType]) {\n this.tableHandlers[chartType](chartElement);\n }\n }\n\n\n\n setUpTableHandler() {\n this.tableHandlers = {\n data_table_lite: (element) => this.observeTableElement(element, 'data_table_lite'),\n };\n }\n\n // Setup IntersectionObserver to call setupTable when the element is in the viewport\n observeTableElement(element, dataTableType) {\n const elementID = element.data('element_id')\n if (gcfe_public_localize.view_port === 'off') {\n if (!this.observer[elementID]) {\n this.observer[elementID] = new IntersectionObserver((entries) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n // Element is in viewport; initialize the chart\n this.setupTable(jQuery(entry.target), dataTableType);\n // Stop observing the element after initializing the chart\n this.observer[elementID].unobserve(entry.target);\n }\n });\n }, { threshold: 0.1 }); // Trigger when at least 10% of the element is visible\n }\n this.observer[elementID].observe(element[0]); // Start observing the chart element\n } else {\n this.setupTable(element, dataTableType);\n }\n }\n\n getDynamicData(settings, extraData, elementId) {\n let post_id = jQuery(`[data-element_id=\"${elementId}\"]`).closest('[data-elementor-id]').data('elementor-id');\n return new Promise((resolve, reject) => {\n jQuery.ajax({\n url: gcfe_public_localize.ajaxurl,\n type: 'POST',\n dataType: 'json',\n data: {\n action : 'get_jquery_datatable_data',\n nonce : gcfe_public_localize.table_nonce,\n chartType : 'data_table_lite',\n post_id : post_id,\n element_id : elementId,\n series_count: 0,\n settings : JSON.stringify(settings),\n selected_field: []\n },\n success: (response) => {\n jQuery('#data_table_lite_loading_' + elementId).hide();\n jQuery('#data_table_lite_no_data_' + elementId).hide();\n resolve(response);\n },\n error: (error) => {\n console.error('AJAX Error:', error);\n reject(new Error('AJAX request failed.'));\n },\n });\n });\n }\n\n async setupTable(element,dataTableType){\n const element_id = element.data('element_id')\n let chart_data = element.data('chart_data')\n const extraData = element.data('extra_data');\n const settings = element.data('settings');\n\n chart_data.fnInitComplete = () => {\n jQuery('.dataTables_scrollBody').css({\n 'overflow': 'hidden',\n 'border': '0'\n });\n jQuery(`#data_table_lite_${element_id} thead th`).addClass('all graphina-datatable-columns')\n\n jQuery(`#data_table_lite_${element_id} tbody td`).addClass('graphina-datatable-tbody-td')\n\n const tableScrollFoot = jQuery('.dataTables_scrollFoot');\n // Enable TFOOT scroll bars\n tableScrollFoot.css('overflow', 'auto');\n\n // Sync TFOOT scrolling with TBODY\n tableScrollFoot.on('scroll', function () {\n jQuery('.dataTables_scrollBody').scrollLeft(jQuery(this).scrollLeft());\n });\n }\n chart_data.rowCallback = function (row, data, index) {\n if (index % 2 === 0) {\n jQuery(row).addClass('odd');\n } else {\n jQuery(row).addClass('even');\n }\n }\n let datatable = jQuery('.data_table_lite_' + element_id).DataTable(chart_data);\n \n if(extraData.is_dynamic_table){\n const dynamicData = await this.getDynamicData(settings, extraData, element_id);\n let dynamicTableData = {}\n if(dynamicData.data.body.length !== 0 && dynamicData.data.header.length !== 0){\n dynamicTableData.data = dynamicData.data.body;\n dynamicTableData.columns = dynamicData.data.header;\n datatable.destroy();\n jQuery('#data_table_lite_loading_' + element_id).hide();\n datatable = jQuery('#data_table_lite_' + element_id).DataTable(dynamicTableData);;\n }else{\n jQuery('#data_table_lite_loading_' + element_id).show();\n }\n }else{\n if(chart_data.columns.length > 0){\n jQuery('#data_table_lite_loading_' + element_id).hide();\n }\n }\n if (extraData.table_footer) {\n jQuery(`#data_table_lite_${element_id}`).append('' + chart_data.columns.map(column => `${column.title}`).join('') + '');\n }\n if (extraData.table_data_direct){\n datatable.destroy()\n jQuery('.data_table_lite_' + element_id).DataTable(chart_data);\n }\n }\n\n}\n// Initialize Data Table\nnew DataTable();\n"],"names":["DataTable","$scope","chartElement","chartType","element","dataTableType","elementID","entries","entry","settings","extraData","elementId","post_id","resolve","reject","response","error","element_id","chart_data","tableScrollFoot","row","data","index","datatable","dynamicData","dynamicTableData","column"],"mappings":"AACe,MAAMA,CAAU,CAC3B,aAAc,CACV,KAAK,cAAgB,CAAE,EACvB,KAAK,KAAM,EACX,KAAK,SAAW,EACxB,CAGI,MAAO,CACH,KAAK,kBAAmB,EACxB,KAAK,kBAAmB,CAChC,CAGI,mBAAoB,CAChB,OAAO,MAAM,EAAE,GAAG,0BAA2B,KAAK,0BAA0B,KAAK,IAAI,CAAC,EACtF,OAAO,MAAM,EAAE,GAAG,wBAAyB,KAAK,0BAA0B,KAAK,IAAI,CAAC,CAC5F,CAGI,2BAA4B,CACxB,kBAAkB,MAAM,UAAU,gCAAkCC,GAAW,CAC3E,MAAMC,EAAeD,EAAO,KAAK,6BAA6B,EAC1DC,EAAa,OAAS,GACtB,KAAK,iBAAiBA,CAAY,CAElD,CAAS,CACT,CAEI,iBAAiBA,EAAc,CAC3B,MAAMC,EAAYD,EAAa,KAAK,YAAY,EAC5C,KAAK,cAAcC,CAAS,GAC5B,KAAK,cAAcA,CAAS,EAAED,CAAY,CAEtD,CAII,mBAAoB,CAChB,KAAK,cAAgB,CACjB,gBAAkBE,GAAY,KAAK,oBAAoBA,EAAS,iBAAiB,CACpF,CACT,CAGI,oBAAoBA,EAASC,EAAe,CACxC,MAAMC,EAAYF,EAAQ,KAAK,YAAY,EACvC,qBAAqB,YAAc,OAC9B,KAAK,SAASE,CAAS,IAC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