Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
06
/
wp-content
/
plugins
/
wordpress-popup
/
assets
/
js
:
wp-dashboard.min.js
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
!function(t){"use strict";({$widget:t(".hustle-widget"),activeModuleType:"",activeDisplayType:"total",activeTrackingType:"conversion",activeDaysRange:"7",trackingData:{},totalsData:{},daysLabels:[],theChart:null,init(){this.$widget.find("#hustle-analytics-apply").on("click",(t=>this.trackingAndDaysUpdated(t))),this.$widget.find(".hustle-options-chart .hustle-option").on("click",(t=>this.moduleTypeSelected(t))),this.$widget.find(".hustle-options-embed .hustle-option").on("click",(t=>this.displayTypeSelected(t))),this.setDaysLabels(),this.setModuleType(this.$widget.find(".hustle-options-chart .hustle-option.hustle-active").data("module-type")),this.retrieveData(),this.$widget.find("#hustle-dashboard-widget-reload-cache").on("click",(t=>this.reloadCache(t)))},trackingAndDaysUpdated(t){t.preventDefault();const e=this.activeDaysRange;if(this.activeTrackingType=this.$widget.find("#hustle-analytics-show").val(),this.activeDaysRange=this.$widget.find("#hustle-analytics-data").val(),this.setDaysLabels(),e===this.activeDaysRange)return this.buildChart(),void this.updateTotals();this.retrieveData()},setDaysLabels(){const t=-1*this.activeDaysRange;this.daysLabels=hustleVars.days_labels.slice(t)},retrieveData(e=!1){const a=this,i=this.$widget.data("nonce"),s=this.$widget.find(".hustle-message-empty"),o={_ajax_nonce:i,action:"hustle_get_wp_dashboard_widget_data",days:this.activeDaysRange,delete_cache:e,trackingType:this.activeTrackingType};t.ajax({url:ajaxurl,type:"POST",data:o,success(t){t.success&&t.data?(a.trackingData=t.data.data,a.totalsData=t.data.totals,a.buildChart(),a.updateTotals(),a.showLastUpdated(t.data.last_updated)):s.show()},error(){s.show(),a.showLastUpdated(!1)}})},moduleTypeSelected(e){const a=t(e.currentTarget),i=a.data("moduleType");this.setModuleType(i)&&(this.markButtonAsSelected(a),this.buildChart())},setModuleType(t){const e=this.$widget.find(".hustle-options-embed");if(["slidein","popup","overall"].includes(t))e.hide();else if("social_sharing"===t)e.show(),e.find('[data-display-type="floating"]').show();else{if("embedded"!==t)return!1;e.show(),e.find('[data-display-type="floating"]').hide()}return this.activeModuleType=t,this.buildTrackingActionSelect(),!0},displayTypeSelected(e){if(!["embedded","social_sharing"].includes(this.activeModuleType))return;const a=t(e.currentTarget),i=a.data("displayType");"floating"===i&&"social_sharing"!==this.activeModuleType||(this.markButtonAsSelected(a),this.activeDisplayType=i,this.buildChart())},markButtonAsSelected(t){t.siblings(".hustle-option").removeClass("hustle-active").attr("aria-selected",!1),t.addClass("hustle-active").attr("aria-selected",!0)},buildTrackingActionSelect(){const t=this.$widget.find("#hustle-analytics-show"),e=["popup","slidein","embedded"],a=!hustleVars.active_module_types.some((t=>e.includes(t)));let i="";const s=Object.assign({},hustleVars.tracking_actions);("social_sharing"===this.activeModuleType||a)&&(delete s.cta_conversion,delete s.optin_conversion,"cta_conversion"!==this.activeTrackingType&&"optin_conversion"!==this.activeTrackingType||(this.activeTrackingType="view"));for(const t in s)i+=`<option value="${t}" ${t===this.activeTrackingType?"selected":""}>${s[t]}</option>`;t.html(i)},updateTotals(){const t=this.totalsData,e=t=>`<span class="sui-icon-arrow-${t} sui-sm" aria-hidden="true"></span>`;for(const a in t){const i=this.$widget.find(`.hustle-options-chart .hustle-option[data-module-type="${a}"]`),s=i.find(".hustle-option--value"),o=i.find(".hustle-option--trend"),l=t[a],d=l[this.activeTrackingType].total,n=l[this.activeTrackingType].trend;let r="";o.removeClass("hustle-up"),o.removeClass("hustle-down"),0!==n&&(0<n?(o.addClass("hustle-up"),r+=e("up")):(o.addClass("hustle-down"),r+=e("down"))),s.text(d),r+=n+"%",o.html(r)}},formatDataForChart(){const t=this.trackingData,e=this.activeModuleType,a=this.activeDisplayType,i=this.activeTrackingType,s=this.$widget.find(".hustle-message-empty");let o={},l={},d=e,n=!1;try{if(["popup","slidein","overall"].includes(e)||"total"===a)o=t[d];else{if("floating"===a&&"social_sharing"!==e)throw!1;d=e+"_"+a,o=t[d]}if(void 0===o)throw!1;if(n=0===this.totalsData.overall.view.total&&0===this.totalsData.overall.conversion.total,!o||!Object.keys(o).length)throw!1;if(l=o[i],void 0===l||!Object.keys(l).length)throw!1;l=Object.values(l)}catch(t){n=!0,l=Array(parseInt(this.activeDaysRange)).fill(0)}return n?s.show():s.hide(),l},buildChart(){const t=this.formatDataForChart(),e=[{label:hustleVars.tracking_actions[this.activeTrackingType],data:t,backgroundColor:["transparent"],borderColor:["#0085BA"],borderWidth:2,pointRadius:0,pointHitRadius:20,pointHoverRadius:4,pointHoverBorderColor:"#0085BA",pointHoverBackgroundColor:"#FFFFFF"}];this.theChart&&this.theChart.destroy(),this.createNewChart(e)},showLastUpdated(e){if(t(".hustle-dashboard-widget-loader").hide(),!e||"1 second"===e)return void t(".hustle-dashboard-widget-heading-extra").hide();const a=hustleVars.last_updated_ago.replace("{time}",_.escape(e));t("#hustle-dashboard-widget-last-updated").text(a),t(".hustle-dashboard-widget-heading-extra").show()},reloadCache(e){e.preventDefault(),t(".hustle-dashboard-widget-loader").show(),t("#hustle-dashboard-widget-last-updated").text(hustleVars.loading),t(".hustle-dashboard-widget-heading-extra").show(),this.retrieveData(!0)},createNewChart(t){const e=this.$widget.find("#hustle-analytics-chart"),a=hustleVars.tracking_actions[this.activeTrackingType],i={labels:this.daysLabels,datasets:t},s={responsive:!0,maintainAspectRatio:!1,scales:{y:{grid:{display:!0,color:"#F8F8F8",zeroLineColor:"#F8F8F8",drawBorder:!1},ticks:{color:"#72777C",font:{size:11}}},x:{grid:{display:!1,zeroLineColor:"rgba(0,0,0,0)",drawBorder:!1},ticks:{color:"#72777C",font:{size:11}}}},elements:{line:{tension:0},point:{radius:.5}},plugins:{legend:{display:!1},tooltip:{padding:{x:12,y:8},backgroundColor:"#333333",titleFontColor:"#FFFFFF",titleFontSize:15,titleFontFamily:"Roboto",titleFontStyle:"normal",titleAlign:"left",titleSpacing:0,titleMarginBottom:2,bodyFontColor:"#AAAAAA",bodyFontSize:11,bodyFontFamily:"Roboto",bodyFontStyle:"normal",bodyAlign:"left",cornerRadius:4,displayColors:!1,callbacks:{title(t){return t[0].formattedValue+" "+a},label(t){return t.label}}}}};this.theChart=new Chart(e[0],{type:"line",fill:"start",data:i,options:s})}}).init()}(jQuery);