UNPKG

7.81 kBJavaScriptView Raw
1!function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.RVerify=t()}(this,function(){"use strict";var e={version:"0.1.1"},M={mask:.5,maskClosable:!1,closeIcon:'<svg t="1590331085919" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3734" width="20" height="20"><path d="M512 451.67l225.835-225.835a42.667 42.667 0 0 1 60.33 60.33L572.331 512l225.834 225.835a42.667 42.667 0 0 1-60.33 60.33L512 572.331 286.165 798.165a42.667 42.667 0 1 1-60.33-60.33L451.669 512 225.835 286.165a42.667 42.667 0 0 1 60.33-60.33L512 451.669z" p-id="3735" fill="#8a8a8a"></path></svg>',sliderIcon:'<svg t="1590338601818" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6547" width="20" height="20"><path d="M512.299934 1023.800044c-10.797617 0-21.595234-3.999117-29.993381-11.797396-17.496139-16.496359-18.195984-44.090269-1.799602-61.586408l412.508958-437.10353c8.398147-8.898036 8.298169-23.894726-0.599868-32.692784L481.606708 74.409578c-17.096227-16.896271-17.296183-44.490181-0.299934-61.586408 16.896271-16.896271 44.390203-17.196205 61.586408-0.299934l410.809333 406.11037c42.290666 41.790777 43.590379 111.075485 2.699404 154.465909l-412.508958 437.003552c-8.69808 9.097992-20.195543 13.696977-31.593027 13.696977z" p-id="6548"></path><path d="M86.093999 924.821889c-10.697639 0-21.495256-3.999117-29.793425-11.897374-17.496139-16.496359-18.295962-44.090269-1.799603-61.586408l315.930274-334.626147c8.398147-9.097992 8.298169-24.094682-0.599868-32.792762L55.500751 173.587689c-16.996249-16.896271-17.196205-44.490181-0.299934-61.686386 16.896271-16.996249 44.390203-17.296183 61.586408-0.199956L431.017873 422.032856c42.290666 41.790777 43.490402 111.075485 2.799382 154.465909l-315.930273 334.626147c-8.69808 9.097992-20.195543 13.696977-31.792983 13.696977z" p-id="6549"></path></svg>',extraIcon:'<svg t="1590289223124" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2770" width="15" height="15"><path d="M512.002558 64.24521c-247.292176 0-447.75786 200.464661-447.75786 447.756837 0 247.287059 200.464661 447.752744 447.75786 447.752744 247.286036 0 447.75172-200.464661 447.75172-447.752744C959.754279 264.710894 759.288594 64.24521 512.002558 64.24521zM512.010745 735.87586c-20.602224 0-37.319977-16.718777-37.319977-37.323047 0-20.597107 16.717753-37.319977 37.319977-37.319977 20.60427 0 37.297464 16.72287 37.297464 37.319977C549.308209 719.158107 532.613992 735.87586 512.010745 735.87586zM549.308209 567.969733c0 20.600177-16.693194 37.293371-37.297464 37.293371-20.602224 0-37.319977-16.693194-37.319977-37.293371L474.690768 325.420581c0-20.605294 16.717753-37.297464 37.319977-37.297464 20.60427 0 37.297464 16.693194 37.297464 37.297464L549.308209 567.969733z" p-id="2771" fill="#4E6EF2"></path></svg>',tolerance:10,duration:500,title:"身份验证",text:"拖动滑块,使图片角度为正",extra:null,extraColor:"#4E6EF2",extraLink:"https://github.com/zpfz",zIndex:9999,album:[]},I=!1;function T(e){return e[t=0,s=e.length-1,Math.round(Math.random()*(s-t)+t)];var t,s}function C(e){if(!(e<5||45<e))return Math.floor(Math.random()*(360-e-1-(e+1)))+(e+1);console.error("Please make sure the tolerance value is between 5°~45°.")}function E(){return parseFloat(V(".rv-img").style.transform.replace(/[^0-9\\.\\^0-9]/gi,""))}function B(e){return e<=M.tolerance||e>=360-M.tolerance}function R(){return"ontouchstart"in window}e.configure=function(e){var t,s;for(t in I=!0,e)void 0!==(s=e[t])&&e.hasOwnProperty(t)&&(M[t]=s);return this},e.action=function(t){if(!I)throw new Error("Please make sure RVerify.configure method is executed before RVerify.action");var e;e=null!==M.extra&&void 0!==M.extra?'<div class="rv-extra"><span>'+M.extraIcon+'</span><a href="'+M.extraLink+'" target="_blank" rel="noopener noreferrer">'+M.extra+"</a></div>":"";var s='<div class="rv-root"><div class="rv-mask"></div><div class="rv-wrap"><div class="rv-close">'+M.closeIcon+'</div><div class="rv-title">'+M.title+'</div><div class="rv-content"><div class="rv-text">'+M.text+'</div><div class="rv-image"><img src="'+T(M.album)+'" draggable="false" class="rv-img"><div class="rv-image-mask"><svg t="1590812400512" class="rv-image-mask-success" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2647" width="80" height="80"><path d="M927.97968 108.360629a50.575037 50.575037 0 0 0-69.085501 18.517689l-391.898737 678.933747-316.000056-182.409708A50.575037 50.575037 0 0 0 100.427574 711.005546l359.812488 207.690002a50.553362 50.553362 0 0 0 69.078276-18.517689L946.504593 177.44613a50.575037 50.575037 0 0 0-18.524913-69.085501z" fill="#ffffff" p-id="2648"></path></svg><svg t="1590815914523" class="rv-image-mask-error" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3574" width="80" height="80"><path d="M441.23 511.44L79.4 149.62c-17.44-19.25-16.72-48.81 1.65-67.18 18.38-18.37 47.93-19.1 67.18-1.65l361.83 361.82L871.89 80.79a48.718 48.718 0 0 1 47.95-14.55 48.725 48.725 0 0 1 35.43 35.43 48.728 48.728 0 0 1-14.54 47.95L578.89 511.44l361.83 361.83a48.734 48.734 0 0 1 14.54 47.95 48.709 48.709 0 0 1-35.43 35.43 48.768 48.768 0 0 1-47.95-14.55L510.06 580.27 148.23 942.1c-19.25 17.44-48.8 16.72-67.18-1.65-18.37-18.37-19.09-47.93-1.65-67.18l361.83-361.83z" p-id="3575" fill="#ffffff"></path></svg></div></div><div class="rv-control"><div class="rv-bar"></div><div class="rv-slider">'+M.sliderIcon+"</div></div>"+e+"</div></div></div>",i=document.createElement("div");i.innerHTML=s,V("body").appendChild(i);var r,o,n=V(".rv-root"),a=V(".rv-bar"),l=V(".rv-slider"),c=V(".rv-close"),v=V(".rv-img"),d=V(".rv-control"),u=V(".rv-wrap"),f=V(".rv-mask"),m=V(".rv-image-mask"),h=V(".rv-image-mask-success"),p=V(".rv-image-mask-error"),g=V(".rv-extra"),w=a.offsetWidth-l.offsetWidth,x=0,y=R(),b=!1;R()?(l.ontouchstart=L,document.ontouchmove=r,document.ontouchend=z):(l.onmousedown=L,document.onmousemove=r,document.onmouseup=z),f.style["background-color"]="rgba(0, 0, 0,"+M.mask+")",f.style["z-index"]=M.zIndex,u.style["z-index"]=M.zIndex,v.style.transform="rotate("+C(M.tolerance)+"deg)",null!==M.extra&&void 0!==M.extra&&(g.style.color=M.extraColor);var k=E();function r(e){var t,s;b&&(e=e||window.event,s=(t=(y?e.touches[0].clientX:e.clientX)-o)/w*360,w<t?t=w:t<0?t=0:(l.style.left=t+"px",s=k+s,v.style.transform="rotate("+s+"deg)"))}function L(e){l.style.transition="",v.style.transition="",l.classList.add("rv-slider-normal");e=e||window.event;o=y?e.touches[0].clientX:e.clientX,b=!0}function z(){var e;l.classList.remove("rv-slider-normal"),b&&(B(360<(e=E())?e-=360:e)?(m.style.cssText="visibility: visible;opacity: 1",h.style.cssText="visibility: visible;opacity: 1",l.style["pointer-events"]="none",l.classList.add("rv-slider-success"),setTimeout(function(){x=1,n.parentNode.remove(),t(x)},M.duration)):(m.style.cssText="visibility: visible;opacity: 1",p.style.cssText="visibility: visible;opacity: 1",l.style["pointer-events"]="none",d.style.animation="shake .15s infinite",l.classList.add("rv-slider-error"),setTimeout(function(){v.src=T(M.album),m.style.cssText="",p.style.cssText="",l.classList.remove("rv-slider-error"),d.style.animation="",l.style.left=0,v.style.transform="rotate("+C(M.tolerance)+"deg)",k=E(),l.style.transition="background .2s ease-in-out,border-color .2s ease-in-out,box-shadow .2s ease-in-out,left .5s ease-in-out",v.style.transition="transform .5s ease-in-out",l.style["pointer-events"]=""},500),t(x)),b=!1)}c.onclick=function(){x=2,n.parentNode.remove(),t(x)},f.onclick=function(){1==M.maskClosable&&(x=2,n.parentNode.remove(),t(x))}};var V=function(e){return document.querySelector(e)};return"undefined"!=typeof window&&(window.RVerify=e),e});
\No newline at end of file