|
1 | | -(function($) { |
2 | | - "use strict"; // Start of use strict |
3 | | - |
4 | | - // Smooth scrolling using jQuery easing |
5 | | - $('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function() { |
6 | | - if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) { |
7 | | - var target = $(this.hash); |
8 | | - target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); |
9 | | - if (target.length) { |
10 | | - $('html, body').animate({ |
11 | | - scrollTop: (target.offset().top - 56) |
12 | | - }, 1000, "easeInOutExpo"); |
13 | | - return false; |
14 | | - } |
15 | | - } |
16 | | - }); |
17 | | - |
18 | | - // Closes responsive menu when a scroll trigger link is clicked |
19 | | - $('.js-scroll-trigger').click(function() { |
20 | | - $('.navbar-collapse').collapse('hide'); |
21 | | - }); |
22 | | - |
23 | | - // Activate scrollspy to add active class to navbar items on scroll |
24 | | - $('body').scrollspy({ |
25 | | - target: '#mainNav', |
26 | | - offset: 56 |
27 | | - }); |
28 | | - |
29 | | -})(jQuery); // End of use strict |
30 | | - |
31 | | -function isInViewport(el, partially) { |
32 | | - |
33 | | - if (typeof(partially) === 'undefined') { |
34 | | - var partially = 0; |
35 | | - } |
36 | | - |
37 | | - if (typeof jQuery === "function" && el instanceof jQuery) { |
38 | | - el = el[0]; |
39 | | - } |
40 | | - |
41 | | - var rect = el.getBoundingClientRect(); |
42 | | - var windowHeight = (window.innerHeight || document.documentElement.clientHeight); |
43 | | - var windowWidth = (window.innerWidth || document.documentElement.clientWidth); |
44 | | - |
45 | | - partialCoeff = 1; |
46 | | - |
47 | | - if (partially == 1) { |
48 | | - var vertInView = (rect.top <= windowHeight) && ((rect.top + rect.height) >= 0); |
49 | | - var horInView = (rect.left <= windowWidth) && ((rect.left + rect.width) >= 0); |
50 | | - return (vertInView && horInView); |
51 | | - } else if (partially > 1) |
52 | | - partialCoeff = partially; |
53 | | - |
54 | | - return ((rect.left >= 0) && (rect.top >= 0) && |
55 | | - ((rect.left + rect.width) <= windowWidth) && |
56 | | - ((rect.top + rect.height/partialCoeff) <= windowHeight)); |
57 | | -} |
58 | | - |
59 | | - |
60 | | -function increment(){ |
61 | | - $('.counting').each(function() { |
62 | | - var $this = $(this), |
63 | | - countTo = $this.attr('data-count'); |
64 | | - |
65 | | - $({ countNum: $this.text()}).animate({ |
66 | | - countNum: countTo |
67 | | - }, |
68 | | - { |
69 | | - duration: 1000, |
70 | | - easing:'linear', |
71 | | - step: function() { |
72 | | - $this.text(Math.floor(this.countNum)); |
73 | | - }, |
74 | | - complete: function() { |
75 | | - $this.text(this.countNum); |
76 | | - } |
77 | | - }); |
78 | | - }); |
79 | | -} |
80 | | - |
81 | | - |
82 | | -function drawChart(){ |
83 | | - // create and animate charts only when they become visible |
84 | | - // loop over all html-defined doughnut charts |
85 | | - var charts = document.getElementsByClassName("doughnut"); |
86 | | - for (var i = 0; i < charts.length; i++) { |
87 | | - var canva = document.createElement("canvas"); |
88 | | - var desc = charts[i].getAttribute("desc"); |
89 | | - var inputColor = charts[i].getAttribute("color"); |
90 | | - var inputValue = charts[i].getAttribute("value"); |
91 | | - charts[i].appendChild(canva); |
92 | | - |
93 | | - // set data |
94 | | - data = { |
95 | | - datasets: |
96 | | - [{ |
97 | | - data: [inputValue, 100-inputValue], |
98 | | - backgroundColor: [inputColor,"#FFFFFF00"], |
99 | | - }], |
100 | | - } |
101 | | - |
102 | | - // create chart |
103 | | - var promisedDeliveryChart = new Chart(canva, { |
104 | | - type: 'doughnut', |
105 | | - data: data, |
106 | | - options: { |
107 | | - elements: {arc: {borderWidth: 0}}, |
108 | | - cutoutPercentage: 80, |
109 | | - tooltips: {enabled: false}, |
110 | | - hover: {mode: null}, |
111 | | - responsive: true, |
112 | | - legend: {display: false} |
113 | | - } |
114 | | - }); |
115 | | - |
116 | | - // override chart with percentage value |
117 | | - Chart.plugins.register({ |
118 | | - id: desc, |
119 | | - beforeDraw: function(chart) { |
120 | | - var width = chart.chart.width, |
121 | | - height = chart.chart.height, |
122 | | - ctx = chart.chart.ctx; |
123 | | - ctx.restore(); |
124 | | - var fontSize = (height / 114).toFixed(2); |
125 | | - ctx.font = fontSize + "em sans-serif"; |
126 | | - ctx.textBaseline = "middle"; |
127 | | - var text = chart.data.datasets[0]["data"][0] + "%", |
128 | | - textX = Math.round((width - ctx.measureText(text).width) / 2), |
129 | | - textY = height / 2; |
130 | | - ctx.fillText(text, textX, textY); |
131 | | - ctx.save(); |
132 | | - } |
133 | | - }); |
134 | | - |
135 | | - // append the chart to the DOM |
136 | | - var description = document.createElement("p"); |
137 | | - var spacer = document.createElement("br"); |
138 | | - var h5 = document.createElement("h5"); |
139 | | - description.appendChild(spacer); |
140 | | - description.appendChild(h5); |
141 | | - h5.innerHTML = desc; |
142 | | - charts[i].appendChild(description); |
143 | | - } |
144 | | -} |
145 | | - |
146 | 1 | var recensioniVisible = false; |
147 | | -var testimonianzeVisible = false; |
148 | | -var percorsoVisible = false; |
149 | | -var comparaVisible = false; |
150 | | -var LFStatsChartsVisible = false; |
151 | 2 | var countersVisible = false; |
152 | 3 |
|
153 | 4 | function track_scroll(){ |
154 | 5 | if(isInViewport($('#recensioni'), 1)){ |
155 | 6 | if(recensioniVisible) return; |
156 | 7 | recensioniVisible = true; |
157 | | - umami.track('scroll_recensioni'); |
| 8 | + umami.track('scroll_docker_recensioni'); |
158 | 9 | return; |
159 | 10 | } |
160 | 11 | if(isInViewport($('#counters'), 1)){ |
161 | 12 | if(countersVisible) return; |
162 | 13 | countersVisible = true; |
163 | 14 | increment(); |
164 | | - umami.track('scroll_counters'); |
165 | | - return; |
166 | | - } |
167 | | - if(isInViewport($('#testimonianze'), 1)){ |
168 | | - if(testimonianzeVisible) return; |
169 | | - testimonianzeVisible = true; |
170 | | - umami.track('scroll_testimonianze'); |
171 | | - return; |
172 | | - } |
173 | | - if(isInViewport($('#percorso'), 1)){ |
174 | | - if(percorsoVisible) return; |
175 | | - percorsoVisible = true; |
176 | | - umami.track('scroll_percorso'); |
177 | | - return; |
178 | | - } |
179 | | - if(isInViewport($('#compara'), 1)){ |
180 | | - if(comparaVisible) return; |
181 | | - comparaVisible = true; |
182 | | - umami.track('scroll_compara'); |
| 15 | + umami.track('scroll_docker_counters'); |
183 | 16 | return; |
184 | 17 | } |
185 | 18 | } |
|
0 commit comments