PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 All 140 releases
learnpress / assets / js / dist / admin / pages / statistic.min.js

statistic.min.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.9, at assets/js/dist/admin/pages/statistic.min.js

1 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{var t;(t=jQuery).fn.LP_Chart_Line=function(e,a){return t.each(this,(function(){const r=t(this),n=t("<canvas />");r.html(""),n.appendTo(r),new Chart(n,{type:"line",data:e,options:a})}))},t.fn.LP_Statistic_Users=function(){if(0!==parseInt(t(this).length))return t.each(this,(function(){const e=t(".chart-buttons button").on("click",(function(){const a=t(this),r=a.data("type");let n="",s="";if(e.not(this).not('[data-type="user-custom-time"]').prop("disabled",!1),"user-custom-time"==r){if(n=t('#user-custom-time input[name="from"]').val(),s=t('#user-custom-time input[name="to"]').val(),""==n||""==s)return!1}else a.prop("disabled",!0);const o=t("#learn-press-chart");return o.addClass("loading"),t.ajax({url:"admin-ajax.php",data:{action:"learnpress_load_chart",type:r,range:[n,s]},dataType:"text",success(t){t=LP.parseJSON(t),o.LP_Chart_Line(t,LP_Chart_Config),o.removeClass("loading")}}),!1})),a=t('.chart-buttons #user-custom-time input[type="text"]').on("change",(function(){e.filter('[data-type="user-custom-time"]').prop("disabled",a.filter((function(){return""==this.value})).get().length||!function(){if(new Date(a[0].value)<new Date(a[1].value))return!0}())}))}))},t.fn.LP_Statistic_Courses=function(){if(0!==parseInt(t(this).length))return t.each(this,(function(){var e=t(".chart-buttons button").on("click",(function(){let a=t(this),r=a.data("type"),n="",s="",o=t("#learn-press-chart");if(e.not(this).not('[data-type="course-custom-time"]').prop("disabled",!1),"course-custom-time"==r){if(n=t('#course-custom-time input[name="from"]').val(),s=t('#course-custom-time input[name="to"]').val(),""==n||""==s)return!1}else a.prop("disabled",!0);return o.addClass("loading"),t.ajax({url:"admin-ajax.php",data:{action:"learnpress_load_chart",type:r,range:[n,s]},dataType:"text",success(t){t=LP.parseJSON(t),o.LP_Chart_Line(t,LP_Chart_Config),o.removeClass("loading")}}),!1})),a=t('.chart-buttons #course-custom-time input[type="text"]').on("change",(function(){e.filter('[data-type="course-custom-time"]').prop("disabled",a.filter((function(){return""==this.value})).get().length||!function(){if(new Date(a[0].value)<new Date(a[1].value))return!0}())}))}))},t.fn.LP_Statistic_Orders=function(){if(0!==parseInt(t(this).length)){t(".panel_report_option").hide(),t("#panel_report_sales_by_"+t("#report_sales_by").val()).show(),t("#report_sales_by").on("change",(function(){t(".panel_report_option").hide(),t("#panel_report_sales_by_"+t(this).val()).show(),"date"==t(this).val()&&e()}));var e=function(){let e="",a="",r="",n="date",s=0,o=0;n=t("#report_sales_by").val(),$container=t("#learn-press-chart"),$container.addClass("loading");const i=t(".chart-buttons button:disabled").not('[data-type="order-custom-time"]');if(parseInt(i.length)>0)e=t(i[0]).data("type");else if(e="order-custom-time",a=t('#order-custom-time input[name="from"]').val(),r=t('#order-custom-time input[name="to"]').val(),""==a||""==r)return!1;"course"===n?o=t("#report-by-course-id").val():"category"===n&&(s=t("#report-by-course-category-id").val()),t.ajax({url:"admin-ajax.php",data:{action:"learnpress_load_chart",type:e,range:[a,r],report_sales_by:n,course_id:o,cat_id:s},dataType:"text",success(t){t=LP.parseJSON(t),$container.LP_Chart_Line(t,LP_Chart_Config),$container.removeClass("loading")}})};t("#report-by-course-id").select2({placeholder:"Select a course",minimumInputLength:1,ajax:{url:ajaxurl+"?action=learnpress_search_course",dataType:"json",quietMillis:250,data:(t,e)=>({q:t}),results:(t,e)=>({results:t.items}),cache:!0}}),t("#report-by-course-id").on("change",(function(){e()})),t("#report-by-course-category-id").select2({placeholder:"Select a course",minimumInputLength:1,ajax:{url:ajaxurl+"?action=learnpress_search_course_category",dataType:"json",quietMillis:250,data:(t,e)=>({q:t}),results:(t,e)=>({results:t.items}),cache:!0}}),t("#report-by-course-category-id").on("change",(function(){e()}));var a=t(".chart-buttons button").on("click",(function(){const r=t(this),n=r.data("type");return t("#learn-press-chart"),a.not(this).not('[data-type="order-custom-time"]').prop("disabled",!1),"order-custom-time"!==n&&(r.prop("disabled",!0),t('#order-custom-time input[name="from"]').val(""),t('#order-custom-time input[name="to"]').val("")),e(),!1})),r=t('.chart-buttons #order-custom-time input[type="text"]').on("change",(function(){a.filter('[data-type="order-custom-time"]').prop("disabled",r.filter((function(){return""==this.value})).get().length||!function(){if(new Date(r[0].value)<new Date(r[1].value))return!0}())}))}},t((function(){void 0!==t.fn.datepicker&&t(".date-picker").datepicker({dateFormat:"yy/mm/dd"}),t(".learn-press-statistic-users").LP_Statistic_Users(),t(".learn-press-statistic-courses").LP_Statistic_Courses(),t(".learn-press-statistic-orders").LP_Statistic_Orders()}))})();