PluginProbe ʕ •ᴥ•ʔ
ShareThis Dashboard for Google Analytics / 2.0.3
ShareThis Dashboard for Google Analytics v2.0.3
3.3.2 trunk 1.0.7 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.5 2.3.5 2.3.6 2.3.7 2.3.8 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.0.0 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.3.0 3.3.1
googleanalytics / js / googleanalytics_page.js
googleanalytics / js Last commit date
bootstrap.min.js 9 years ago googleanalytics.js 9 years ago googleanalytics_dashboard.js 9 years ago googleanalytics_page.js 9 years ago
googleanalytics_page.js
147 lines
1 const GA_ACCESS_CODE_MODAL_ID = "ga_access_code_modal";
2 const GA_ACCESS_CODE_TMP_ID = "ga_access_code_tmp";
3 const GA_ACCESS_CODE_ID = "ga_access_code";
4 const GA_FORM_ID = "ga_form";
5
6 (function ($) {
7
8 ga_popup = {
9 url: '',
10 authorize: function (e, url) {
11 e.preventDefault();
12 ga_popup.url = url;
13 $('#' + GA_ACCESS_CODE_MODAL_ID).appendTo("body").modal('show');
14 ga_popup.open();
15 },
16 open: function () {
17 const p_width = Math.round(screen.width / 2);
18 const p_height = Math.round(screen.height / 2);
19 const p_left = Math.round(p_width / 2);
20 const p_top = 300;
21 window.open(ga_popup.url, 'ga_auth_popup', 'width=' + p_width + ',height='
22 + p_height + ',top=' + p_top + ',left=' + p_left);
23 },
24 saveAccessCode: function (e) {
25 e.preventDefault();
26 e.target.disabled = 'disabled';
27 ga_loader.show();
28 const ac_tmp = $('#' + GA_ACCESS_CODE_TMP_ID).val();
29 if (ac_tmp) {
30 $('#' + GA_ACCESS_CODE_ID).val(ac_tmp);
31 $('#' + GA_FORM_ID).submit();
32 }
33 }
34 };
35 ga_events = {
36
37 click: function (selector, callback) {
38 $(selector).live('click', callback);
39 },
40 codeManuallyCallback: function (terms_accepted) {
41 const button_disabled = $('#ga_authorize_with_google_button').attr('disabled');
42 const selector_disabled = $('#ga_account_selector').attr('disabled');
43 if (terms_accepted) {
44 if (button_disabled) {
45 $('#ga_authorize_with_google_button').removeAttr('disabled').next().hide();
46 } else {
47 $('#ga_authorize_with_google_button').attr('disabled',
48 'disabled').next().show();
49 }
50
51 if (selector_disabled) {
52 $('#ga_account_selector').removeAttr('disabled');
53 } else {
54 $('#ga_account_selector').attr('disabled', 'disabled');
55 }
56 }
57
58 $('#ga_manually_wrapper').toggle();
59 },
60 initModalEvents: function () {
61 $('#' + GA_ACCESS_CODE_MODAL_ID).on('shown.bs.modal', function () {
62 $('#' + GA_ACCESS_CODE_TMP_ID).focus();
63 });
64
65 $('#' + GA_ACCESS_CODE_MODAL_ID).on('hide.bs.modal', function () {
66 ga_loader.hide();
67 $('#ga_save_access_code').removeAttr('disabled');
68 });
69 }
70 };
71
72 $(document).ready(function () {
73 ga_events.initModalEvents();
74 });
75
76 const offset = 50;
77 const minWidth = 350;
78 const wrapperSelector = '#ga-stats-container';
79 const chartContainer = 'chart_div';
80
81 ga_charts = {
82
83 init: function (callback) {
84 $(document).ready(function () {
85 google.charts.load('current', {
86 'packages': ['corechart']
87 });
88 ga_loader.show();
89 google.charts.setOnLoadCallback(callback);
90 });
91 },
92 createTooltip: function (day, pageviews) {
93 return '<div style="padding:10px;width:100px;">' + '<strong>' + day
94 + '</strong><br>' + 'Pageviews:<strong> ' + pageviews
95 + '</strong>' + '</div>';
96 },
97 events: function (data) {
98 $(window).on('resize', function () {
99 ga_charts.drawChart(data, ga_tools.recomputeChartWidth(minWidth, offset, wrapperSelector));
100 });
101 },
102 drawChart: function (data, chartWidth) {
103
104 if (typeof chartWidth == 'undefined') {
105 chartWidth = ga_tools.recomputeChartWidth(minWidth, offset, wrapperSelector);
106 }
107
108 const options = {
109 /*title : 'Page Views',*/
110 lineWidth: 5,
111 pointSize: 10,
112 tooltip: {
113 isHtml: true
114 },
115 legend: {
116 position: (ga_tools.getCurrentWidth(wrapperSelector) <= minWidth ? 'top'
117 : 'top'),
118 maxLines: 5,
119 alignment: 'start',
120 textStyle: {color: '#000', fontSize: 12}
121 },
122 colors: ['#4285f4', '#ff9800'],
123 hAxis: {
124 title: 'Day',
125 titleTextStyle: {
126 color: '#333'
127 }
128 },
129 vAxis: {
130 minValue: 0
131 },
132 width: chartWidth,
133 height: 500,
134 chartArea: {
135 top: 50,
136 left: 50,
137 right: 30,
138 bottom: 100
139 },
140 };
141 var chart = new google.visualization.AreaChart(document
142 .getElementById(chartContainer));
143 chart.draw(data, options);
144 }
145 };
146 })(jQuery);
147