Skip to content

Commit

Permalink
Merge pull request #16 from tienvx/feat/disable_automatic_scolling
Browse files Browse the repository at this point in the history
Add option to disable automatic scrolling.
  • Loading branch information
sathomas committed Dec 8, 2013
2 parents 8fe3884 + 2ff7323 commit c77cdd0
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/acc-wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@
// the first panel that isn't complete is the active panel. If none
// of the steps are marked as complete, then use the first step.

currentHash = window.location.hash ||
if (options.autoScrolling) {
currentHash = window.location.hash;
}
currentHash = currentHash ||
$(options.sidebar,$el)
.children("li."+options.todoClass+":first")
.children("a").attr("href") ||
Expand All @@ -175,7 +178,9 @@
.children("a").attr("href");

// Sync up the window hash with our calculated value
window.location.hash = currentHash;
if (options.autoScrolling) {
window.location.hash = currentHash;
}

// We also need to know the overall parent for the panels
var parent = "#" + $(".accordion",$el)[0].id;
Expand Down Expand Up @@ -206,13 +211,15 @@
// Next up are the events we need to hook. To continue
// with the hash theme, here's our hook for hash
// changes.
$(window).bind('hashchange', function() {
if (currentHash !== window.location.hash) {
currentHash = window.location.hash;
$(".accordion-body" + currentHash,$el).collapse("show");
makeTaskActive(currentHash);
}
});
if (options.autoScrolling) {
$(window).bind('hashchange', function() {
if (currentHash !== window.location.hash) {
currentHash = window.location.hash;
$(".accordion-body" + currentHash,$el).collapse("show");
makeTaskActive(currentHash);
}
});
}

// Whenever a new accordion panel is shown, update
// the vertical navigation task list to make
Expand All @@ -221,7 +228,9 @@
$(".accordion-body",$el).on("shown", function () {
currentHash = "#" + this.id;
makeTaskActive(currentHash);
window.location.hash = currentHash;
if (options.autoScrolling) {
window.location.hash = currentHash;
}
});

if (options.addButtons) {
Expand Down Expand Up @@ -372,6 +381,7 @@
backType: "reset", // HTML input type for back button
nextClasses: "btn btn-primary", // class(es) for next button
backClasses: "btn", // class(es) for back button
autoScrolling: true,
onNext: function() {}, // function to call on next step
onBack: function() {}, // function to call on back up
onInit: function() {}, // a chance to hook initialization
Expand Down

0 comments on commit c77cdd0

Please sign in to comment.