setup.js
1.73 KB
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
71
72
73
74
75
76
77
78
/* global Beacon */
jQuery(function ($) {
$(document).on('click', '.box .content', function (e) {
const $box = $(this).closest('.box'),
url = $box.data('url'),
completed = $box.data('completed') === 1;
if (url && url.length > 0 && !completed) {
e.preventDefault();
window.location.href = url;
}
});
$(document).on(
'click',
'a[data-type="article"], a[data-type="overview_article"]',
function (e) {
e.preventDefault();
Beacon('article', $(this).data('helpscout_id'), { type: 'modal' });
}
);
$(document).on('click', 'a[data-type="helpscout_action"]', function (e) {
e.preventDefault();
const action = $(this).data('action');
let keyword, articles;
switch (action) {
case 'open_doc':
keyword = $(this).data('keyword');
if (keyword.length > 0) {
Beacon('navigate', '/docs/search?query=' + keyword);
} else {
Beacon('suggest', []);
Beacon('navigate', '/answers/');
}
Beacon('open');
break;
case 'open_chat':
Beacon('navigate', '/ask/');
Beacon('open');
break;
case 'suggest_articles':
articles = $(this).data('articles').split(',');
Beacon('suggest', articles);
Beacon('navigate', '/answers/');
Beacon('open');
break;
}
});
$(document).on('click', '[data-type="youtube_video"]', function (e) {
e.preventDefault();
const youtubeId = $(this).data('youtube_id'),
src =
'https://www.youtube.com/embed/' +
youtubeId +
'?autoplay=1&controls=1';
$('.video-wrapper .video-iframe').attr('src', src);
$('.video-wrapper').show();
});
$(document).on('click', '.video-wrapper .close', function (e) {
e.preventDefault();
$('.video-wrapper .video-iframe').removeAttr('src');
$('.video-wrapper').hide();
});
});