layui.define(["jquery","layer","form"],function(x){var l=layui.jquery,w=layui.form,k=layui.layer,u=layui.device(),V=(function(){var t=".slider-item{height:38px;line-height:38px;background-color:#d0d0d0;position:relative;border: 1px solid white;}.slider-bg{position:absolute;width:40px;height:100%;z-index:100}.slider-btn{width:40px;height:96%;position:absolute;border:1px solid #ccc;cursor:move;text-align:center;background-color:#fff;user-select:none;color:#666;z-index:120}.slider-btn-success{font-size:26px}.slider-text{position:absolute;text-align:center;width:100%;height:100%;user-select:none;font-size:14px;color:#fff;z-index:120}.slider-error{animation:glow 800ms ease-out infinite alternate;}@keyframes glow{0%{border-color:#e6e6e6}100%{border-color:#ff5722}}",e=document.createElement("style");e.innerHTML=t,e.type="text/css",l("head link:last")[0]&&l("head link:last").after(e)||l("head").append(e)})(),m={version:"1.7.2"},a=function(t){return t[0]},O=function(){var t=this;return{isOk:function(){return t.isOk.call(t)},reset:function(){return t.reset.call(t)}}},y="sliderVerify",p="slider-btn",b="slider-bg",g="slider-text",L="layui-icon-next",z="layui-icon-ok-circle",M="slider-btn-success",C="layui-bg-green",h="slider-error",E="请拖动滑块验证",A="验证通过",r=function(t){var e=this;e.config=l.extend({},e.config,t),e.render()};r.prototype.config={elem:"",onOk:null,isOk:!1,isAutoVerify:!0,timer:null,bg:C,text:E},r.prototype.render=function(){var t=this,e=t.config,o=l(e.elem);if(o[0]){e.domid&&e.domid.remove(),e.domid=t.createIdNum();var i=l(['
','
','
'+e.text+"
",'
'].join(""));o.hide().after(i),e.domid=l("#"+e.domid),t.events(),e.isAutoVerify&&w.verify({sliderVerify:function(n,s){if(!n)return s.classList.add(h),e.text}})}},r.prototype.isMobile=function(){return u.os=="ios"||u.os=="android"||u.android||u.ios||u.weixin&&typeof u.weixin===Boolean},r.prototype.createIdNum=function(){return y+(+new Date).toString()+Math.random().toString().substr(2,7)},r.prototype.isOk=function(){return this.config.isOk},r.prototype.error=function(t){return k.msg(t,{icon:5})},r.prototype.distance=function(){var t=this.config.container;return t.box.offsetWidth-t.btn.offsetWidth},r.prototype.reset=function(){return this.config.isOk=!1,this.render()},r.prototype.resize=function(i){var e=this,o=e.config.container,i=i||e.distance();o.btn.style.left=i+"px",o.bg.style.width=i+"px"},r.prototype.cancelTransition=function(){var t=this.config.container;this.config.domid[0].classList.remove(h),t.btn.style.transition="",t.bg.style.transition=""},r.prototype.down=function(n){var e=this,o=e.config,i=o.container,n=n||window.event,s=n.clientX||n.touches[0].clientX;e.cancelTransition();var c=function(d){e.move(s,d)};e.events.move=c,e.isMobile()?document.addEventListener("touchmove",e.events.move):document.onmousemove=c,navigator.userAgent.indexOf("UCBrowser")>-1&&n.preventDefault()},r.prototype.move=function(t,s){var o=this,i=o.config,n=i.container,s=s||window.event,c=s.clientX||s.touches[0].clientX,d=c-t;if(d>n.distance?d=n.distance:d<0&&(d=0),n.btn.style.left=d+"px",n.bg.style.width=d+"px",d==n.distance){n.text.innerHTML=A;var f=window.getComputedStyle?window.getComputedStyle(n.bg,null):n.bg.currentStyle;n.btn.style.border="1px solid "+f.backgroundColor,n.btn.style.color=f.backgroundColor,n.btn.classList.remove(L),n.btn.classList.add(z,M),i.isOk=!0,n.box.value=!0,o.isMobile()?(n.btn.removeEventListener("touchstart",o.events.down,!1),document.removeEventListener("touchmove",o.events.move,!1)):(n.btn.onmousedown=null,document.onmousemove=null),i.onOk&&typeof i.onOk=="function"&&i.onOk();return}var v=function(T){o.stop(T)};o.events.seup=v,o.isMobile()?document.addEventListener("touchend",v):document.onmouseup=v},r.prototype.stop=function(t){var e=this,o=e.config,i=o.container;e.isOk()||(i.btn.style.left=0,i.bg.style.width=0,i.btn.style.transition="left 1s",i.bg.style.transition="width 1s",document.onmousemove=null,document.onmouseup=null,e.isMobile()&&(document.removeEventListener("touchmove",e.events.move,!1),document.removeEventListener("touchend",e.events.seup,!1)))},r.prototype.events=function(){var t=this,e=t.config;if(!e.domid)return t.error("创建滑块验证失败");var o=e.domid.find("."+p),i=e.domid.find("."+b),n=e.domid.find("."+g),s={box:a(e.domid),btn:a(o),bg:a(i),text:a(n)};e.container=s,s.distance=t.distance();var c=function(f){t.down(f)};t.events.down=c,t.isMobile()?s.btn.addEventListener("touchstart",t.events.down):s.btn.onmousedown=c;var d=l(window);d.on("resize",e.domid,function(){t.config.isOk?t.resize():(clearTimeout(e.timer),e.timer=setTimeout(function(){t.render()},400))})},m.render=function(t){var e=new r(t);return O.call(e)},x(y,m)});