Skip to content

Commit

Permalink
Merge pull request #25 from bmartinelle/master
Browse files Browse the repository at this point in the history
Added optional onClose and onComplete callback functions
  • Loading branch information
tannerlinsley committed Jan 28, 2016
2 parents c92e7dc + bad22da commit 119c9bc
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ var tour = {
dark: false, // Dark mode (Works great with `mask.visible = false`)
disableInteraction: false, // Disable interaction with the highlighted elements
highlightMargin: 0, // Margin of the highglighted area
disableEscExit: false // Disable end of tour when pressing ESC
disableEscExit: false // Disable end of tour when pressing ESC,
onClose: function() {} //Function called when the tour is closed
onComplete: function() {} //Function called when the tour is completed
},
steps: []
}
Expand Down
16 changes: 12 additions & 4 deletions dist/nz-tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@
.then(function() {
return startTour(tour);
});
} else {
return startTour(tour);
}
return startTour(tour);
}

function stop() {
Expand All @@ -72,8 +73,11 @@
return toggleElements(false);
})
.then(function() {
service.current.promise.reject();
var func = service.current.tour.config.onClose;
service.current = false;
if(func) {
return func();
}
return true;
});
}
Expand Down Expand Up @@ -164,13 +168,14 @@
service.box = angular.element($compile('<nz-tour class="hidden"></nz-tour>')(service));
angular.element(service.body).append(service.box);
service.box.removeClass('hidden');
return $q.when();
} else {
service.box.addClass('hidden');
return $timeout(function() {
service.cleanup();
}, service.current.tour.config.animationDuration);
}
return $q.when(null);
// return $q.when(null);
}

function doStep(direction) {
Expand Down Expand Up @@ -210,8 +215,11 @@
function finish() {
return toggleElements(false)
.then(function() {
service.current.promise.resolve();
var func = service.current.tour.config.onComplete;
service.current = false;
if(func) {
return func();
}
return true;
});
}
Expand Down
Loading

0 comments on commit 119c9bc

Please sign in to comment.