canvas-tablet
Version:
Tablet是一个轻量级的基于canvas的在线画板,无其他依赖,`传统网站`或`vue`、`react`、`angular`等单页面应用皆可使用!兼容各种移动设备!
7 lines (6 loc) • 19 kB
JavaScript
!function(){"use strict";
/*!
* Tablet
* Tablet是一个轻量级的基于canvas的在线画板,无其他依赖,传统网站或vue、react、angular等单页面应用皆可使用!兼容各种移动设备!
* github: https://github.com/941477276/Tablet
*/!function(t){if("function"==typeof define&&define.amd)define(t);else if("object"==typeof module&&module.exports)module.exports=t(require());else{window.Tablet=t();try{"function"==typeof define&&define((function(e){return t(e())}))}catch(t){}}}((function(){function t(t,e,i,n){this.ctx=t,this.ctxBack=e,this.lineConfig=i||{},this.bgConfig=n||{},this.backuped=!1,this.points=[]}function e(t){this.tablet=t.tablet,this.type=t.type,this.linesIndex=void 0===t.linesIndex?-1:t.linesIndex,this.lines=[].concat(t.lines),this.lineConfig=t.lineConfig?n.objectCopy({},t.lineConfig):null,this.bgConfig=t.bgConfig?n.objectCopy({},t.bgConfig):null}function i(t,e){this._init(t,e),this._ctxInit()}t.prototype.draw=function(t,e,i,n){t=void 0===t?1:parseFloat(t),e=void 0===e?1:parseFloat(e),t=t>0?t:1,e=e>0?e:1,i=void 0!==i&&!!i;var o=this.lineConfig,s=i?this.ctxBack:this.ctx;for(var h in s.beginPath(),o)s[h]=o[h];if(s.lineWidth=o.lineWidth*Math.min(t,e),1==this.points.length){var r=this.points[0],a=r.x*t,l=r.y*e;return s.moveTo(a,l),s.lineTo(a,l),void s.stroke()}this.points.forEach((function(i,n){var o=i.x*t,h=i.y*e;s[n>0?"lineTo":"moveTo"](o,h),n>0&&s.stroke()}))},t.prototype.addPoint=function(t,e){this.points.push({x:t,y:e})},e.prototype.exec=function(){var t=this,e=this.tablet,i=(e.ctx,this.tablet.ctxBack),n=function(i){i=void 0!==i&&!!i,t.lines.forEach((function(n){n&&n.draw(e.widthZoomRate,e.heightZoomRate,i,t.tablet.devicePixelRatio)}))},o=function(t){"color"==t.bgType?e.setBackgroundColor(t.bgColor,t.x,t.y,t.width,t.height,!1):"img"==t.bgType&&e.setBackgroundImage(t.bgImg,t.x,t.y,t.width,t.height,null,null,!1)};this.tablet.devicePixelRatio;switch(this.type){case"drawLine":case"bgColor":case"bgImg":i.clearRect(0,0,e.width,e.height),n(!0),o(t.bgConfig)}},i._conut=0,i.prototype._init=function(t,e){var o,s=this;if("string"==typeof t?o=document.querySelector(t):"object"==typeof t&&1==t.nodeType&&(o=t),!o)throw new Error("el参数必须是一个css选择器或dom元素!");this.config={response:!0,width:0,height:0,extraClass:"",defaultColor:"#000",defaultBackgroundColor:"transparent",defaultBgType:"color",defaultBgImg:null,defaultHeight:400,autoResize:!0,imgType:"png",onInit:function(){},onBeforeClear:function(){},onClear:function(){}},e&&"object"===n.getType(e)&&n.objectCopy(this.config,e),this.container=o,this.id="Tablet_LYN_"+i._conut++,this.devicePixelRatio=window.devicePixelRatio||1,this.isMobile=/phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone/i.test(navigator.userAgent),this.lineConfig={strokeStyle:this.config.defaultColor,lineWidth:8,lineWidthZoomRate:1,lineCap:"round",lineJoin:"round",shadowBlur:0,shadowColor:this.config.defaultColor},this.bgConfig={bgColor:this.config.defaultBackgroundColor,bgImg:this.config.bgImg,bgType:this.config.bgType,x:0,y:0,width:-1,height:-1};var h=document.createElement("div");h.className="yn-canvas-tablet",h.id=this.id;var r=document.createElement("canvas");r.className="yn-tablet-canvas",r.style.cursor="crosshair",r.style.display="none";var a=document.createElement("canvas");a.className="yn-tablet-backup-canvas",a.style.display="none",h.appendChild(r),h.appendChild(a),this.container.appendChild(h),this.canvas=r,this.ctx=this.canvas.getContext("2d"),this.canvasBack=a,this.ctxBack=this.canvasBack.getContext("2d"),this.point={x:0,y:0},this.lines=[],this.operationRecords=[],this.degree=0,this.version="2.0.6","function"==typeof this.config.width?this.width=this.config.width():this.width=this.config.width,"function"==typeof this.config.height?this.height=this.config.height():this.height=this.config.height;var l=n.getDocumentWidthHeight();if(this.isMobile){var c=this.lineConfig;delete c.shadowBlur,delete c.shadowColor,l>=768?c.lineWidth=8:l<768&&l>=414?c.lineWidth=6:l<414&&l>=375?c.lineWidth=4:l<375&&l>=320&&(c.lineWidth=2)}this.setCanvasWH(this.width,this.height),this.widthOrigin=this.width,this.heightOrigin=this.height,this.widthZoomRate=1,this.heightZoomRate=1,n.setCss(this.canvas,"display","block"),this.config.autoResize&&(this._removeResizeEventFn=this._bindResizeEvent()),n.on(h,"DOMNodeRemoved",(function(){s.destroy()})),this.config.onInit&&"function"==typeof this.config.onInit&&this.config.onInit.call(this)},i.prototype._ctxInit=function(){var i=this,o=(this.pressed=!1,function(e){return function(o){if(o.preventDefault(),1===e&&(i.pressed=!0),1===e||i.pressed){o=i.isMobile?o.touches[0]:o;var s=n.offset(i.canvas),h=n.scrollTop(),r=n.scrollLeft();i.point.x=o.clientX-(s.left+.5-r),i.point.y=o.clientY-(s.top+.5-h),function(e){switch(e){case 1:i.ctx.beginPath(),i.ctx.moveTo(i.point.x,i.point.y),i.lines.push(new t(i.ctx,i.ctxBack,n.objectCopy({},i.lineConfig),n.objectCopy({},i.bgConfig)));case 2:i.ctx.lineWidth=i.lineConfig.lineWidth*i.lineConfig.lineWidthZoomRate,i.ctx.lineTo(i.point.x,i.point.y),i.ctx.stroke(),i.lines[i.lines.length-1].addPoint(i.point.x/i.widthZoomRate,i.point.y/i.heightZoomRate)}}(e)}}}),s=i.lineConfig;for(var h in s)i.ctx[h]=s[h],i.ctxBack[h]=s[h];i.isMobile||(i.ctx.shadowBlur=s.shadowBlur,i.ctx.shadowColor=s.shadowColor,i.ctxBack.shadowBlur=s.shadowBlur,i.ctxBack.shadowColor=s.shadowColor);var r,a=o(1),l=o(2),c=(window.requestAnimationFrame,function(){if(i.pressed=!1,i.lines.length>0){var t=i.lines[i.lines.length-1];t&&!t.backuped&&(t.draw(0,0,!0,i.devicePixelRatio),t.backuped=!0)}}),g=function(){i.pressed=!1,i.lines.length>0&&i.operationRecords.push(new e({type:"drawLine",tablet:i,lines:i.lines,bgConfig:i.bgConfig,linesIndex:i.lines.length-1}))};"color"==(r={bgType:this.config.defaultBgType,bgColor:this.config.defaultBackgroundColor,bgImg:this.config.defaultBgImg}).bgType?i.setBackgroundColor(r.bgColor,-1,-1,-1,-1,!1):"img"==r.bgType&&i.setBackgroundImage(r.bgImg,-1,-1,-1,-1,null,null,!1);var d=this.canvas;this.isMobile?(n.on(d,"touchstart",a),n.on(d,"touchmove",l)):(n.on(d,"mousedown",a),n.on(d,"mousemove",l)),["touchend","mouseleave","mouseup"].forEach((function(t,e){n.on(d,t,c)})),["touchend","mouseup"].forEach((function(t,e){n.on(d,t,g)}))},i.prototype._bindResizeEvent=function(){var t="resize",e=this,i=0;t+=window.onorientationchange?" orientationchange":"";var o=function(){var t=(new Date).getTime();(0==i||t-i>100)&&(i=t,e.setCanvasWH(),e.refresh())};return n.on(window,t,o),function(){n.off(window,t,o)}},i.prototype.refresh=function(t){var e=this;(t=void 0!==t&&!!t)&&this.setCanvasWH();var i=e.width/e.widthOrigin,n=e.height/e.heightOrigin,o=e.bgConfig,s=function(){"color"==o.bgType?e.setBackgroundColor(o.bgColor,o.x,o.y,o.width,o.height,!1):"img"==o.bgType&&e.setBackgroundImage(o.bgImg,o.x,o.y,o.width,o.height,null,null,!1)};return e.lineConfig.lineWidthZoomRate=Math.min(i,n),e.widthZoomRate=i,e.heightZoomRate=n,e.hasCanUseLine()?(e.ctxBack.clearRect(0,0,e.width,e.height),e.ctx.clearRect(0,0,e.width,e.height),e.lines.forEach((function(t){t&&t.draw(i,n,!0,e.devicePixelRatio)})),"color"==o.bgType&&"transparent"==o.bgColor?(e.ctx.save(),e.ctx.shadowBlur=0,e.ctx.drawImage(e.canvasBack,0,0,e.width*devicePixelRatio,e.height*devicePixelRatio,0,0,e.width,e.height),e.ctx.restore(),this):(s(),this)):(e.canvasReset(),s(),this)},i.prototype.getRect=function(){var t=this.width,e=this.height;90!=this.degree&&-90!=this.degree||(t=this.height,e=this.width);var i=n.offset(this.canvas);return{x:i.left,y:i.top,width:t,height:e}},i.prototype.hasCanUseLine=function(){return this.lines.some((function(t){return!!t}))},i.prototype.setColor=function(t){var e=this;return e.ctx.beginPath(),t?(e.lineConfig.strokeStyle=t,e.ctx.strokeStyle=t,e.ctxBack.strokeStyle=t,e.isMobile||(e.lineConfig.shadowColor=t,e.ctx.shadowColor=t,e.ctxBack.shadowColor=t),this):this},i.prototype.setLineWidth=function(t){var e=this;return t=parseFloat(t),isNaN(t)||(e.lineConfig.lineWidth=t,e.ctx.beginPath(),e.ctxBack.beginPath(),e.ctx.lineWidth=t,e.ctxBack.lineWidth=t),this},i.prototype.setBackgroundColor=function(t,i,n,o,s,h){var r=this.getRect(),a=o>0?o:r.width,l=s>0?s:r.height,c=this.devicePixelRatio;i=i>0?i:0,n=n>0?n:0,this.bgConfig.bgType="color",this.bgConfig.bgColor=t,this.bgConfig.bgImg=null,this.bgConfig.x=i,this.bgConfig.y=n,this.bgConfig.width=o,this.bgConfig.height=s;var g=this.ctx;return g.clearRect(i,n,a,l),g.fillStyle=t,g.save(),g.shadowBlur=0,g.fillRect(i,n,a,l),this.hasCanUseLine()&&this.ctx.drawImage(this.canvasBack,i,n,a*c,l*c,i,n,a,l),g.restore(),(h=void 0===h)&&this.operationRecords.push(new e({type:"bgColor",tablet:this,lines:this.lines,bgConfig:this.bgConfig})),this},i.prototype.setBackgroundImage=function(t,i,n,o,s,h,r,a){if(!t)return!1;var l=this,c=this.devicePixelRatio,g=function(){var r=l.getRect();i=i>0?i:0,n=n>0?n:0;var g=o>0?o:r.width,d=s>0?s:r.height,f=l.ctx;l.bgConfig.bgType="img",l.bgConfig.bgImg=t,l.bgConfig.bgColor="",l.bgConfig.x=i,l.bgConfig.y=n,l.bgConfig.width=o,l.bgConfig.height=s,"function"==typeof h&&h({statusCode:2,status:"ok",img:t}),f.clearRect(i,n,g,d),f.save(),f.shadowBlur=0,f.drawImage(t,i,n,g,d),l.hasCanUseLine()&&f.drawImage(l.canvasBack,i,n,g*c,d*c,i,n,g,d),f.restore(),(a=void 0===a)&&l.operationRecords.push(new e({type:"bgImg",tablet:l,lines:l.lines,bgConfig:l.bgConfig}))},d=function(){"function"==typeof r&&r()};if("string"==typeof t){"function"==typeof h&&h({statusCode:1,status:"loading"});var f=t;(t=new Image).onload=g,t.onerror=d,t.src=f}else t.complete?g():(t.onload=g,t.onerror=d)},i.prototype.setCanvasWH=function(t,e){if(t&&e){if(t==this.width&&e==this.height)return this;this.width=t,this.height=e}else{var i=this.container,o=parseFloat(n.getStyle(i,"border-left-width")),s=parseFloat(n.getStyle(i,"border-right-width")),h=parseFloat(n.getStyle(i,"border-top-width")),r=parseFloat(n.getStyle(i,"border-bottom-width")),a=parseFloat(n.getStyle(i,"padding-left")),l=parseFloat(n.getStyle(i,"padding-right")),c=parseFloat(n.getStyle(i,"padding-top")),g=parseFloat(n.getStyle(i,"padding-bottom")),d=i.offsetWidth-o-s-a-l,f=i.offsetHeight-h-r-c-g;if(d==this.width&&f==this.height)return this;this.width=i.offsetWidth-o-s-a-l,this.height=i.offsetHeight-h-r-c-g}var u=this.canvas,p=this.canvasBack,v=this.ctx,w=this.ctxBack,m=this.lineConfig,b=this.devicePixelRatio=window.devicePixelRatio||1;if(b&&b>1){var y=this.width*b,C=this.height*b;n.setCss(u,"width",this.width),n.setCss(u,"height",this.height),n.setCss(p,"width",this.width),n.setCss(p,"height",this.height),u.width=y,u.height=C,p.width=y,p.height=C,v.scale(b,b),w.scale(b,b),v.clearRect(0,0,y,C),w.clearRect(0,0,y,C)}else u.width=this.width,u.height=this.height,p.width=this.width,p.height=this.height,v.clearRect(0,0,this.width,this.height),w.clearRect(0,0,this.width,this.height);for(var x in m)v[x]=m[x],w[x]=m[x];return this},i.prototype.canvasReset=function(){var t=this,e=this.lineConfig;for(var i in e)t.ctx[i]=e[i],t.ctxBack[i]=e[i];return t.isMobile||(t.ctx.shadowBlur=e.shadowBlur,t.ctx.shadowColor=e.shadowColor,t.ctxBack.shadowBlur=e.shadowBlur,t.ctxBack.shadowColor=e.shadowColor),this},i.prototype.revoke=function(){var t=this.operationRecords,e=this;if(0==t.length)return this;var i,n=t.length-1,o=t.splice(n,1);if(o[0].linesIndex>-1&&this.removeLine(o[0].linesIndex),0==t.length){this.ctx.clearRect(0,0,this.width,this.height),this.ctxBack.clearRect(0,0,this.width,this.height);return"color"==(i={bgType:this.config.defaultBgType,bgColor:this.config.defaultBackgroundColor,bgImg:this.config.defaultBgImg}).bgType?e.setBackgroundColor(i.bgColor,-1,-1,-1,-1,!1):"img"==i.bgType&&e.setBackgroundImage(i.bgImg,-1,-1,-1,-1,null,null,!1),this}return t[n-1].exec(),this},i.prototype.clear=function(t){var e=this.width,i=this.height;if((t=void 0!==t&&!!t,this.config.onBeforeClear&&"function"==typeof this.config.onBeforeClear)&&!1===this.config.onBeforeClear.call(this))return this;return 90!=this.degree&&-90!=this.degree||(e=this.height,i=this.width),this.ctx.clearRect(0,0,e,i),this.ctxBack.clearRect(0,0,e,i),t&&(this.operationRecords=[],this.lines=[]),this.config.onClear&&"function"==typeof this.config.onClear&&this.config.onClear.call(this),this},i.prototype.removeLine=function(t){var e=this.lines;if("number"==typeof t)e.splice(t,1,null);else if("object"==typeof t){for(var i=-1,n=0,o=e.length;n<o;n++)if(e[n]==t){i=n;break}e.splice(i,1,null)}return this},i.prototype.getBase64=function(t,e){if(t){var i=t.toLowerCase();"png"===i?t="image/png":"jpg"!==i&&"jpeg"!==i||(t="image/jpg")}else t="image/png";var n="";if(e){var o=this.width,s=this.height,h=this.devicePixelRatio;h&&h>1&&(o*=h,s*=h),-90===e&&(e=270);var r=e*Math.PI/180,a=e/90%4,l=document.createElement("canvas"),c=l.getContext("2d");0===a?(l.width=o,l.height=s,c.drawImage(this.canvas,0,0)):1===a?(l.width=s,l.height=o,c.translate(.5*l.width,.5*l.height),c.rotate(r),c.drawImage(this.canvas,-l.height/2,-l.width/2)):2===a?(l.width=o,l.height=s,c.translate(.5*o,.5*s),c.rotate(r),c.drawImage(this.canvas,-l.width/2,-l.height/2)):3===a&&(l.width=s,l.height=o,c.translate(.5*l.width,.5*l.height),c.rotate(r),c.drawImage(this.canvas,-l.height/2,-l.width/2)),n=l.toDataURL(t,1),l=null,c=null}else n=this.canvas.toDataURL(t,1);return n},i.prototype.getBlob=function(t,e){for(var i=this.getBase64(t,e).split(","),n=i[0].match(/:(.*?);/)[1],o=atob(i[1]),s=o.length,h=new Uint8Array(s);s--;)h[s]=o.charCodeAt(s);return new Blob([h],{type:n})},i.getMax=function(t,e){var i={left:0,right:0,top:0,bottom:0};return"[object Array]"!=={}.toString.call(t)||"[object Array]"!=={}.toString.call(e)||(i.left=Math.min.apply(null,t),i.right=Math.max.apply(null,t),i.top=Math.min.apply(null,e),i.bottom=Math.max.apply(null,e)),i},i.prototype.getTabletImageColors=function(){for(var t=this.ctx.getImageData(0,0,this.canvas.width,this.canvas.height).data,e={},i=function(t){if(t in e)return e[t];var i=t.toString(16);return 1==i.length&&(i="0"+i),e[t]=i,i},n={},o=function(t,e,o,s){var h=t+"_"+e+"_"+o+"_"+s;if(h in n)return n[h];var r=[];r.push(i(t)),r.push(i(e)),r.push(i(o)),r.push(i(s));var a=r.join("");return n[h]=a,a},s={},h=0;h<t.length;h+=4){var r=o(t[h],t[h+1],t[h+2],t[h+3]);s[r]?s[r]++:s[r]=1}return s},i.prototype.hasContent=function(t,e){var i=this.hasCanUseLine(),n=this.getTabletImageColors();if(t||(t=5),e||(e=2),!i){var o={},s=0;for(var h in n){var r=n[h];r>t&&(o[h]=r,s++)}return s>=e}return!0},i.prototype.destroy=function(){var t=this.canvas,e=this.canvasBack;n.setCss(t,"cursor","default"),["touchend","mouseleave","mouseup","touchstart","touchmove","mousedown","mousemove","touchend","mouseup"].forEach((function(i,o){n.off(t,i),n.off(e,i)})),t=this.canvas=null,this.ctx=null,e=this.canvasBack=null,this.ctxBack=null,this.tabletEl=null,this.container=null,this.lines=[],this.operationRecords=[],"function"==typeof this._removeResizeEventFn&&(this._removeResizeEventFn(),this._removeResizeEventFn=null)};var n={getDocumentWidthHeight:()=>null!=window.innerHeight?{width:window.innerWidth,height:window.innerHeight}:"CSS1Compat"===document.compatMode?{width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight}:{width:document.body.scrollWidth,height:document.body.scrollHeight},offset(t){var e={top:0,left:0},i=t.offsetParent;for(e.top=t.offsetTop,e.left=t.offsetLeft;null!=i;)e.top+=i.offsetTop,e.left+=i.offsetLeft,i=i.offsetParent;return e},scrollTop:()=>window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,scrollLeft:()=>window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0,hasClass(t,e){if(t&&t.nodeName&&e){if(t.classList)return t.classList.contains(e);for(var i=!1,n=t.className.split(" "),o=0,s=n.length;o<s;o++)if(n[o]===e){i=!0;break}return i}},getStyle(t,e){if(t&&t.nodeName&&e){var i="";return window.getComputedStyle?i=window.getComputedStyle(t,null)[e]:t.currentStyle&&(i=t.currentStyle[e]),isNaN(parseFloat(i))?i:parseFloat(i)}},setCss(t,e,i){if(t&&t.nodeName){var n={}.toString.call(e),o={width:1,height:1,margin:1,padding:1,borderRadius:1,top:1,left:1,marginLeft:1,marginRight:1,marginTop:1,marginBottom:1,right:1,bottom:1,paddingLeft:1,paddingRight:1,paddingTop:1,paddingBottom:1,borderTopLeftRadius:1,borderTopRightRadius:1,borderBottomLeftRadius:1,borderBottomRightRadius:1,fontSize:1,lineHeight:1,textIndent:1,minWidth:1,maxWith:1};if("[object String]"===n&&void 0!==i)(e=e.replace(/\-(\w)/g,(function(t,e){return e.toUpperCase()})))in o&&!isNaN(Number(i))?t.style[e]=i+"px":t.style[e]=i;else if("[object Object]"===n){var s=t.style;for(var h in e){var r=e[h],a=Number(r);(h=h.replace(/\-(\w)/g,(function(t,e){return e.toUpperCase()})))in o&&!isNaN(a)?s[h]=r+"px":s[h]=r}}return this}},on:function(t,e,i){if(!t)return this;if(!e||"string"!=typeof e)return this;if(!i||"function"!=typeof i)return this;if(t._events||(t._events={}),e in t._events){var n=this.getIndex(t._events[e],(function(t){return t===i}));(n<0||void 0===n)&&t._events[e].push(i)}else if(t._events[e]=[i],document.addEventListener){var o=function(i){var n=t._events[e];if(n&&n.length>0)for(var o=0,s=n.length;o<s;o++)n[o]&&n[o].call(t,i)};t.addEventListener(e,o,!1),t._events[e+"_fn"]=o}else if(window.attachEvent){o=function(){var i=t._events[e],n=window.event;n.preventDefault=function(){n.returnValue=!1},n.stopPropagation=function(){n.cancelBubble=!0};for(var o=0,s=i.length;o<s;o++)i[o].call(t,n)};t.attachEvent("on"+e,o),t._events[e+"_fn"]=o}return this},off:function(t,e,i){if(t&&e&&"string"==typeof e){if(!t._events)return this;if(!e)return this;var n=t._events[e],o=t._events[e+"_fn"];if(e&&!i)document.removeEventListener?t.removeEventListener(e,o,!1):window.detachEvent&&t.detachEvent("on"+e,o),delete t._events[e],delete t._events[e+"_fn"];else if(e&&i){if(!n)return;if(document.removeEventListener)(s=this.getIndex(n,(function(t){return t===i})))>-1&&n.splice(s,1),0===n.length&&(delete t._events[e],delete t._events[e+"_fn"]);else if(window.detachEvent){if(!n)return;var s;(s=this.getIndex(n,(function(t){return t===i})))>-1&&n.splice(s,1),0===n.length&&(delete t._events[e],delete t._events[e+"_fn"])}}return n=null,this}},getIndex(t,e){if(!t||0===t.length||!e||"function"!=typeof e)return-1;if(t.findIndex)return t.findIndex(e);for(var i=t.length,n=0,o=-1;n<i;n++){if(!0===e(t[n],o,t)){o=n;break}}return o},objectCopy(t,e){if(Array.isArray(e))for(var i=0,o=e.length;i<o;i++){var s=e[i];t[i]="object"==typeof s&&s?n.objectCopy(Array.isArray(s)?[]:{},s):s}else for(var h in e){s=e[h];t[h]="object"==typeof s&&s?n.objectCopy(Array.isArray(s)?[]:{},s):s}return t},isEmptyObject(t){for(var e in t)return!1;return!0},parents(t,e){if(t&&t.nodeName&&e)for(var i=e.split(" "),n=t.parentElement;n;){for(var o=!0,s=0,h=i.length;s<h;s++)if(!this.hasClass(n,i[s])){o=!1;break}if(o)return n;n=n.parentElement}},getType:function(t){return null==t?t+"":"object"==typeof t||"function"==typeof t?{}[toString.call(t)]||"object":typeof t}};return i}))}();