You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
3.2 KiB
JavaScript
1 line
3.2 KiB
JavaScript
7 months ago
|
"use strict";var WPFormsDashboardWidget=window.WPFormsDashboardWidget||function(s){var e={$widget:s("#wpforms_reports_widget_lite"),$settingsBtn:s("#wpforms-dash-widget-settings-button"),$canvas:s("#wpforms-dash-widget-chart"),$dismissBtn:s(".wpforms-dash-widget-dismiss-chart-upgrade"),$recomBlockDismissBtn:s("#wpforms-dash-widget-dismiss-recommended-plugin-block")},i={instance:null,settings:{type:"line",data:{labels:[],datasets:[{label:wpforms_dashboard_widget.i18n.entries,data:[],backgroundColor:"rgba(255, 129, 0, 0.135)",borderColor:"rgba(211, 126, 71, 1)",borderWidth:2,pointRadius:4,pointBorderWidth:1,pointBackgroundColor:"rgba(255, 255, 255, 1)"}]},options:{scales:{xAxes:[{type:"time",time:{unit:"day"},distribution:"series",ticks:{beginAtZero:!0,source:"labels",padding:10,minRotation:25,maxRotation:25,callback:function(t,e,s){var i=Math.floor(s.length/7);return i<1||(s.length-e-1)%i==0?t:void 0}}}],yAxes:[{ticks:{beginAtZero:!0,maxTicksLimit:6,padding:20,callback:function(t){if(Math.floor(t)===t)return t}}}]},elements:{line:{tension:0}},animation:{duration:0},hover:{animationDuration:0},legend:{display:!1},tooltips:{displayColors:!1},responsiveAnimationDuration:0,maintainAspectRatio:!1}},init:function(){var t;e.$canvas.length&&(t=e.$canvas[0].getContext("2d"),i.instance=new Chart(t,i.settings),i.updateUI())},updateUI:function(){i.updateWithDummyData(),i.instance.data.labels=i.settings.data.labels,i.instance.data.datasets[0].data=i.settings.data.datasets[0].data,i.instance.update()},updateWithDummyData:function(){for(var t,e=moment().endOf("day"),s=1;s<=7;s++)t=e.clone().subtract(s,"days"),i.settings.data.labels.push(t),i.settings.data.datasets[0].data.push({t:t,y:Math.floor(16*Math.random())+5})}},a={init:function(){s(a.ready)},ready:function(){i.init(),a.events(),a.graphSettings()},graphSettings:function(){e.$settingsBtn.on("click",function(){s(this).siblings(".wpforms-dash-widget-settings-menu").toggle()})},events:function(){a.formsListEvents(),a.handleChartClose(),a.handleRecommendedPluginsClose()},formsListEvents:function(){e.$widget.on("click","#wpforms-dash-widget-forms-more",function(){a.toggleCompleteFormsList()})},handleChartClose:function(){e.$dismissBtn.on("click",function(t){t.preventDefault(),a.saveWidgetMeta("hide_graph",1),s(".wpforms-dash-widget.wpforms-lite").addClass("wpforms-dash-widget-no-graph"),s(this).closest(".wpforms-dash-widget-chart-block-container").remove()})},handleRecommendedPluginsClose:function(){e.$recomBlockDismissBtn.on("click",function(){a.dismissRecommendedBlock()})},saveWidgetMeta:function(t,e){t={_wpnonce:wpforms_dashboard_widget.nonce,action:"wpforms_"+wpforms_dashboard_widget.slug+"_save_widget_meta",meta:t,value:e};s.post(ajaxurl,t)},toggleCompleteFormsList:function(){s("#wpforms-dash-widget-forms-list-table .wpforms-dash-widget-forms-list-hidden-el").toggle(),s("#wpforms-dash-widget-forms-more").html(function(t,e){return e===wpforms_dashboard_widget.show_less_html?wpforms_dashboard_widget.show_more_html:wpforms_dashboard_widget.show_less_html})},dismissRecommendedBlock:function(){s(".wpforms-dash-widget-recommended-plugin-block").remove(),a.saveWidgetMeta("hide_recommended_block",1)}};return a}((document,window,jQuery));WPFormsDashboardWidget.init();
|