forked from tjek/tjek-js-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
paged-publications.html
121 lines (99 loc) · 4.11 KB
/
paged-publications.html
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html>
<html lang="en">
<head>
<title>Paged Publications</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta charset="utf-8">
<link href="sgn-sdk.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="css/spectre.min.css">
<link rel="stylesheet" type="text/css" href="css/spectre-exp.min.css">
<link rel="stylesheet" type="text/css" href="css/spectre-icons.min.css">
<style>
body {
padding: 50px;
}
.sgn__pp {
display: none;
background-color: #fff;
}
.sgn-pp--open {
overflow: hidden;
}
.sgn-pp--open .sgn__pp {
display: block;
}
.publication {
width: 177px;
display: block;
margin: 0 auto 20px;
}
</style>
</head>
<body>
<div class="publications">
<div class="loading"></div>
</div>
<div class="sgn__pp" data-layout-fixed="true">
<div class="verso">
<div class="verso__scroller">
<div class="sgn-pp__pages"></div>
</div>
</div>
<header class="sgn-pp__header sgn__navbar">
<section class="sgn-navbar__section">
<a href="#" class="sgn-pp--close sgn__btn sgn-btn--fab">x</a>
</section>
<section class="sgn-navbar__section"></section>
</header>
<div class="sgn-pp__progress">
<div class="sgn-pp-progress__bar"></div>
</div>
<div class="sgn-pp__progress-label"></div>
<a class="sgn-pp__control" href="#" role="button" data-direction="prev">‹</a>
<a class="sgn-pp__control" href="#" role="button" data-direction="next">›</a>
</div>
<script src="sgn-sdk.js" id="sgn-sdk" data-app-key="00j4o5wpwptl84fuubdig2s6ej5uyna8" data-track-id="00j4o5wpwptl84fuubdig2s6ej5uyna8"></script>
<script>
function fetchPublications (id, callback) {
SGN.CoreKit.request({
url: '/v2/catalogs',
qs: {
dealer_id: id,
order_by: '-publication_date'
}
}, callback);
}
function renderPublications (publications) {
var html = '';
publications.forEach(function (publication) {
html += '<a href="#" class="publication" data-id="' + publication.id + '" onclick="openPublication(event);">';
html += '<img src=' + publication.images.thumb + '/>';
html += '</a>';
});
document.querySelector('.publications').innerHTML = html;
}
function openPublication (e) {
e.preventDefault();
document.querySelector('html').classList.add('sgn-pp--open');
SGN.PagedPublicationKit.initialize({
el: document.querySelector('.sgn__pp'),
id: e.target.parentNode.getAttribute('data-id'),
eventTracker: SGN.config.get('eventTracker')
}, function (err, viewer) {
if (!err) {
viewer.bind('hotspotClicked', function (hotspot) {
alert('Hotspot clicked');
});
viewer.bind('destroyed', function () {
document.querySelector('html').classList.remove('sgn-pp--open');
});
viewer.start();
}
});
}
fetchPublications(SGN.util.getQueryParam('id') || '93f13', function (err, publications) {
if (!err) renderPublications(publications);
});
</script>
</body>
</html>