text: /*! jquery.oekaki v0.1.1 | (c) 2016 kamem | https://github.com/kamem/jquery.oekaki.git */
  !function(e,t){"undefined"!=typeof exports?module.exports=t(require("jquery"),e):"function"==typeof define&&define.amd?define(["jquery"],function(){t($,e)}):t($,e)}("undefined"!=typeof window?window:this,function(e,t){!function(){var t,n={},a={},i={};n=function(e){function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),a=function(){function e(){t(this,e),this.width=300,this.height=300,this.layerNum=1}return n(e,[{key:"createNewLayer",value:function(e){}},{key:"setLayers",value:function(e){this.canvas=e}},{key:"setLayer",value:function(e){var t=e.layerNum,n=void 0===t?1:t;this.layerNum=n;var a=this.canvas.length-n;this.canvas[a].width=this.width,this.canvas[a].height=this.height,this.ctx=this.canvas[a].getContext("2d")}},{key:"setG",value:function(e){this.ctx=e}}]),e}();e.stage=new a;return e}(n),a=function(e,t){function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0}),e.Oekaki=void 0;var a=function(){function e(e,t){var n=[],a=!0,i=!1,r=void 0;try{for(var o,s=e[Symbol.iterator]();!(a=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);a=!0);}catch(c){i=!0,r=c}finally{try{!a&&s["return"]&&s["return"]()}finally{if(i)throw r}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}();e.Oekaki=function(){function e(t){var a=t.strokeStyle,i=t.lineWidth;n(this,e),this.strokeStyle=a,this.lineWidth=i,this.startX=0,this.startY=0,this.x=0,this.y=0,this.isDrawing=!1,this.lines=[],this.repeatSpeed=10}return i(e,[{key:"changeStrokeStyle",value:function(e){this.strokeStyle=e}},{key:"changeStrokeStyle",value:function(e){this.strokeStyle=e}},{key:"changeDrawing",value:function(e){this.isDrawing=e}},{key:"changeStartPoint",value:function(e){var t=e.x,n=e.y;this.startX=t,this.startY=n}},{key:"changePoint",value:function(e){var t=e.x,n=e.y;this.x=t,this.y=n}},{key:"changeLine",value:function(e){this.lines=e}},{key:"addLine",value:function(){this.lines.push([this.startX,this.startY,this.x,this.y,this.strokeStyle,this.lineWidth])}},{key:"draw",value:function(e,n,a,i,r,o){t.stage.ctx.strokeStyle=r||this.strokeStyle,t.stage.ctx.lineWidth=o||this.lineWidth,t.stage.ctx.lineJoin="round",t.stage.ctx.lineCap="round",t.stage.ctx.beginPath(),t.stage.ctx.moveTo(e||this.startX,n||this.startY),t.stage.ctx.lineTo(a||this.x,i||this.y),t.stage.ctx.stroke()}},{key:"save",value:function(){localStorage.draw=JSON.stringify(this.lines)}},{key:"repeat",value:function(e){var n=this,i=e.speed,r=void 0===i?this.repeatSpeed:i,o=e.lines,s=void 0===o?this.lines:o;t.stage.ctx.beginPath(),t.stage.ctx.clearRect(0,0,t.stage.width,t.stage.height);for(var c=0,h=0;h<s.length;h++)setTimeout(function(){var e=a(n.lines[c],6),t=e[0],i=e[1],r=e[2],o=e[3],s=e[4],h=e[5];n.draw(t,i,r,o,s,h),c++},r*h)}}]),e}();return e}(a,n),i=function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=navigator.userAgent;t.match(/iPhone OS (\w+){1,3}/g),t.match(/CPU OS (\w+){1,3}/g);var n=(RegExp.$1.replace(/_/g,"")+"00").slice(0,3),a=e.UA={iPhone:t.search(/iPhone/)!==-1,iPad:t.search(/iPad/)!==-1,Android:t.search(/Android/)!==-1&&t.search(/Mobile/)!==-1&&t.search(/SC-01C/)==-1,AndroidTab:t.search(/Android/)!==-1&&(t.search(/Mobile/)==-1||t.search(/SC-01C/)!==-1),Android3_2:t.search(/Android 3.2/)!==-1,iOS5_less:(t.search(/iPhone/)!==-1||t.search(/iPad/)!==-1)&&n<500,other:!(t.search(/iPhone/)!==-1||t.search(/iPad/)!==-1||t.search(/Android/)!==-1&&t.search(/Mobile/)!==-1&&t.search(/SC-01C/)==-1||t.search(/Android/)!==-1&&(t.search(/Mobile/)==-1||t.search(/SC-01C/)!==-1))},i=e.isMobile=a.iPhone||a.iPad||a.Android||a.AndroidTab;e.EVENT_TYPE={touchStart:i?"touchstart":"mousedown",touchEnd:i?"touchend":"mouseup",touchMove:i?"touchmove":"mousemove"};return e}(i),t=function(t,n,a){e.fn.oekaki=function(i){var r=e(this);r.prepend('<canvas class="layer"></canvas>'),t.stage.setLayers(r.find(".layer")),t.stage.setLayer({});var o=new n.Oekaki({strokeStyle:"#333",lineWidth:1});window.location.search&&(o.changeLine(JSON.parse(localStorage.draw)),o.repeat({})),e(this).on(a.EVENT_TYPE.touchStart,function(e){var t=a.isMobile?e.originalEvent.touches[0]:e;o.changeDrawing(!0),o.changeStartPoint({x:t.pageX,y:t.pageY})}).on(a.EVENT_TYPE.touchMove,function(e){if(o.isDrawing){a.isMobile&&event.preventDefault();var t=a.isMobile?e.originalEvent.touches[0]:e;o.changePoint({x:t.pageX,y:t.pageY}),o.addLine(),o.draw(),o.changeStartPoint({x:e.pageX,y:e.pageY})}}).on(a.EVENT_TYPE.touchEnd,function(e){o.changeDrawing(!1)}).mouseleave(function(e){o.changeDrawing(!1)}),e(".save").on("click",function(e){o.save()}),e(".repeat").on("click",function(e){o.changeLine(JSON.parse(localStorage.draw)),o.repeat({})}),e(".num").on("keyup",function(e){t.stage.setLayer({layerNum:parseInt(e.target.value)})}),e(".addLayer").on("click",function(n){r.prepend('<canvas class="layer"></canvas>'),t.stage.setLayers(r.find(".layer")),t.stage.setLayer({layerNum:t.stage.layerNum+1}),e(".num").val(t.stage.layerNum)})}}(n,a,i)}()});