-
Notifications
You must be signed in to change notification settings - Fork 943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add number of steps to the template function #362
Comments
I was looking for a similar feature. I was hoping to find something in the template such as.
|
I was looking for something like this and came up with the following solution:
For example: var tour_steps = [
{
orphan: true,
title: "Welcome to this tour!",
content: 'This is the first step.',
},
{
element: "#cool_element",
title: 'Now with item counts.',
content: "These steps have the count shown in the header...",
},
];
$.each(tour_steps, function(i, step){
step['title'] += '<span style="float:right;">'+(i+1)+'/'+tour_steps.length+'</span>';
});
var my_tour = new Tour({
backdrop: true,
storage: false,
steps: tour_steps
});
my_tour.init(); Obviously you can adjust the markup however you would like. For instance, a progress bar: $.each(tour_steps, function(i, step){
var percent = parseInt(((i+1) / tour_steps.length) * 100);
step['content'] = '<div class="progress"><div class="progress-bar" role="progressbar" style="min-width: 2em; width:'+percent+'%;">'+percent+'%</div></div>'+step['content'];
}); I hope that helps someone! |
For completeness, here's my solution (adds slide number after the title on the right, and has a progress bar underneath).. JS: var tour_steps = [
...
{
orphan: true,
title: "Example Tour Slide",
content: "I know how far through this tour I am! And my, what a lovely progress bar."
},
...
];
$.each(tour_steps, function(i, step){
step['title'] += '<span class="pull-right">'+(i+1)+'/'+tour_steps.length+'</span>';
var percent = parseInt(((i+1) / tour_steps.length) * 100);
step['content'] = '<div class="pbar_wrapper"><hr class="pbar" style="width:'+percent+'%;"></div>' + step['content'];
});
var intro_tour = new Tour({
backdrop: true,
storage: false,
steps: tour_steps
});
intro_tour.init();
$('#launch-into-tour').click(function(){
intro_tour.start();
}); CSS: .popover.my-tour .popover-content {
padding-top: 0;
}
.popover.my-tour .popover-content .pbar_wrapper {
padding-bottom: 9px;
margin: -1px -14px 0;
}
.popover.my-tour .popover-content .pbar {
border-top: 1px solid #337ab7;
margin:0;
} |
… added Fixed flow issue with tour.init() especially where page contains hidden elements - Do not call tour.init(). Create your new Tour({options}); then call Tour.start or .restart when you want to show the tour. (sorich87#700 Fixed inefficient display of tour popover - popovers do not constantly reload current step on scroll. Flickering/flashing resolved. (sorich87#685) - element popovers don't move around the page as you scroll - this is a personal thing, but I didn't like the functionality where if you scroll the page so the element is no longer visible, the popover follows you around. Doesn't make much sense because the popover isn't visually attached to it's parent element. - orphan popovers stay stuck to the center of the screen no matter what Added onElementUnavailable(tour, step) to global and step options - Specify a function as normal (i.e.: same as onNext etc) with pattern above. Function will be called when the element of the step is unavailable == missing, hidden etc. "step" parameter indicates the step that is going to be skipped. Added progress indicators and ability to dynamically change during tour: - Global option "showProgressBar" : set to true to show a (bootstrap) progress bar, or false to hide it - Step option "showProgressBar" will override global option, so you can turn on/off progress bars per step Customise the progress bar using option getProgressBarHTML: getProgressBarHTML: function(percentProgress) { return '<div class="progress"><div class="progress-bar progress-bar-striped" role="progressbar" style="width: ' + percentProgress + '%;"></div></div>'} - Global and step option "showProgressText" shows a "N / X" tour step counter in the popover title bar Customise the text using option getProgressTextHTML: getProgressBarHTML: function(stepNumber, percentProgress, stepCount) { return '<span class="pull-right">' + stepNumber + '/' + stepCount + '</span>'; } Based on sorich87#362
I think this could be done easily, so we could on the template function add a progress bar.
I've changed the Tour.prototype.getStep and added a property:
numSteps: this._options.steps.length
for me it's working.
Thanks,
Frederico
The text was updated successfully, but these errors were encountered: