mirror of
https://github.com/esphome/esphome.git
synced 2024-11-30 10:44:13 +01:00
6 lines
7.5 KiB
JavaScript
6 lines
7.5 KiB
JavaScript
|
/* Materializecss Stepper - By Kinark 2016
|
||
|
// https://github.com/Kinark/Materialize-stepper
|
||
|
// JS.min v2.1.3
|
||
|
*/
|
||
|
var validation=$.isFunction($.fn.valid)?1:0;$.fn.isValid=function(){return!validation||this.valid()},validation&&$.validator.setDefaults({errorClass:"invalid",validClass:"valid",errorPlacement:function(a,b){b.is(":radio")||b.is(":checkbox")?a.insertBefore($(b).parent()):a.insertAfter(b)},success:function(a){$(a).closest("li").find("label.invalid:not(:empty)").length||$(a).closest("li").removeClass("wrong")}}),$.fn.getActiveStep=function(){return active=this.find(".step.active"),$(this.children(".step:visible")).index($(active))+1},$.fn.activateStep=function(a){$(this).hasClass("step")||(stepper=$(this).closest("ul.stepper"),stepper.find(">li").removeAttr("data-last"),window.innerWidth<993||!stepper.hasClass("horizontal")?$(this).addClass("step").stop().slideDown(400,function(){$(this).css({height:"auto","margin-bottom":"",display:"inherit"}),a&&a(),stepper.find(">li.step").last().attr("data-last","true")}):$(this).addClass("step").stop().css({width:"0%",display:"inherit"}).animate({width:"100%"},400,function(){$(this).css({height:"auto","margin-bottom":"",display:"inherit"}),a&&a(),stepper.find(">li.step").last().attr("data-last","true")}))},$.fn.deactivateStep=function(a){$(this).hasClass("step")&&(stepper=$(this).closest("ul.stepper"),stepper.find(">li").removeAttr("data-last"),window.innerWidth<993||!stepper.hasClass("horizontal")?$(this).stop().css({transition:"none","-webkit-transition":"margin-bottom none"}).slideUp(400,function(){$(this).removeClass("step").css({height:"auto","margin-bottom":"",transition:"margin-bottom .4s","-webkit-transition":"margin-bottom .4s"}),a&&a(),stepper.find(">li").removeAttr("data-last"),stepper.find(">li.step").last().attr("data-last","true")}):$(this).stop().animate({width:"0%"},400,function(){$(this).removeClass("step").hide().css({height:"auto","margin-bottom":"",display:"none",width:""}),a&&a(),stepper.find(">li.step").last().attr("data-last","true")}))},$.fn.showError=function(a){if(validation){name=this.attr("name"),form=this.closest("form");var b={};b[name]=a,form.validate().showErrors(b),this.closest("li").addClass("wrong")}else this.removeClass("valid").addClass("invalid"),this.next().attr("data-error",a)},$.fn.activateFeedback=function(){active=this.find(".step.active:not(.feedbacking)").addClass("feedbacking").find(".step-content"),active.prepend('<div class="wait-feedback"> <div class="preloader-wrapper active"> <div class="spinner-layer spinner-blue"> <div class="circle-clipper left"> <div class="circle"></div></div><div class="gap-patch"> <div class="circle"></div></div><div class="circle-clipper right"> <div class="circle"></div></div></div><div class="spinner-layer spinner-red"> <div class="circle-clipper left"> <div class="circle"></div></div><div class="gap-patch"> <div class="circle"></div></div><div class="circle-clipper right"> <div class="circle"></div></div></div><div class="spinner-layer spinner-yellow"> <div class="circle-clipper left"> <div class="circle"></div></div><div class="gap-patch"> <div class="circle"></div></div><div class="circle-clipper right"> <div class="circle"></div></div></div><div class="spinner-layer spinner-green"> <div class="circle-clipper left"> <div class="circle"></div></div><div class="gap-patch"> <div class="circle"></div></div><div class="circle-clipper right"> <div class="circle"></div></div></div></div></div>')},$.fn.destroyFeedback=function(){return active=this.find(".step.active.feedbacking"),active&&(active.removeClass("feedbacking"),active.find(".wait-feedback").remove()),!0},$.fn.resetStepper=function(a){return a||(a=1),form=$(this).closest("form"),$(form)[0].reset(),Materialize.updateTextFields(),$(this).openStep(a)},$.fn.submitStepper=function(a){form=this.closest("form"),form.isValid()&&form.submit()},$.fn.nextStep=function(a,b,c){return stepper=this,settings=$(stepper).data("settings"),form=this.closest("form"),active=this.find(".step.active"),next=$(this.children(".step:visible")).index($(active))+2,feedback=active.find(".next-step").length>1?c?$(c.target).data("feedback"):void 0:active.find(".next-step").data("feedba
|