-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCallPhoneAnalytics.js
70 lines (59 loc) · 2.35 KB
/
CallPhoneAnalytics.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
(function (window, $) {
var _getCurrentSelectedText = function () {
if (window.getSelection) {
return window.getSelection().toString();
} else if (window.document.selection) {
return window.document.selection.createRange().text;
}
return "";
};
$(function () {
$(".js-a-call-phone").on("ot.trackCallPhone", function () {
var mouseEnterTimeout = $(this).data("mouseEnterTimeout");
if (mouseEnterTimeout) {
clearTimeout(mouseEnterTimeout);
}
$(this).data("mouseEnterTime", null);
$(this).data("mouseEnterTimeout", null);
var $a = $(this);
var phoneNumber = $a.attr("href").substr(5);
window.yaCounterProxy.reachGoal("CALL_PHONE", phoneNumber);
})
.click(function() {
$(this).trigger("ot.trackCallPhone");
})
.mouseenter(function () {
var $a = $(this);
$a.data("mouseEnterTime", new Date());
var mouseEnterTimeout = setTimeout(function () {
$a.trigger("ot.trackCallPhone");
$a.data("mouseEnterTimeout", null);
$a.data("mouseEnterTime", null);
clearTimeout(mouseEnterTimeout);
}, 3000);
$a.data("mouseEnterTimeout", mouseEnterTimeout);
}).mouseleave(function () {
var mouseEnterTimeout = $(this).data("mouseEnterTimeout");
if (mouseEnterTimeout) {
clearTimeout(mouseEnterTimeout);
}
$(this).data("mouseEnterTime", null);
$(this).data("mouseEnterTimeout", null);
})
.parent().mouseup(function () {
var selectedText = _getCurrentSelectedText();
if (selectedText) {
$(this).find(".js-a-call-phone").each(function (i, a) {
if ($(a).text().indexOf(selectedText) !== -1) {
$(a).trigger("ot.trackCallPhone");
}
});
}
})
});
})(window, jQuery);
(function(window, $) {
$(".js-social-network-link").click(function() {
yaCounterProxy.reachGoal("SOCIAL_NETWORK_NAV", $(this).data("social-network-id"));
});
})(window, jQuery)