/*! * * typeit - the most versatile animated typing utility on the planet. * author: alex macarthur (https://macarthur.me) * version: v5.10.1 * url: https://typeitjs.com * license: gpl-2.0 * */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.typeit=e()}(this,function(){"use strict";function t(t){var e=t.getboundingclientrect();return!(e.right>window.innerwidth||e.bottom>window.innerheight)&&!(e.top<0||e.left<0)}function e(t,e){return math.abs(math.random()*(t+e-(t-e))+(t-e))}function i(t,e){return 0===t.indexof(e)}function n(t){return array.isarray(t)?t.slice(0):t.split("
")}window.typeitdefaults={strings:[],speed:100,deletespeed:null,lifelike:!0,cursor:!0,cursorchar:"|",cursorspeed:1e3,breaklines:!0,startdelay:250,startdelete:!1,nextstringdelay:750,loop:!1,loopdelay:!1,html:!0,autostart:!0,callback:!1,beforestring:!1,afterstring:!1,beforestep:!1,afterstep:!1,aftercomplete:!1};var s="function"==typeof symbol&&"symbol"==typeof symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof symbol&&t.constructor===symbol&&t!==symbol.prototype?"symbol":typeof t},o=function(t,e){if(!(t instanceof e))throw new typeerror("cannot call a class as a function")},r=function(){function t(t,e){for(var i=0;i/g,"")}),!(this.options.strings.length>=1&&""===this.options.strings[0])}},{key:"preparedom",value:function(){this.element.innerhtml='\n \n ',this.element.setattribute("data-typeitid",this.id),this.elementcontainer=this.element.queryselector("span")}},{key:"reset",value:function(){return new s(this.element,this.id,this.options,this.autoinit,this.typeit)}},{key:"contents",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return null===t?this.options.html?this.elementcontainer.innerhtml:this.elementcontainer.innertext:(this.elementcontainer[this.options.html?"innerhtml":"innertext"]=t,t)}},{key:"preparedelay",value:function(t){var e=this.options[t];if(e){var i=array.isarray(e),n=i?null:e/2;this.options[t]={before:i?e[0]:n,after:i?e[1]:n,total:i?e[0]+e[1]:e}}}},{key:"generatequeue",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e=null===e?[this.pause,this.options.startdelay]:e,this.queue.push(e),this.options.strings.foreach(function(e,i){if(t.queuestring(e),i+1!==t.options.strings.length){if(t.options.breaklines)return t.queue.push([t.break]),void t.insertsplitpause(t.queue.length);t.queuedeletions(e),t.insertsplitpause(t.queue.length,e.length)}})}},{key:"queuedeletions",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e="string"==typeof t?t.length:t,i=0;i1&&void 0!==arguments[1])||arguments[1];if(t){if(t=n(t),document.implementation.createhtmldocument("").body.innerhtml=t,e&&(t=(t=this.rake(t))[0]),this.options.html&&i(t[0],"<")&&!i(t[0],"/),o=document.implementation.createhtmldocument("");o.body.innerhtml="<"+s[1]+">",this.queue.push([this.type,o.body.children[0]])}else this.queue.push([this.type,t[0]]);t.splice(0,1),e&&this.queue[this.queue.length-1].push("first-of-string"),t.length?this.queuestring(t,!1):this.queue[this.queue.length-1].push("last-of-string")}}},{key:"insertsplitpause",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.queue.splice(t,0,[this.pause,this.options.nextstringdelay.before]),this.queue.splice(t-e,0,[this.pause,this.options.nextstringdelay.after])}},{key:"init",value:function(){if(!this.hasstarted){if(this.cursor(),this.options.autostart)return this.hasstarted=!0,void this.next();if(t(this.element))return this.hasstarted=!0,void this.next();var e=this;window.addeventlistener("scroll",function i(n){t(e.element)&&!e.hasstarted&&(e.hasstarted=!0,e.next(),n.currenttarget.removeeventlistener(n.type,i))})}}},{key:"cursor",value:function(){var t="visibility: hidden;";if(this.options.cursor){var e=document.createelement("style");e.id=this.id;var i="\n @keyframes blink-"+this.id+" {\n 0% {opacity: 0}\n 49% {opacity: 0}\n 50% {opacity: 1}\n }\n\n [data-typeitid='"+this.id+"'] .ti-cursor {\n animation: blink-"+this.id+" "+this.options.cursorspeed/1e3+"s infinite;\n }\n ";e.appendchild(document.createtextnode(i)),document.head.appendchild(e),t=""}this.element.insertadjacenthtml("beforeend",''+this.options.cursorchar+"")}},{key:"insert",value:function(t){arguments.length>1&&void 0!==arguments[1]&&arguments[1]?this.elementcontainer.lastchild.insertadjacenthtml("beforeend",t):this.elementcontainer.insertadjacenthtml("beforeend",t),this.contents(this.contents().split("").join(""))}},{key:"preparetargetelement",value:function(){var t=this;[].slice.call(this.element.childnodes).foreach(function(e){void 0!==e.classlist&&e.classlist.contains("ti-container")&&(t.element.innerhtml="")}),!this.options.startdelete&&this.element.innerhtml.length>0?this.options.strings=this.element.innerhtml.trim():this.stringstodelete=this.element.innerhtml}},{key:"break",value:function(){this.insert("
"),this.next()}},{key:"pause",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];settimeout(function(){t.next()},e||this.options.nextstringdelay.total)}},{key:"rake",value:function(t){var e=this;return t.map(function(t){return t=t.split(""),e.options.html?function(t){for(var e=[],i=void 0,n=!1,s=0;s"===t[s]||";"===t[s]&&n)&&(e[1]=s,s=0,i=t.slice(e[0],e[1]+1).join(""),t.splice(e[0],e[1]-e[0]+1,i),n=!1);return t}(t):t})}},{key:"type",value:function(t){var e=this;this.setpace(),this.timeouts[0]=settimeout(function(){return"string"!=typeof t?(t.innerhtml="",e.elementcontainer.appendchild(t),e.isintag=!0,void e.next()):i(t,"1&&void 0!==arguments[1]?arguments[1]:null,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n={};for(var s in null===e&&(e=this.options),e)n[s]=e[s];for(var o in t)n[o]=t[o];this.options=n,i&&this.next()}},{key:"setpace",value:function(){var t=this.options.speed,i=null!==this.options.deletespeed?this.options.deletespeed:this.options.speed/3,n=t/2,s=i/2;this.typepace=this.options.lifelike?e(t,n):t,this.deletepace=this.options.lifelike?e(i,s):i}},{key:"delete",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.timeouts[1]=settimeout(function(){t.setpace();for(var i=t.contents().split(""),n=i.length-1;n>-1;n--){if(">"!==i[n]&&";"!==i[n]||!t.options.html){i.pop();break}for(var s=n;s>-1;s--){if("
"===i.slice(s-3,s+1).join("")){i.splice(s-3,4);break}if("&"===i[s]){i.splice(s,n-s+1);break}if("<"===i[s]&&">"!==i[s-1]){if(";"===i[s-1])for(var o=s-1;o>-1;o--)if("&"===i[o]){i.splice(o,s-o);break}i.splice(s-1,1);break}}break}if(t.options.html&&t.contents().indexof(">-1)for(var r=t.contents().indexof(">=0;r--)if("<"===i[r]){i.splice(r,i.length-r);break}t.contents(i.join("").replace(/<[^\/>][^>]*><\/[^>]+>/,"")),null===e&&t.queue.unshift([t.delete,i.length]),e>1&&t.queue.unshift([t.delete,e-1]),t.next()},this.deletepace)}},{key:"empty",value:function(){this.contents(""),this.next()}},{key:"next",value:function(){var t=this;if(!this.isfrozen){if(this.queue.length>0)return this.step=this.queue.shift(),"first-of-string"===this.step[2]&&this.options.beforestring&&this.options.beforestring(this.step,this.queue,this.typeit),this.options.beforestep&&this.options.beforestep(this.step,this.queue,this.typeit),this.step[0].call(this,this.step[1],this.step[2]),"last-of-string"===this.step[2]&&this.options.afterstring&&this.options.afterstring(this.step,this.queue,this.typeit),void(this.options.afterstep&&this.options.afterstep(this.step,this.queue,this.typeit));if(this.options.callback&&this.options.callback(),this.options.aftercomplete&&this.options.aftercomplete(this.typeit),this.options.loop){var e=this.options.loopdelay?this.options.loopdelay:this.options.nextstringdelay;return this.queuedeletions(this.contents()),this.generatequeue([this.pause,e.before]),void settimeout(function(){t.next()},e.after)}this.iscomplete=!0}}}]),s}();return function(){function t(e,i){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];o(this,t),this.id=math.random().tostring(36).substring(2,15),this.instances=[],this.elements=[],this.args=i,this.autoinit=n,"object"===(void 0===e?"undefined":s(e))&&(void 0===e.length?this.elements.push(e):this.elements=e),"string"==typeof e&&(this.elements=document.queryselectorall(e)),this.generateinstances()}return r(t,[{key:"generateinstances",value:function(){var t=this;[].slice.call(this.elements).foreach(function(e){t.instances.push(new u(e,t.id,t.args,t.autoinit,t))})}},{key:"queueup",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.instances.foreach(function(i){i.queue.push([i[t],e]),!0===i.iscomplete&&i.next()})}},{key:"type",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.instances.foreach(function(e){e.queuestring(t),!0===e.iscomplete&&e.next()}),this}},{key:"delete",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.queueup("delete",t),this}},{key:"pause",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.queueup("pause",t),this}},{key:"empty",value:function(){return this.queueup("empty"),this}},{key:"break",value:function(){return this.queueup("break"),this}},{key:"options",value:function(t){return this.queueup("setoptions",t),this}},{key:"freeze",value:function(){this.instances.foreach(function(t){t.isfrozen=!0})}},{key:"unfreeze",value:function(){this.instances.foreach(function(t){t.isfrozen&&(t.isfrozen=!1,t.next())})}},{key:"destroy",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.instances.foreach(function(e){e.timeouts.foreach(function(t){cleartimeout(t)}),e.timeouts=[],t&&e.options.cursor&&e.element.removechild(e.element.queryselector(".ti-cursor")),e.hasbeendestroyed=!0})}},{key:"reset",value:function(){this.instances=this.instances.map(function(t){return t.reset()})}},{key:"init",value:function(){this.instances.foreach(function(t){t.init()})}},{key:"iscomplete",get:function(){return!!this.instances.length&&this.instances[0].iscomplete}},{key:"hasbeendestroyed",get:function(){return!!this.instances.length&&this.instances[0].hasbeendestroyed}},{key:"hasstarted",get:function(){return!!this.instances.length&&this.instances[0].hasstarted}},{key:"isfrozen",get:function(){return!!this.instances.length&&this.instances[0].isfrozen}}]),t}()});