Skip to content

Commit

Permalink
basic tour implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantsan committed Jul 23, 2023
1 parent e1f84d4 commit d1a8a2e
Show file tree
Hide file tree
Showing 8 changed files with 611 additions and 23 deletions.
File renamed without changes.
476 changes: 476 additions & 0 deletions ckanext/tour/assets/css/vendor/introjs.min.css

Large diffs are not rendered by default.

85 changes: 85 additions & 0 deletions ckanext/tour/assets/js/init-tour.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
this.ckan.module('init-tour', function (jQuery) {
return {
/* An object of module options */
options: {
template: [
'<a id="intro-switch" href="#" class="btn btn-sm question"><i class="fa fa-lg fa-question-circle"></i></a>',
'<i class="icon-question-sign"></i>',
'</i>',
'</a>'
].join('\n')
},

initialize: function () {
intro = introJs();
var introStart = true;
var visited = localStorage.getItem('intro');
introStart = visited ? false : true;
var md = new MobileDetect(window.navigator.userAgent);
var isMobile = md.mobile() ? true : false;

intro.setOptions({
overlayOpacity: 0.7,
nextLabel: ' &rarr; ',
prevLabel: '&larr; ',
skipLabel: this._('Skip'),
doneLabel: this._('Got it!'),
showStepNumbers: false,
exitOnEsc: true, // default
exitOnOverlayClick: true, // default
keyboardNavigation: true, // default
showButtons: true, // default
showBullets: true, // default,
showProgress: false, // default
steps: [
{
element: '.search-input-group',
intro: this._('Here you can search datasets by a keyword.')
},
{
element: '.filters',
intro: this._('Here you can filter datasets.'),
position: 'right'
},
{
element: '.dataset-list',
intro: this._('The matched datasets will list here.'),
position: 'right'
},
{
element: '#intro-switch',
intro: this._('Click this question mark to show this help again.'),
position: 'right'
},
{
title: 'Test!',
intro: '<img src="https://media3.giphy.com/media/xUNd9D6kBtEjkOGgYE/giphy.gif?cid=ecf05e47qlgq80obqtrt4q15om1rhttqgzct3k1ejhau0uu9&ep=v1_gifs_search&rid=giphy.gif&ct=g" /> test me up'
}
]
});

if (isMobile) {
introStart = false;
} else {
this.createMark().appendTo('.breadcrumb .active');
this.mark.on('click', this._onClick);
}

if (introStart) {
localStorage.setItem('intro', 1);
intro.start();
}
},

createMark: function () {
if (!this.mark) {
var element = this.mark = jQuery(this.options.template);
}
return this.mark;
},

_onClick: function (event) {
intro.start();
}
}
});
17 changes: 17 additions & 0 deletions ckanext/tour/assets/js/vendor/intro.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions ckanext/tour/assets/js/vendor/mobile-detect.min.js

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions ckanext/tour/assets/script.js

This file was deleted.

26 changes: 13 additions & 13 deletions ckanext/tour/assets/webassets.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# tour-js:
# filter: rjsmin
# output: ckanext-tour/%(version)s-tour.js
# contents:
# - js/tour.js
# extra:
# preload:
# - base/main
tour-js:
filter: rjsmin
output: ckanext-tour/%(version)s-tour.js
contents:
- js/vendor/intro.min.js
- js/vendor/mobile-detect.min.js
- js/init-tour.js

# tour-css:
# filter: cssrewrite
# output: ckanext-tour/%(version)s-tour.css
# contents:
# - css/tour.css

tour-css:
filter: cssrewrite
output: ckanext-tour/%(version)s-tour.css
contents:
- css/vendor/introjs.min.css
17 changes: 17 additions & 0 deletions ckanext/tour/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% ckan_extends %}

{% block head_extras %}
<span class="hidden" data-module="init-tour"></span>
{% endblock %}

{% block scripts %}
{{ super() }}

{% asset 'tour/tour-js' %}
{% endblock %}

{% block styles %}
{{ super() }}

{% asset 'tour/tour-css' %}
{% endblock %}

0 comments on commit d1a8a2e

Please sign in to comment.