This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnucivic_data_hopscotch.js
93 lines (85 loc) · 2.94 KB
/
nucivic_data_hopscotch.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* @file
* JS for hopscotch.
*/
(function ($) {
Drupal.behaviors.nucivicDatahopscotch = {
attach: function (context, settings) {
var tour = {
id: "hello-hopscotch",
onEnd: function() {
setCookie("toured", "toured");
},
onClose: function() {
setCookie("toured", "toured");
},
steps: [
{
title: "Welcome to DKAN",
content: "Click next to take the tour.",
target: document.querySelector(".logo"),
placement: "bottom",
fixedElement: true,
xOffset: "0",
yOffset: "0"
},
{
title: "Search Datasets",
content: "Unlock open data with rich search tools.",
target: "block-dkan-sitewide-dkan-sitewide-search-bar",
multipage: true,
onNext: function () {
window.location = "/dataset"
},
placement: "left"
},
{
title: "Faceted Search",
content: "Dig through large volumes of data with search facets.",
target: document.querySelector(".col-md-3"),
multipage: true,
onNext: function () {
window.location = "/dataset/wisconsin-polling-places"
},
placement: "right"
},
{
title: "Rich Metadata",
content: "DKAN makes it easy to collect and expose metatadata that conforms to a number of open specifications including DCAT and Project Open Data.",
target: document.querySelector(".field-group-table"),
placement: "top"
},
{
title: "Expose Data in Multiple Formats",
content: "Federate data using Project Open Data and CKAN compliant json endpoints and DCAT compatiable RDF endpoints.",
target: document.querySelector(".pane-dkan-sitewide-dkan-sitewide-other-access"),
multipage: true,
onNext: function () {
window.location = $('#data-and-resources li.first a').attr('href')
},
placement: "right"
},
{
title: "Preview Resources",
content: "Unlock data with rich data previews.",
target: document.querySelector(".data-explorer"),
placement: "top"
},
]
};
function setCookie(key, value) {
var expires = new Date();
expires.setTime(expires.getTime() + (1 * 24 * 60 * 60 * 1000));
document.cookie = key + '=' + value + ';path=/' + ';expires=' + expires.toUTCString();
};
function getCookie(key) {
var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
return keyValue ? keyValue[2] : null;
};
// Initialize tour if it's the user's first time
if (!getCookie("toured")) {
hopscotch.startTour(tour);
}
}
}
})(jQuery);