Skip to content
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

Showing step counter on each step - Now with template #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions joyride-2.0.3.css
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,9 @@ body {
top: 0px;
left: 0px;
}

.joyride-counter {
color: #BBBBBB;
float: right;
font-size: 14px;
}
19 changes: 17 additions & 2 deletions jquery.joyride-2.0.3.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
'postRideCallback' : $.noop, // A method to call once the tour closes (canceled or complete)
'preStepCallback' : $.noop, // A method to call before each step
'postStepCallback' : $.noop, // A method to call after each step
'postCancelCallback' : $.noop, // A method to call after joyride is cancelled
'showStepCounter' : true, // To show step counter like 1 of 5 on each step
'template' : { // HTML segments for tip layout
'link' : '<a href="#close" class="joyride-close-tip">X</a>',
'timer' : '<div class="joyride-timer-indicator-wrap"><span class="joyride-timer-indicator"></span></div>',
Expand All @@ -44,7 +46,8 @@
'button' : '<a href="#" class="joyride-next-tip"></a>',
'modal' : '<div class="joyride-modal-bg"></div>',
'expose' : '<div class="joyride-expose-wrapper"></div>',
'exposeCover': '<div class="joyride-expose-cover"></div>'
'exposeCover': '<div class="joyride-expose-cover"></div>',
'step_counter' : '<div class="joyride-counter"></div>'
}
},

Expand Down Expand Up @@ -126,6 +129,7 @@
settings.$document.on('click.joyride', '.joyride-close-tip', function (e) {
e.preventDefault();
methods.end();
settings.postCancelCallback(settings.$li.index(), settings.$current_tip);
});

settings.$window.bind('resize.joyride', function (e) {
Expand Down Expand Up @@ -170,7 +174,17 @@
methods.hide();
methods.show();
}
},
},

steps_html : function (opts) {
var step_counter;
if (settings.showStepCounter) {
step_counter = $(settings.template.step_counter);
step_counter.append((opts.index+1) + ' of '+ $($(opts.li).parent()).children('li').size()) ;
return methods.outerHTML(step_counter[0]);
}
return '';
},

tip_template : function (opts) {
var $blank, content, $wrapper;
Expand All @@ -180,6 +194,7 @@
$blank = $(settings.template.tip).addClass(opts.tip_class);
content = $.trim($(opts.li).html()) +
methods.button_text(opts.button_text) +
methods.steps_html(opts) +
settings.template.link +
methods.timer_instance(opts.index);

Expand Down