D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
shubmkcj
/
urbane.createerp.com
/
plugins
/
jquery.stepy
/
Filename :
jquery.stepy.min.js
back
Copy
/*! * jQuery Stepy - A Wizard Plugin * * Licensed under The MIT License * * @version 1.1.0 * @author Washington Botelho * @documentation wbotelhos.com/stepy * */ ;!function(t){var e={init:function(i){return this.each(function(){e.destroy.call(this),this.opt=t.extend({},t.fn.stepy.defaults,i);var n=this,a=t(this),s=a.attr("id");if(void 0===s||""===s){var s=e._hash.call(n);a.attr("id",s)}n.opt.validate&&(jQuery.validator.setDefaults({ignore:n.opt.ignore}),a.append('<div class="stepy-errors" />')),n.header=e._header.call(n),n.steps=a.children("fieldset"),n.steps.each(function(t){e._createHead.call(n,this,t),e._createButtons.call(n,this,t)}),n.heads=n.header.children("li"),n.heads.first().addClass("stepy-active"),n.opt.finishButton&&e._bindFinish.call(n),n.opt.titleClick?n.heads.click(function(){var i=n.heads.filter(".stepy-active").attr("id").split("-"),s=parseInt(i[i.length-1],10),r=t(this).index();if(r>s){if(n.opt.next&&!e._execute.call(a,n.opt.next,r))return!1}else if(s>r&&n.opt.back&&!e._execute.call(a,n.opt.back,r))return!1;r!=s&&e.step.call(n,r+1)}):n.heads.css("cursor","default"),n.opt.enter&&e._bindEnter.call(n),n.steps.first().find(":input:visible:enabled").first().select().focus(),a.data({settings:this.opt,stepy:!0})})},_bindEnter:function(){var e=this;e.steps.delegate('input[type="text"], input[type="password"]',"keypress",function(i){var n=i.keyCode?i.keyCode:i.which;if(13==n){i.preventDefault();var a=t(this).closest("fieldset").find(".stepy-navigator");if(a.length){var s=a.children(".button-next");s.length?s.click():e.finish&&e.finish.click()}}})},_bindFinish:function(){var i=this,n=t(this),a=n.children('input[type="submit"]');if(i.finish=1===a.length?a:n.children(".stepy-finish"),i.finish.length){var s=n.is("form"),r=void 0;s&&i.opt.finish&&(r=n.attr("onsubmit"),n.attr("onsubmit","return false;")),i.finish.on("click.stepy",function(t){if(i.opt.finish&&!e._execute.call(n,i.opt.finish,i.steps.length-1))t.preventDefault();else if(s){r?n.attr("onsubmit",r):n.removeAttr("onsubmit");var a="submit"===i.finish.attr("type");a||i.opt.validate&&!e.validate.call(n,i.steps.length-1)||n.submit()}}),i.steps.last().children(".stepy-navigator").append(i.finish)}else t.error('Submit button or element with class "stepy-finish" missing!')},_createBackButton:function(i,n){var a=this,s=(t(this),{href:"#","class":"button-back",html:a.opt.backLabel});t("<a />",s).on("click.stepy",function(t){t.preventDefault(),(!a.opt.back||e._execute.call(a,a.opt.back,n-1))&&e.step.call(a,n-1+1)}).appendTo(i)},_createButtons:function(i,n){var a=e._navigator.call(this).appendTo(i);0===n?this.steps.length>1&&e._createNextButton.call(this,a,n):(t(i).hide(),e._createBackButton.call(this,a,n),n<this.steps.length-1&&e._createNextButton.call(this,a,n))},_createHead:function(i,n){var i=t(i).attr("id",t(this).attr("id")+"-step-"+n).addClass("stepy-step"),a=e._head.call(this,n);a.append(e._title.call(this,i)),this.opt.description&&a.append(e._description.call(this,i)),this.header.append(a)},_createNextButton:function(i,n){var a=this,s=t(this),r={href:"#","class":"button-next",html:a.opt.nextLabel};t("<a/>",r).on("click.stepy",function(t){t.preventDefault(),(!a.opt.next||e._execute.call(s,a.opt.next,n+1))&&e.step.call(a,n+1+1)}).appendTo(i)},_description:function(i){var n=i.children("legend");return this.opt.legend||n.hide(),n.length?t("<span />",{html:n.html()}):void e._error.call(this,"<legend /> element missing!")},_error:function(e){t(this).html(e),t.error(e)},_execute:function(t,e){var i=t.call(this,e+1);return i||void 0===i},_hash:function(){return this.hash="stepy-"+Math.random().toString().substring(2),this.hash},_head:function(e){return t("<li />",{id:t(this).attr("id")+"-head-"+e})},_header:function(){var e=t("<ul />",{id:t(this).attr("id")+"-header","class":"stepy-header"});return this.opt.titleTarget?e.appendTo(this.opt.titleTarget):e.insertBefore(this),e},_navigator:function(e){return t('<p class="stepy-navigator" />')},_title:function(e){return t("<div />",{html:e.attr("title")||"--"})},destroy:function(){return t(this).each(function(){var e=t(this);if(e.data("stepy")){var i=e.data("stepy",!1).children("fieldset").css("display","");e.children(".stepy-errors").remove(),this.finish.appendTo(i.last()),i.find("p.stepy-navigator").remove()}})},step:function(i){that=t(this),opt=that[0].opt,i--;var n=that.children("fieldset");i>n.length-1&&(i=n.length-1);var a=i;if(opt.validate)for(var s=!0,r=0;i>r;r++)if(s&=e.validate.call(this,r),opt.block&&!s){a=r;break}var l=n.length;if("fade"==opt.transition?n.fadeOut(opt.duration,function(){--l>0||n.eq(a).fadeIn(opt.duration)}):"slide"==opt.transition?n.slideUp(opt.duration,function(){--l>0||n.eq(a).slideDown(opt.duration)}):n.hide(opt.duration).eq(a).show(opt.duration),that[0].heads.removeClass("stepy-active").eq(a).addClass("stepy-active"),that.is("form")){var o=void 0;o=a==i?n.eq(a).find(":input:enabled:visible"):n.eq(a).find(".error").select().focus(),o.first().select().focus()}return opt.select&&opt.select.call(this,a+1),that},validate:function(e){var i=t(this);if(!i.is("form"))return!0;var n=this,a=i.children("fieldset").eq(e),s=!0,r=t("#"+i.attr("id")+"-header").children().eq(e),l=i.validate();return t(a.find(":input:enabled").get().reverse()).each(function(){var e=l.element(t(this));void 0===e&&(e=!0),s&=e,s?n.opt.errorImage&&r.removeClass("stepy-error"):(n.opt.errorImage&&r.addClass("stepy-error"),l.focusInvalid())}),s}};t.fn.stepy=function(i){return e[i]?e[i].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof i&&i?void t.error("Method "+i+" does not exist!"):e.init.apply(this,arguments)},t.fn.stepy.defaults={back:void 0,backLabel:"< Back",block:!1,description:!0,duration:void 0,enter:!0,errorImage:!1,finish:void 0,finishButton:!0,ignore:"",legend:!0,next:void 0,nextLabel:"Next >",select:void 0,titleClick:!1,titleTarget:void 0,transition:void 0,validate:!1}}(jQuery);