Skip to content

Commit 9f213a8

Browse files
authored
Merge pull request #18 from FelipePrestesA/master
Update jquery.smartWizard.js
2 parents 4b4d817 + 6fec48a commit 9f213a8

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

js/jquery.smartWizard.js

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
enableAnchorOnDoneStep: true // Enable/Disable the done steps navigation
4141
},
4242
contentURL: null, // content url, Enables Ajax content loading. Can also set as data data-content-url on anchor
43+
contentCache: true, // cache step contents, if false content is fetched always from ajax url
4344
disabledSteps: [], // Array Steps disabled
4445
errorSteps: [], // Highlight step with errors
4546
hiddenSteps: [], // Hidden steps
@@ -316,9 +317,35 @@
316317
},
317318
_loadStepContent: function (idx) {
318319
var mi = this;
320+
// Get current step elements
321+
var curTab = this.steps.eq(this.current_index);
322+
var curPage = (curTab.length>0) ? $(curTab.attr("href"),this.main) : null;
323+
// Get step to show elements
324+
var selTab = this.steps.eq(idx);
325+
var selPage = (selTab.length>0) ? $(selTab.attr("href"),this.main) : null;
326+
// Get the direction of step navigation
327+
var stepDirection = '';
319328
var elm = this.steps.eq(idx);
320329
var contentURL = (elm.data('content-url') && elm.data('content-url').length > 0) ? elm.data('content-url') : this.options.contentURL;
330+
331+
if(this.current_index !== null && this.current_index !== idx){
332+
stepDirection = (this.current_index < idx) ? "forward" : "backward";
333+
}
321334

335+
var stepPosition = 'middle';
336+
if(idx === 0){
337+
stepPosition = 'first';
338+
}else if(idx === (this.steps.length-1)){
339+
stepPosition = 'final';
340+
}
341+
342+
// Trigger "leaveStep" event
343+
if(this.current_index !== null && this._triggerEvent("leaveStep", [curTab, this.current_index, stepDirection]) === false){ return false; }
344+
345+
// check contentCache
346+
if(!this.options.contentCache){
347+
elm.data('has-content', false);
348+
}
322349
if(contentURL && contentURL.length > 0 && !elm.data('has-content')){
323350
// Get ajax content and then show step
324351
var selPage = (elm.length>0) ? $(elm.attr("href"),this.main) : null;
@@ -364,10 +391,7 @@
364391
}else if(idx === (this.steps.length-1)){
365392
stepPosition = 'final';
366393
}
367-
368-
// Trigger "leaveStep" event
369-
if(this.current_index !== null && this._triggerEvent("leaveStep", [curTab, this.current_index, stepDirection]) === false){ return false; }
370-
394+
371395
this.options.transitionEffect = this.options.transitionEffect.toLowerCase();
372396
this.pages.finish();
373397
if(this.options.transitionEffect === 'slide'){ // normal slide
@@ -565,4 +589,4 @@
565589
}
566590
};
567591

568-
})(jQuery, window, document);
592+
})(jQuery, window, document);

0 commit comments

Comments
 (0)