forked from usablica/intro.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintro.min.js
1 lines (1 loc) · 3.91 KB
/
intro.min.js
1
(function(){function t(e){this._targetElement=e}function n(e){var t=e.querySelectorAll("*[data-intro]"),n=[],o=this;if(t.length<1){return}for(var a=0,f=t.length;a<f;a++){var l=t[a];n.push({element:l,intro:l.getAttribute("data-intro"),step:parseInt(l.getAttribute("data-step"))})}n.sort(function(e,t){return e.step-t.step});o._introItems=n;if(u(e)){r.call(o);var c=e.querySelector(".introjs-skipbutton"),h=e.querySelector(".introjs-nextbutton");e.onkeydown=function(t){if(t.keyCode==27){s(e)}if([37,39].indexOf(t.keyCode)>=0){if(t.keyCode==37){i.call(o)}else if(t.keyCode==39){r.call(o)}}}}return false}function r(){if(this._currentStep==undefined){this._currentStep=0}else{++this._currentStep}if(this._introItems.length<=this._currentStep){s(this._targetElement);return}o.call(this,this._introItems[this._currentStep].element)}function i(){if(this._currentStep==0)return;o.call(this,this._introItems[--this._currentStep].element)}function s(e){var t=e.querySelector(".introjs-overlay");t.style.opacity=0;setTimeout(function(){t.parentNode.removeChild(t)},500);var n=e.querySelector(".introjs-helperLayer");n.parentNode.removeChild(n);var r=document.querySelector(".introjs-showElement");r.className=r.className.replace(/introjs-showElement/,"").trim();e.onkeydown=null}function o(e){var t=this,n=document.querySelector(".introjs-helperLayer"),i=a(e);if(n!=null){var o=n.querySelector(".introjs-helperNumberLayer"),u=n.querySelector(".introjs-tooltiptext"),f=n.querySelector(".introjs-tooltip");n.setAttribute("style","width: "+(i.width+10)+"px; "+"height:"+(i.height+10)+"px; "+"top:"+(i.top-5)+"px;"+"left: "+(i.left-5)+"px;");o.innerHTML=e.getAttribute("data-step");u.innerHTML=e.getAttribute("data-intro");var l=document.querySelector(".introjs-showElement");l.className=l.className.replace(/introjs-showElement/,"").trim();e.className+=" introjs-showElement";setTimeout(function(){f.style.bottom="-"+(a(f).height+10)+"px"},300)}else{e.className+=" introjs-showElement";var c=document.createElement("div"),h=document.createElement("span"),p=document.createElement("div");c.className="introjs-helperLayer";c.setAttribute("style","width: "+(i.width+10)+"px; "+"height:"+(i.height+10)+"px; "+"top:"+(i.top-5)+"px;"+"left: "+(i.left-5)+"px;");document.body.appendChild(c);h.className="introjs-helperNumberLayer";p.className="introjs-tooltip";h.innerHTML=e.getAttribute("data-step");p.innerHTML="<div class='introjs-tooltiptext'>"+e.getAttribute("data-intro")+"</div><div class='introjs-tooltipbuttons'></div>";c.appendChild(h);c.appendChild(p);var d=document.createElement("a");d.className="introjs-skipbutton";d.href="javascript:void(0);";d.innerHTML="Skip";var v=document.createElement("a");v.onclick=function(){r.call(t)};v.className="introjs-nextbutton";v.href="javascript:void(0);";v.innerHTML="Next →";d.onclick=function(){s(t._targetElement)};var m=p.querySelector(".introjs-tooltipbuttons");m.appendChild(d);m.appendChild(v);p.style.bottom="-"+(a(p).height+10)+"px"}if(typeof e.scrollIntoViewIfNeeded==="function"){e.scrollIntoViewIfNeeded()}}function u(e){var t=document.createElement("div"),n="";t.className="introjs-overlay";var r=a(e);if(r){n+="width: "+r.width+"px; height:"+r.height+"px; top:"+r.top+"px;left: "+r.left+"px;";t.setAttribute("style",n)}e.appendChild(t);t.onclick=function(){s(e)};setTimeout(function(){n+="opacity: .5;";t.setAttribute("style",n)},10);return true}function a(e){var t={};t.width=e.offsetWidth;t.height=e.offsetHeight;var n=0;var r=0;while(e&&!isNaN(e.offsetLeft)&&!isNaN(e.offsetTop)){n+=e.offsetLeft;r+=e.offsetTop;e=e.offsetParent}t.top=r;t.left=n;return t}var e="0.1.0";var f=function(e){if(typeof e==="object"){return new t(e)}else if(typeof e==="string"){var n=document.querySelector(e);if(n){return new t(n)}else{throw new Error("There's no element with given selector.")}}else{return new t(document.body)}};f.version=e;f.fn=t.prototype={clone:function(){return t(this)},start:function(){return n.call(this,this._targetElement)}};this["introJs"]=f})()