-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfront-end-extras.js
78 lines (72 loc) · 2.67 KB
/
front-end-extras.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
71
72
73
74
75
76
77
78
"use strict";
function enablePaginationButtons (element) {
if (element.dataset.nextStep) {
jQuery("#adobe-instructions-modal ul.pagination li.next.disabled").removeClass("disabled");
}
else {
jQuery("#adobe-instructions-modal ul.pagination li.next").addClass("disabled");
}
if (element.dataset.prevStep) {
jQuery("#adobe-instructions-modal ul.pagination li.previous.disabled").removeClass("disabled");
}
else {
jQuery("#adobe-instructions-modal ul.pagination li.previous").addClass("disabled");
}
}
function advanceForwards(event = undefined) {
let elem = document.querySelector('[data-current-instruction="true"]');
let nextStepID = elem.dataset.nextStep;
if (nextStepID) {
let nextElem = document.getElementById(nextStepID);
jQuery(elem).hide("fast");
delete elem.dataset.currentInstruction;
jQuery(nextElem).show("slow");
nextElem.dataset.currentInstruction = "true";
//set up the next/prev steps
enablePaginationButtons(nextElem);
}
else{
console.log("no selected page");
}
}
jQuery("#adobe-instructions-modal li.next a").click(advanceForwards);
function advanceBackwards(event = undefined) {
let elem = document.querySelector('[data-current-instruction="true"]');
let previousStepID = elem.dataset.prevStep;
if (previousStepID) {
let prevElem = document.getElementById(previousStepID);
jQuery(elem).hide("fast");
delete elem.dataset.currentInstruction;
jQuery(prevElem).show("slow");
prevElem.dataset.currentInstruction = "true";
//set up the next/prev steps
enablePaginationButtons(prevElem);
}
else{
console.log("no selected page");
}
}
jQuery("#adobe-instructions-modal li.previous a").click(advanceBackwards);
/*
The initial instruction images are transparent 1x1 (43 byte) GIF data-uri images.
This is to lower the page loading time.
We lazy load the correct URLs using an attribute called 'data-src'
*/
function loadInstructionImages() {
if (window.omnibus.frontend.imagesLoaded !== true){
window.omnibus.frontend.imagesLoaded = true;
dataLayer.push({'event': 'instructionModalOpen'});
var imgs = jQuery('#adobe-instructions-modal img');
//change src from the transparent GIF to the actual source on modal open
for (var i = 0; i < imgs.length; i++) {
if (imgs[i].getAttribute('data-src')) {
imgs[i].setAttribute('src', imgs[i].getAttribute('data-src'));
}
}
}
}
jQuery('#adobe-instructions-modal').on('shown.bs.modal', loadInstructionImages);
/*
We need to cleanly
*/
module.exports = {advanceForwards, advanceBackwards, loadInstructionImages, enablePaginationButtons, imagesLoaded:false};