/*! * Toast UI Colorpicker * @version 2.0.1 * @author NHNEnt FE Development Team * @license MIT */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("tui-code-snippet")):"function"==typeof define&&define.amd?define(["tui-code-snippet"],e):"object"==typeof exports?exports.colorPicker=e(require("tui-code-snippet")):(t.tui=t.tui||{},t.tui.colorPicker=e(t.tui&&t.tui.util))}(this,function(t){return function(t){function e(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return t[n].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var o={};return e.m=t,e.c=o,e.p="dist",e(0)}([function(t,e,o){o(16),t.exports=o(12)},function(e,o){e.exports=t},function(t,e,o){"use strict";function n(t){return t.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}var r,i,s=o(1),a=o(3),l=o(6),c=s,u="_pos",d="onselectstart"in document,f="",h=/^auto$|^$|%/;r={appendHTMLElement:function(t,e,o){var n;return o=o||"",n=document.createElement(t),n.className=o,e?e.appendChild(n):document.body.appendChild(n),n},remove:function(t){t&&t.parentNode&&t.parentNode.removeChild(t)},get:function(t){return document.getElementById(t)},_matcher:function(t,e){var o=/^\./,n=/^#/;return o.test(e)?r.hasClass(t,e.replace(".","")):n.test(e)?t.id===e.replace("#",""):t.nodeName.toLowerCase()===e.toLowerCase()},find:function(t,e,o){function n(t,e){for(var c,u=t.childNodes,d=0,f=u.length;d0&&(n(c,e),s))break}var i=[],s=!1,a=c.isUndefined(o)||o===!1,l=c.isFunction(o);return c.isString(e)&&(e=r.get(e)),e=e||window.document.body,n(e,t),a?i[0]||null:i},closest:function(t,e){var o=t.parentNode;if(r._matcher(t,e))return t;for(;o&&o!==window.document.body;){if(r._matcher(o,e))return o;o=o.parentNode}},text:function(t){var e="",o=0,n=t.nodeType;if(n){if(1===n||9===n||11===n){if("string"==typeof t.textContent)return t.textContent;for(t=t.firstChild;t;t=t.nextSibling)e+=r.text(t)}else if(3===n||4===n)return t.nodeValue}else for(;t[o];o+=1)e+=r.text(t[o]);return e},setData:function(t,e,o){return"dataset"in t?void(t.dataset[e]=o):void t.setAttribute("data-"+e,o)},getData:function(t,e){return"dataset"in t?t.dataset[e]:t.getAttribute("data-"+e)},hasClass:function(t,e){var o;return c.isUndefined(t.classList)?(o=r.getClass(t),o.length>0&&new RegExp("(^|\\s)"+e+"(\\s|$)").test(o)):t.classList.contains(e)},addClass:function(t,e){var o;c.isUndefined(t.classList)?r.hasClass(t,e)||(o=r.getClass(t),r.setClass(t,(o?o+" ":"")+e)):c.forEachArray(e.split(" "),function(e){t.classList.add(e)})},setClass:function(t,e){c.isUndefined(t.className.baseVal)?t.className=e:t.className.baseVal=e},removeClass:function(t,e){var o="";c.isUndefined(t.classList)?(o=(" "+r.getClass(t)+" ").replace(" "+e+" "," "),r.setClass(t,n(o))):t.classList.remove(e)},getClass:function(t){return t&&t.className?c.isUndefined(t.className.baseVal)?t.className:t.className.baseVal:""},getStyle:function(t,e){var o,n=t.style[e]||t.currentStyle&&t.currentStyle[e];return n&&"auto"!==n||!document.defaultView||(o=document.defaultView.getComputedStyle(t,null),n=o?o[e]:null),"auto"===n?null:n},getComputedStyle:function(t){var e=document.defaultView;return e&&e.getComputedStyle?document.defaultView.getComputedStyle(t):{getPropertyValue:function(e){var o=/(\-([a-z]){1})/g;return"float"===e&&(e="styleFloat"),o.test(e)&&(e=e.replace(o,function(){return arguments[2].toUpperCase()})),t.currentStyle[e]?t.currentStyle[e]:null}}},setPosition:function(t,e,o){e=c.isUndefined(e)?0:e,o=c.isUndefined(o)?0:o,t[u]=[e,o],t.style.left=e+"px",t.style.top=o+"px"},getPosition:function(t,e){var o,n,r;return e&&(t[u]=null),t[u]?t[u]:(o=0,n=0,(h.test(t.style.left)||h.test(t.style.top))&&"getBoundingClientRect"in t?(r=t.getBoundingClientRect(),o=r.left,n=r.top):(o=parseFloat(t.style.left||0),n=parseFloat(t.style.top||0)),[o,n])},getSize:function(t){var e,o=r.getStyle(t,"width"),n=r.getStyle(t,"height");return(h.test(o)||h.test(n))&&"getBoundingClientRect"in t?(e=t.getBoundingClientRect(),o=e.width,n=e.height):(o=parseFloat(o||0),n=parseFloat(n||0)),[o,n]},testProp:function(t){for(var e=document.documentElement.style,o=0,n=t.length;oe)return t+"";for(;n HSV conversion utilities based off of http://www.cs.rit.edu/~ncs/color/t_convert.html hexToRGB:function(t){var e,o,r;return!!n.isValidRGB(t)&&(t=t.substring(1),e=parseInt(t.substr(0,2),16),o=parseInt(t.substr(2,2),16),r=parseInt(t.substr(4,2),16),[e,o,r])},rgbToHEX:function(t,e,o){var r="#"+n.leadingZero(t.toString(16),2)+n.leadingZero(e.toString(16),2)+n.leadingZero(o.toString(16),2);return!!n.isValidRGB(r)&&r},rgbToHSV:function(t,e,o){var n,r,i,s,a,l;if(t/=255,e/=255,o/=255,n=Math.max(t,e,o),r=Math.min(t,e,o),a=n,l=n-r,s=0===n?0:l/n,n===r)i=0;else{switch(n){case t:i=(e-o)/l+(e1?void a(u.call(arguments),function(t){this.add(t)},this):(e=this.getItemID(t),o=this.items,o[e]||(this.length+=1),void(o[e]=t))},n.prototype.remove=function(t){var e,o,n=[];return this.length?arguments.length>1?n=i.map(u.call(arguments),function(t){return this.remove(t)},this):(e=this.items,c(t)&&(t=this.getItemID(t)),e[t]?(this.length-=1,o=e[t],delete e[t],o):n):n},n.prototype.clear=function(){this.items={},this.length=0},n.prototype.has=function(t){var e,o;return!!this.length&&(e=l(t),o=!1,e?this.each(function(e){return t(e)!==!0||(o=!0,!1)}):(t=c(t)?this.getItemID(t):t,o=i.isExisty(this.items[t])),o)},n.prototype.doWhenHas=function(t,e,o){var n=this.items[t];i.isExisty(n)&&e.call(o||this,n)},n.prototype.find=function(t){var e=new n;return this.hasOwnProperty("getItemID")&&(e.getItemID=this.getItemID),this.each(function(o){t(o)===!0&&e.add(o)}),e},n.prototype.groupBy=function(t,e){var o,r,s={},a=l(t),c=this.getItemID;if(i.isArray(t)){if(i.forEachArray(t,function(t){s[t+""]=new n(c)}),!e)return s;t=e,a=!0}return this.each(function(e){a?r=t(e):(r=e[t],l(r)&&(r=r.apply(e))),o=s[r],o||(o=s[r]=new n(c)),o.add(e)}),s},n.prototype.single=function(){var t;return this.each(function(e){return t=e,!1},this),t},n.prototype.sort=function(t){var e=[];return this.each(function(t){e.push(t)}),l(t)&&(e=e.sort(t)),e},n.prototype.each=function(t,e){s(this.items,t,e||this)},n.prototype.toArray=function(){return this.length?i.map(this.items,function(t){return t}):[]},t.exports=n},function(t,e,o){(function(e){"use strict";function n(t,e){s.on(e,"mousedown",this._onMouseDown,this),this.options=r.extend({distance:10},t),this.container=e,this._isMoved=!1,this._distance=0,this._dragStartFired=!1,this._dragStartEventData=null}var r=o(1),i=o(2),s=o(3);n.prototype.destroy=function(){s.off(this.container,"mousedown",this._onMouseDown,this),this.options=this.container=this._isMoved=this._distance=this._dragStartFired=this._dragStartEventData=null},n.prototype._toggleDragEvent=function(t){var o,n,r=this.container;t?(o="on",n="disable"):(o="off",n="enable"),i[n+"TextSelection"](r),i[n+"ImageDrag"](r),s[o](e.document,{mousemove:this._onMouseMove,mouseup:this._onMouseUp},this)},n.prototype._getEventData=function(t){return{target:t.target||t.srcElement,originEvent:t}},n.prototype._onMouseDown=function(t){0===s.getMouseButton(t)&&(this._distance=0,this._dragStartFired=!1,this._dragStartEventData=this._getEventData(t),this._toggleDragEvent(!0))},n.prototype._onMouseMove=function(t){var e=this.options.distance;return s.preventDefault(t),this._isMoved=!0,this._distance50?"white":"black",a.setStrokeColor(r,n),o||this.fire("_selectColor",{color:l.rgbToHEX.apply(null,this.getRGB())})},n.prototype.moveSaturationAndValue=function(t,e,o){var n,r,i,s;t=t||0,e=e||0,n=Math.abs(f[0]),r=f[1],i=t*r/100-n,s=r-e*r/100-n,this._moveColorSliderHandle(i,s,o)},n.prototype._moveColorSliderByPosition=function(t,e){var o=f[0];this._moveColorSliderHandle(t+o,e+o)},n.prototype.getSaturationAndValue=function(){var t,e,o=Math.abs(f[0]),n=o+f[1],r=a.getTranslateXY(this.sliderHandleElement);return t=(r[1]+o)/n*100,e=100-(r[0]+o)/n*100,[t,e]},n.prototype._moveHueHandle=function(t,e){var o,n,r=this.huebarHandleElement,i=this.baseColorElement;t=Math.max(h[0],t),t=Math.min(h[1],t),a.setTranslateY(r,t),o=l.hsvToRGB(this.getHue(),100,100),n=l.rgbToHEX.apply(null,o),a.setGradientColorStop(i,n),e||this.fire("_selectColor",{color:l.rgbToHEX.apply(null,this.getRGB())})},n.prototype.moveHue=function(t,e){var o,n,r=0;o=Math.abs(h[0]),n=o+h[1],t=t||0,r=n*t/p-o,this._moveHueHandle(r,e)},n.prototype._moveHueByPosition=function(t){var e=h[0];this._moveHueHandle(t+e)},n.prototype.getHue=function(){var t,e,o=this.huebarHandleElement,n=a.getTranslateXY(o);return t=Math.abs(h[0]),e=t+h[1],(n[0]+t)*p/e},n.prototype.getHSV=function(){var t=this.getSaturationAndValue(),e=this.getHue();return[e].concat(t)},n.prototype.getRGB=function(){return l.hsvToRGB.apply(null,this.getHSV())},n.prototype._prepareColorSliderForMouseEvent=function(t){var e,o=this.options,n=i.closest(t.target,"."+o.cssPrefix+"slider-part");return e=this._dragDataCache={isColorSlider:i.hasClass(n,o.cssPrefix+"slider-left"),parentElement:n}},n.prototype._onClick=function(t){var e=this._prepareColorSliderForMouseEvent(t),o=s.getMousePosition(t.originEvent,e.parentElement);e.isColorSlider?this._moveColorSliderByPosition(o[0],o[1]):this._moveHueByPosition(o[1]),this._dragDataCache=null},n.prototype._onDragStart=function(t){this._prepareColorSliderForMouseEvent(t)},n.prototype._onDrag=function(t){var e=this._dragDataCache,o=s.getMousePosition(t.originEvent,e.parentElement);e.isColorSlider?this._moveColorSliderByPosition(o[0],o[1]):this._moveHueByPosition(o[1])},n.prototype._onDragEnd=function(){this._dragDataCache=null},r.CustomEvents.mixin(n),t.exports=n},function(t,e,o){"use strict";var n=o(1),r=/[\.\-0-9]+/g,i=-6,s={isOldBrowser:function(){var t=s._isOldBrowser;return n.isExisty(t)||(s._isOldBrowser=t=n.browser.msie&&n.browser.version<9),t},getTranslateXY:function(t){var e;return s.isOldBrowser()?(e=t.style,[parseFloat(e.top),parseFloat(e.left)]):(e=t.getAttribute("transform"))?(e=e.match(r),[parseFloat(e[1]),parseFloat(e[0])]):[0,0]},setTranslateXY:function(t,e,o){s.isOldBrowser()?(t.style.left=e+"px",t.style.top=o+"px"):t.setAttribute("transform","translate("+e+","+o+")")},setTranslateY:function(t,e){s.isOldBrowser()?t.style.top=e+"px":t.setAttribute("transform","translate("+i+","+e+")")},setStrokeColor:function(t,e){s.isOldBrowser()?t.strokecolor=e:t.setAttribute("stroke",e)},setGradientColorStop:function(t,e){s.isOldBrowser()?t.color=e:t.setAttribute("stop-color",e)}};t.exports=s},function(t,e,o){"use strict";function n(t){var e;if(!(this instanceof n))return new n(t);if(t=this.options=r.extend({container:null,color:"#f8f8f8",preset:["#181818","#282828","#383838","#585858","#b8b8b8","#d8d8d8","#e8e8e8","#f8f8f8","#ab4642","#dc9656","#f7ca88","#a1b56c","#86c1b9","#7cafc2","#ba8baf","#a16946"],cssPrefix:"tui-colorpicker-",detailTxt:"Detail"},t),!t.container)throw new Error("ColorPicker(): need container option.");e=this.layout=new s(t,t.container),this.palette=new a(t,e.container),this.palette.on({_selectColor:this._onSelectColorInPalette,_toggleSlider:this._onToggleSlider},this),this.slider=new l(t,e.container),this.slider.on("_selectColor",this._onSelectColorInSlider,this),e.addChild(this.palette),e.addChild(this.slider),this.render(t.color)}var r=o(1),i=o(5),s=o(13),a=o(8),l=o(9);n.prototype._onSelectColorInPalette=function(t){var e=t.color,o=this.options;return i.isValidRGB(e)?(this.fire("selectColor",{color:e,origin:"palette"}),void(o.color!==e&&(o.color=e,this.render(e)))):void this.render()},n.prototype._onToggleSlider=function(){this.slider.toggle(!this.slider.isVisible())},n.prototype._onSelectColorInSlider=function(t){var e=t.color,o=this.options;this.fire("selectColor",{color:e,origin:"slider"}),o.color!==e&&(o.color=e,this.palette.render(e))},n.prototype.setColor=function(t){if(!i.isValidRGB(t))throw new Error("ColorPicker#setColor(): need valid hex string color value");this.options.color=t,this.render(t)},n.prototype.getColor=function(){return this.options.color},n.prototype.toggle=function(t){this.layout.container.style.display=t?"block":"none"},n.prototype.render=function(t){this.layout.render(t||this.options.color)},n.prototype.destroy=function(){this.layout.destroy(),this.options.container.innerHTML="",this.layout=this.slider=this.palette=this.options=null},r.CustomEvents.mixin(n),t.exports=n},function(t,e,o){"use strict";var n=o(2),r=o(3),i=o(6),s=o(4),a=o(7),l=o(11),c=o(8),u=o(9),d=o(5),f=o(10),h={domutil:n,domevent:r,Collection:i,View:s,Drag:a,create:l,Palette:c,Slider:u,colorutil:d,svgvml:f};t.exports=h},function(t,e,o){"use strict";function n(t,e){this.options=r.extend({cssPrefix:"tui-colorpicker-"},t),e=i.appendHTMLElement("div",e,this.options.cssPrefix+"container"),s.call(this,t,e),this.render()}var r=o(1),i=o(2),s=o(4);r.inherit(n,s),n.prototype.render=function(t){this.recursive(function(e){e.render(t)},!0)},t.exports=n},function(t,e){"use strict";var o=['
    {{colorList}}
','
','','','{{color}}',"
"].join("\n"),n='
  • ';t.exports={layout:o,item:n}},function(t,e,o){(function(e){"use strict";var n=o(1),r=['
    {{slider}}
    ','
    {{huebar}}
    '].join("\n"),i=['',"",'','','',"",'','','',"","",'','','',""].join("\n"),s=['
    ','','',"",'','',"",'',"
    "].join("\n"),a=['',"",'','','','','','','','',"","",'','',""].join("\n"),l=['
    ','','',"",'',"
    "].join("\n"),c=n.browser.msie&&n.browser.version<9;c&&e.document.namespaces.add("v","urn:schemas-microsoft-com:vml"),t.exports={layout:r,slider:c?s:i,huebar:c?l:a}}).call(e,function(){return this}())},function(t,e){}])});