-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjquery.bootstrap.wizard.min.js
More file actions
1 lines (1 loc) · 5.42 KB
/
Copy pathjquery.bootstrap.wizard.min.js
File metadata and controls
1 lines (1 loc) · 5.42 KB
1
!function(n){var t=function(t,e){var t=n(t),i=this,o='li:has([data-toggle="tab"])',a=[],r=n.extend({},n.fn.bootstrapWizard.defaults,e),s=null,l=null;this.rebindClick=function(n,t){n.unbind("click",t).bind("click",t)},this.fixNavigationButtons=function(){return s.length||(l.find("a:first").tab("show"),s=l.find(o+":first")),n(r.previousSelector,t).toggleClass("disabled",i.firstIndex()>=i.currentIndex()),n(r.nextSelector,t).toggleClass("disabled",i.currentIndex()>=i.navigationLength()),n(r.nextSelector,t).toggleClass("hidden",i.currentIndex()>=i.navigationLength()&&n(r.finishSelector,t).length>0),n(r.lastSelector,t).toggleClass("hidden",i.currentIndex()>=i.navigationLength()&&n(r.finishSelector,t).length>0),n(r.finishSelector,t).toggleClass("hidden",i.currentIndex()<i.navigationLength()),n(r.backSelector,t).toggleClass("disabled",0==a.length),n(r.backSelector,t).toggleClass("hidden",i.currentIndex()>=i.navigationLength()&&n(r.finishSelector,t).length>0),i.rebindClick(n(r.nextSelector,t),i.next),i.rebindClick(n(r.previousSelector,t),i.previous),i.rebindClick(n(r.lastSelector,t),i.last),i.rebindClick(n(r.firstSelector,t),i.first),i.rebindClick(n(r.finishSelector,t),i.finish),i.rebindClick(n(r.backSelector,t),i.back),r.onTabShow&&"function"==typeof r.onTabShow&&r.onTabShow(s,l,i.currentIndex())===!1?!1:void 0},this.next=function(){if(t.hasClass("last"))return!1;if(r.onNext&&"function"==typeof r.onNext&&r.onNext(s,l,i.nextIndex())===!1)return!1;var n=i.currentIndex();$index=i.nextIndex(),$index>i.navigationLength()||(a.push(n),l.find(o+":eq("+$index+") a").tab("show"))},this.previous=function(){if(t.hasClass("first"))return!1;if(r.onPrevious&&"function"==typeof r.onPrevious&&r.onPrevious(s,l,i.previousIndex())===!1)return!1;var n=i.currentIndex();$index=i.previousIndex(),$index<0||(a.push(n),l.find(o+":eq("+$index+") a").tab("show"))},this.first=function(){return r.onFirst&&"function"==typeof r.onFirst&&r.onFirst(s,l,i.firstIndex())===!1?!1:t.hasClass("disabled")?!1:(a.push(i.currentIndex()),void l.find(o+":eq(0) a").tab("show"))},this.last=function(){return r.onLast&&"function"==typeof r.onLast&&r.onLast(s,l,i.lastIndex())===!1?!1:t.hasClass("disabled")?!1:(a.push(i.currentIndex()),void l.find(o+":eq("+i.navigationLength()+") a").tab("show"))},this.finish=function(){r.onFinish&&"function"==typeof r.onFinish&&r.onFinish(s,l,i.lastIndex())},this.back=function(){if(0==a.length)return null;var n=a.pop();return r.onBack&&"function"==typeof r.onBack&&r.onBack(s,l,n)===!1?(a.push(n),!1):void t.find(o+":eq("+n+") a").tab("show")},this.currentIndex=function(){return l.find(o).index(s)},this.firstIndex=function(){return 0},this.lastIndex=function(){return i.navigationLength()},this.getIndex=function(n){return l.find(o).index(n)},this.nextIndex=function(){return l.find(o).index(s)+1},this.previousIndex=function(){return l.find(o).index(s)-1},this.navigationLength=function(){return l.find(o).length-1},this.activeTab=function(){return s},this.nextTab=function(){return l.find(o+":eq("+(i.currentIndex()+1)+")").length?l.find(o+":eq("+(i.currentIndex()+1)+")"):null},this.previousTab=function(){return i.currentIndex()<=0?null:l.find(o+":eq("+parseInt(i.currentIndex()-1)+")")},this.show=function(n){var e=t.find(isNaN(n)?o+" a[href=#"+n+"]":o+":eq("+n+") a");e.length>0&&(a.push(i.currentIndex()),e.tab("show"))},this.disable=function(n){l.find(o+":eq("+n+")").addClass("disabled")},this.enable=function(n){l.find(o+":eq("+n+")").removeClass("disabled")},this.hide=function(n){l.find(o+":eq("+n+")").hide()},this.display=function(n){l.find(o+":eq("+n+")").show()},this.remove=function(t){var e=t[0],i="undefined"!=typeof t[1]?t[1]:!1,a=l.find(o+":eq("+e+")");if(i){var r=a.find("a").attr("href");n(r).remove()}a.remove()};var d=function(t){var e=l.find(o),a=e.index(n(t.currentTarget).parent(o)),d=n(e[a]);return r.onTabClick&&"function"==typeof r.onTabClick&&r.onTabClick(s,l,i.currentIndex(),a,d)===!1?!1:void 0},u=function(t){$element=n(t.target).parent();var e=l.find(o).index($element);return $element.hasClass("disabled")?!1:r.onTabChange&&"function"==typeof r.onTabChange&&r.onTabChange(s,l,i.currentIndex(),e)===!1?!1:(s=$element,void i.fixNavigationButtons())};this.resetWizard=function(){n('a[data-toggle="tab"]',l).off("click",d),n('a[data-toggle="tab"]',l).off("shown shown.bs.tab",u),l=t.find("ul:first",t),s=l.find(o+".active",t),n('a[data-toggle="tab"]',l).on("click",d),n('a[data-toggle="tab"]',l).on("shown shown.bs.tab",u),i.fixNavigationButtons()},l=t.find("ul:first",t),s=l.find(o+".active",t),l.hasClass(r.tabClass)||l.addClass(r.tabClass),r.onInit&&"function"==typeof r.onInit&&r.onInit(s,l,0),r.onShow&&"function"==typeof r.onShow&&r.onShow(s,l,i.nextIndex()),n('a[data-toggle="tab"]',l).on("click",d),n('a[data-toggle="tab"]',l).on("shown shown.bs.tab",u)};n.fn.bootstrapWizard=function(e){if("string"==typeof e){var i=Array.prototype.slice.call(arguments,1);return 1===i.length&&i.toString(),this.data("bootstrapWizard")[e](i)}return this.each(function(){var i=n(this);if(!i.data("bootstrapWizard")){var o=new t(i,e);i.data("bootstrapWizard",o),o.fixNavigationButtons()}})},n.fn.bootstrapWizard.defaults={tabClass:"nav nav-pills",nextSelector:".wizard li.next",previousSelector:".wizard li.previous",firstSelector:".wizard li.first",lastSelector:".wizard li.last",finishSelector:".wizard li.finish",backSelector:".wizard li.back",onShow:null,onInit:null,onNext:null,onPrevious:null,onLast:null,onFirst:null,onFinish:null,onBack:null,onTabChange:null,onTabClick:null,onTabShow:null}}(jQuery);