Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Commit

Permalink
Create helpers API for callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon Koo committed Mar 18, 2013
1 parent ed6d7e8 commit b968090
Show file tree
Hide file tree
Showing 6 changed files with 304 additions and 63 deletions.
34 changes: 2 additions & 32 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,39 +100,9 @@ <h3>Tour Options</h3>
<!--<script src="js/jquery-1.7.2.js"></script>-->
<!--<script src="js/hopscotch_jquery.js"></script>-->
<script src="js/hopscotch-0.0.5.js"></script>
<script src="js/li_helpers.js"></script>
<script src="js/exampletour.js"></script>
<script src="js/debug.js"></script>
<script>
//hopscotch.clearCookie();
var printLog = function(str) {
var el = document.getElementById('debug-output'),
newEl = document.createElement('p');
if (el) {
newEl.innerHTML = str;
el.appendChild(newEl);
}
else {
console.log(str);
}
},
onStart = function(tourId) {
printLog('global start ' + tourId);
},
onEnd = function(tourId) {
printLog('global end ' + tourId);
},
onNext = function(tourId, stepNum) {
printLog('global next ' + tourId + ' ' + stepNum);
},
onPrev = function(tourId, stepNum) {
printLog('global prev ' + tourId + ' ' + stepNum);
};
hopscotch.listen('start', onStart)
.listen('end', onEnd)
.listen('next', onNext)
.listen('prev', onPrev);

hopscotch.startTour(tour);
</script>
<script src="js/toursetup.js"></script>
</body>
</html>
18 changes: 14 additions & 4 deletions js/exampletour.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,25 @@ var tour = {
title: 'Multi-page test',
content: 'Are you ready? We\'re going to try hopping to another page and then back!!! Where we\'re going, we won\'t need roads... (Please click this link.)',
target: 'secpagelink',
orientation: 'bottom',
showNextButton: false,
orientation: 'right',
yOffset: -20,
onNext: ["goTo", "secondpage.html"],
multipage: true
},
{
title: 'Polar bears',
content: 'We made it!! Polar bears are very interesting creatures.',
target: 'polarbears',
orientation: 'right',
orientation: 'right'
//showPrevButton: false
},
{
title: 'Returning to the first page',
content: 'Time to go back home... Please click this link to return to the first page.',
target: 'firstpagelink',
orientation: 'bottom',
showNextButton: false,
//showNextButton: false,
onNext: ['goTo', 'index.html'],
//showPrevButton: false,
multipage: true // this indicates that next step will be on a different page
},
Expand All @@ -88,6 +90,13 @@ var tour = {
scrollDuration: 500,
cookieName: 'li_hs',
skipIfNoElement: true,
onStart: ['printlog', 'tour-onstart: start'],
onNext: ['printlog', 'clicked next'],
onPrev: ['printlog', 'clicked prev'],
onShow: ['printlog', 'showing'],
onClose: [['printlog', 'clicked close'], ['alert', 'closing the tour']],
onEnd: ['printlog', 'end']
/*
onNext: function(tourId, idx) {
var newLi,
list = document.getElementById('my-list');
Expand Down Expand Up @@ -123,6 +132,7 @@ var tour = {
onClose: function() {
printLog('closing');
}
*/
//i18n: {
////nextBtn: 'Forward',
////prevBtn: 'Backward',
Expand Down
Loading

0 comments on commit b968090

Please # to comment.