Skip to content

Commit

Permalink
Merge pull request #18 from FelipePrestesA/master
Browse files Browse the repository at this point in the history
Update jquery.smartWizard.js
  • Loading branch information
techlab authored Feb 1, 2017
2 parents 4b4d817 + 6fec48a commit 9f213a8
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions js/jquery.smartWizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
enableAnchorOnDoneStep: true // Enable/Disable the done steps navigation
},
contentURL: null, // content url, Enables Ajax content loading. Can also set as data data-content-url on anchor
contentCache: true, // cache step contents, if false content is fetched always from ajax url
disabledSteps: [], // Array Steps disabled
errorSteps: [], // Highlight step with errors
hiddenSteps: [], // Hidden steps
Expand Down Expand Up @@ -316,9 +317,35 @@
},
_loadStepContent: function (idx) {
var mi = this;
// Get current step elements
var curTab = this.steps.eq(this.current_index);
var curPage = (curTab.length>0) ? $(curTab.attr("href"),this.main) : null;
// Get step to show elements
var selTab = this.steps.eq(idx);
var selPage = (selTab.length>0) ? $(selTab.attr("href"),this.main) : null;
// Get the direction of step navigation
var stepDirection = '';
var elm = this.steps.eq(idx);
var contentURL = (elm.data('content-url') && elm.data('content-url').length > 0) ? elm.data('content-url') : this.options.contentURL;

if(this.current_index !== null && this.current_index !== idx){
stepDirection = (this.current_index < idx) ? "forward" : "backward";
}

var stepPosition = 'middle';
if(idx === 0){
stepPosition = 'first';
}else if(idx === (this.steps.length-1)){
stepPosition = 'final';
}

// Trigger "leaveStep" event
if(this.current_index !== null && this._triggerEvent("leaveStep", [curTab, this.current_index, stepDirection]) === false){ return false; }

// check contentCache
if(!this.options.contentCache){
elm.data('has-content', false);
}
if(contentURL && contentURL.length > 0 && !elm.data('has-content')){
// Get ajax content and then show step
var selPage = (elm.length>0) ? $(elm.attr("href"),this.main) : null;
Expand Down Expand Up @@ -364,10 +391,7 @@
}else if(idx === (this.steps.length-1)){
stepPosition = 'final';
}

// Trigger "leaveStep" event
if(this.current_index !== null && this._triggerEvent("leaveStep", [curTab, this.current_index, stepDirection]) === false){ return false; }


this.options.transitionEffect = this.options.transitionEffect.toLowerCase();
this.pages.finish();
if(this.options.transitionEffect === 'slide'){ // normal slide
Expand Down Expand Up @@ -565,4 +589,4 @@
}
};

})(jQuery, window, document);
})(jQuery, window, document);

0 comments on commit 9f213a8

Please sign in to comment.