fcef7f50c7f93494d425d80e56f9f78e.json 46.5 KB
{"ast":null,"code":"import snippet from 'tui-code-snippet';\nimport Colorpicker from './tools/colorpicker';\nimport Range from './tools/range';\nimport Submenu from './submenuBase';\nimport templateHtml from './template/submenu/filter';\nimport { toInteger, toCamelCase, assignmentForDestroy } from '../util';\nimport { defaultFilterRangeValus as FILTER_RANGE } from '../consts';\nconst PICKER_CONTROL_HEIGHT = '130px';\nconst BLEND_OPTIONS = ['add', 'diff', 'subtract', 'multiply', 'screen', 'lighten', 'darken'];\nconst FILTER_OPTIONS = ['grayscale', 'invert', 'sepia', 'vintage', 'blur', 'sharpen', 'emboss', 'remove-white', 'brightness', 'noise', 'pixelate', 'color-filter', 'tint', 'multiply', 'blend'];\nconst filterNameMap = {\n  grayscale: 'grayscale',\n  invert: 'invert',\n  sepia: 'sepia',\n  blur: 'blur',\n  sharpen: 'sharpen',\n  emboss: 'emboss',\n  removeWhite: 'removeColor',\n  brightness: 'brightness',\n  contrast: 'contrast',\n  saturation: 'saturation',\n  vintage: 'vintage',\n  polaroid: 'polaroid',\n  noise: 'noise',\n  pixelate: 'pixelate',\n  colorFilter: 'removeColor',\n  tint: 'blendColor',\n  multiply: 'blendColor',\n  blend: 'blendColor',\n  hue: 'hue',\n  gamma: 'gamma'\n};\nconst RANGE_INSTANCE_NAMES = ['removewhiteDistanceRange', 'colorfilterThresholeRange', 'pixelateRange', 'noiseRange', 'brightnessRange', 'tintOpacity'];\nconst COLORPICKER_INSTANCE_NAMES = ['filterBlendColor', 'filterMultiplyColor', 'filterTintColor'];\n/**\r\n * Filter ui class\r\n * @class\r\n * @ignore\r\n */\n\nclass Filter extends Submenu {\n  constructor(subMenuElement, {\n    locale,\n    menuBarPosition,\n    usageStatistics\n  }) {\n    super(subMenuElement, {\n      locale,\n      name: 'filter',\n      menuBarPosition,\n      templateHtml,\n      usageStatistics\n    });\n    this.selectBoxShow = false;\n    this.checkedMap = {};\n\n    this._makeControlElement();\n  }\n  /**\r\n   * Destroys the instance.\r\n   */\n\n\n  destroy() {\n    this._removeEvent();\n\n    this._destroyToolInstance();\n\n    assignmentForDestroy(this);\n  }\n  /**\r\n   * Remove event for filter\r\n   */\n\n\n  _removeEvent() {\n    snippet.forEach(FILTER_OPTIONS, filter => {\n      const filterCheckElement = this.selector(`.tie-${filter}`);\n      const filterNameCamelCase = toCamelCase(filter);\n      filterCheckElement.removeEventListener('change', this.eventHandler[filterNameCamelCase]);\n    });\n    snippet.forEach([...RANGE_INSTANCE_NAMES, ...COLORPICKER_INSTANCE_NAMES], instanceName => {\n      this._els[instanceName].off();\n    });\n\n    this._els.blendType.removeEventListener('change', this.eventHandler.changeBlendFilter);\n\n    this._els.blendType.removeEventListener('click', this.eventHandler.changeBlendFilter);\n  }\n\n  _destroyToolInstance() {\n    snippet.forEach([...RANGE_INSTANCE_NAMES, ...COLORPICKER_INSTANCE_NAMES], instanceName => {\n      this._els[instanceName].destroy();\n    });\n  }\n  /**\r\n   * Add event for filter\r\n   * @param {Object} actions - actions for crop\r\n   *   @param {Function} actions.applyFilter - apply filter option\r\n   */\n\n\n  addEvent({\n    applyFilter\n  }) {\n    const changeFilterState = filterName => this._changeFilterState.bind(this, applyFilter, filterName);\n\n    const changeFilterStateForRange = filterName => (value, isLast) => this._changeFilterState(applyFilter, filterName, isLast);\n\n    this.eventHandler = {\n      changeBlendFilter: changeFilterState('blend'),\n      blandTypeClick: event => event.stopPropagation()\n    };\n    snippet.forEach(FILTER_OPTIONS, filter => {\n      const filterCheckElement = this.selector(`.tie-${filter}`);\n      const filterNameCamelCase = toCamelCase(filter);\n      this.checkedMap[filterNameCamelCase] = filterCheckElement;\n      this.eventHandler[filterNameCamelCase] = changeFilterState(filterNameCamelCase);\n      filterCheckElement.addEventListener('change', this.eventHandler[filterNameCamelCase]);\n    });\n\n    this._els.removewhiteDistanceRange.on('change', changeFilterStateForRange('removeWhite'));\n\n    this._els.colorfilterThresholeRange.on('change', changeFilterStateForRange('colorFilter'));\n\n    this._els.pixelateRange.on('change', changeFilterStateForRange('pixelate'));\n\n    this._els.noiseRange.on('change', changeFilterStateForRange('noise'));\n\n    this._els.brightnessRange.on('change', changeFilterStateForRange('brightness'));\n\n    this._els.filterBlendColor.on('change', this.eventHandler.changeBlendFilter);\n\n    this._els.filterMultiplyColor.on('change', changeFilterState('multiply'));\n\n    this._els.filterTintColor.on('change', changeFilterState('tint'));\n\n    this._els.tintOpacity.on('change', changeFilterStateForRange('tint'));\n\n    this._els.filterMultiplyColor.on('changeShow', this.colorPickerChangeShow.bind(this));\n\n    this._els.filterTintColor.on('changeShow', this.colorPickerChangeShow.bind(this));\n\n    this._els.filterBlendColor.on('changeShow', this.colorPickerChangeShow.bind(this));\n\n    this._els.blendType.addEventListener('change', this.eventHandler.changeBlendFilter);\n\n    this._els.blendType.addEventListener('click', this.eventHandler.blandTypeClick);\n  }\n  /**\r\n   * Set filter for undo changed\r\n   * @param {Object} chagedFilterInfos - changed command infos\r\n   *   @param {string} type - filter type\r\n   *   @param {string} action - add or remove\r\n   *   @param {Object} options - filter options\r\n   */\n\n\n  setFilterState(chagedFilterInfos) {\n    const {\n      type,\n      options,\n      action\n    } = chagedFilterInfos;\n\n    const filterName = this._getFilterNameFromOptions(type, options);\n\n    const isRemove = action === 'remove';\n\n    if (!isRemove) {\n      this._setFilterState(filterName, options);\n    }\n\n    this.checkedMap[filterName].checked = !isRemove;\n  }\n  /**\r\n   * Set filter for undo changed\r\n   * @param {string} filterName - filter name\r\n   * @param {Object} options - filter options\r\n   * @private\r\n   */\n  // eslint-disable-next-line complexity\n\n\n  _setFilterState(filterName, options) {\n    if (filterName === 'colorFilter') {\n      this._els.colorfilterThresholeRange.value = options.distance;\n    } else if (filterName === 'removeWhite') {\n      this._els.removewhiteDistanceRange.value = options.distance;\n    } else if (filterName === 'pixelate') {\n      this._els.pixelateRange.value = options.blocksize;\n    } else if (filterName === 'brightness') {\n      this._els.brightnessRange.value = options.brightness;\n    } else if (filterName === 'noise') {\n      this._els.noiseRange.value = options.noise;\n    } else if (filterName === 'tint') {\n      this._els.tintOpacity.value = options.alpha;\n      this._els.filterTintColor.color = options.color;\n    } else if (filterName === 'blend') {\n      this._els.filterBlendColor.color = options.color;\n    } else if (filterName === 'multiply') {\n      this._els.filterMultiplyColor.color = options.color;\n    }\n  }\n  /**\r\n   * Get filter name\r\n   * @param {string} type - filter type\r\n   * @param {Object} options - filter options\r\n   * @returns {string} filter name\r\n   * @private\r\n   */\n\n\n  _getFilterNameFromOptions(type, options) {\n    let filterName = type;\n\n    if (type === 'removeColor') {\n      filterName = snippet.isExisty(options.useAlpha) ? 'removeWhite' : 'colorFilter';\n    } else if (type === 'blendColor') {\n      filterName = {\n        add: 'blend',\n        multiply: 'multiply',\n        tint: 'tint'\n      }[options.mode];\n    }\n\n    return filterName;\n  }\n  /**\r\n   * Add event for filter\r\n   * @param {Function} applyFilter - actions for firter\r\n   * @param {string} filterName - filter name\r\n   * @param {boolean} [isLast] - Is last change\r\n   */\n\n\n  _changeFilterState(applyFilter, filterName, isLast = true) {\n    const apply = this.checkedMap[filterName].checked;\n    const type = filterNameMap[filterName];\n    const checkboxGroup = this.checkedMap[filterName].closest('.tui-image-editor-checkbox-group');\n\n    if (checkboxGroup) {\n      if (apply) {\n        checkboxGroup.classList.remove('tui-image-editor-disabled');\n      } else {\n        checkboxGroup.classList.add('tui-image-editor-disabled');\n      }\n    }\n\n    applyFilter(apply, type, this._getFilterOption(filterName), !isLast);\n  }\n  /**\r\n   * Get filter option\r\n   * @param {String} type - filter type\r\n   * @returns {Object} filter option object\r\n   * @private\r\n   */\n  // eslint-disable-next-line complexity\n\n\n  _getFilterOption(type) {\n    const option = {};\n\n    switch (type) {\n      case 'removeWhite':\n        option.color = '#FFFFFF';\n        option.useAlpha = false;\n        option.distance = parseFloat(this._els.removewhiteDistanceRange.value);\n        break;\n\n      case 'colorFilter':\n        option.color = '#FFFFFF';\n        option.distance = parseFloat(this._els.colorfilterThresholeRange.value);\n        break;\n\n      case 'pixelate':\n        option.blocksize = toInteger(this._els.pixelateRange.value);\n        break;\n\n      case 'noise':\n        option.noise = toInteger(this._els.noiseRange.value);\n        break;\n\n      case 'brightness':\n        option.brightness = parseFloat(this._els.brightnessRange.value);\n        break;\n\n      case 'blend':\n        option.mode = 'add';\n        option.color = this._els.filterBlendColor.color;\n        option.mode = this._els.blendType.value;\n        break;\n\n      case 'multiply':\n        option.mode = 'multiply';\n        option.color = this._els.filterMultiplyColor.color;\n        break;\n\n      case 'tint':\n        option.mode = 'tint';\n        option.color = this._els.filterTintColor.color;\n        option.alpha = this._els.tintOpacity.value;\n        break;\n\n      case 'blur':\n        option.blur = this._els.blurRange.value;\n        break;\n\n      default:\n        break;\n    }\n\n    return option;\n  }\n  /**\r\n   * Make submenu range and colorpicker control\r\n   * @private\r\n   */\n\n\n  _makeControlElement() {\n    this._els = {\n      removewhiteDistanceRange: new Range({\n        slider: this.selector('.tie-removewhite-distance-range')\n      }, FILTER_RANGE.removewhiteDistanceRange),\n      brightnessRange: new Range({\n        slider: this.selector('.tie-brightness-range')\n      }, FILTER_RANGE.brightnessRange),\n      noiseRange: new Range({\n        slider: this.selector('.tie-noise-range')\n      }, FILTER_RANGE.noiseRange),\n      pixelateRange: new Range({\n        slider: this.selector('.tie-pixelate-range')\n      }, FILTER_RANGE.pixelateRange),\n      colorfilterThresholeRange: new Range({\n        slider: this.selector('.tie-colorfilter-threshole-range')\n      }, FILTER_RANGE.colorfilterThresholeRange),\n      filterTintColor: new Colorpicker(this.selector('.tie-filter-tint-color'), '#03bd9e', this.toggleDirection, this.usageStatistics),\n      filterMultiplyColor: new Colorpicker(this.selector('.tie-filter-multiply-color'), '#515ce6', this.toggleDirection, this.usageStatistics),\n      filterBlendColor: new Colorpicker(this.selector('.tie-filter-blend-color'), '#ffbb3b', this.toggleDirection, this.usageStatistics),\n      blurRange: FILTER_RANGE.blurFilterRange\n    };\n    this._els.tintOpacity = this._pickerWithRange(this._els.filterTintColor.pickerControl);\n    this._els.blendType = this._pickerWithSelectbox(this._els.filterBlendColor.pickerControl);\n    this.colorPickerControls.push(this._els.filterTintColor);\n    this.colorPickerControls.push(this._els.filterMultiplyColor);\n    this.colorPickerControls.push(this._els.filterBlendColor);\n  }\n  /**\r\n   * Make submenu control for picker & range mixin\r\n   * @param {HTMLElement} pickerControl - pickerControl dom element\r\n   * @returns {Range}\r\n   * @private\r\n   */\n\n\n  _pickerWithRange(pickerControl) {\n    const rangeWrap = document.createElement('div');\n    const rangelabel = document.createElement('label');\n    const slider = document.createElement('div');\n    slider.id = 'tie-filter-tint-opacity';\n    rangelabel.innerHTML = 'Opacity';\n    rangeWrap.appendChild(rangelabel);\n    rangeWrap.appendChild(slider);\n    pickerControl.appendChild(rangeWrap);\n    pickerControl.style.height = PICKER_CONTROL_HEIGHT;\n    return new Range({\n      slider\n    }, FILTER_RANGE.tintOpacityRange);\n  }\n  /**\r\n   * Make submenu control for picker & selectbox\r\n   * @param {HTMLElement} pickerControl - pickerControl dom element\r\n   * @returns {HTMLElement}\r\n   * @private\r\n   */\n\n\n  _pickerWithSelectbox(pickerControl) {\n    const selectlistWrap = document.createElement('div');\n    const selectlist = document.createElement('select');\n    const optionlist = document.createElement('ul');\n    selectlistWrap.className = 'tui-image-editor-selectlist-wrap';\n    optionlist.className = 'tui-image-editor-selectlist';\n    selectlistWrap.appendChild(selectlist);\n    selectlistWrap.appendChild(optionlist);\n\n    this._makeSelectOptionList(selectlist);\n\n    pickerControl.appendChild(selectlistWrap);\n    pickerControl.style.height = PICKER_CONTROL_HEIGHT;\n\n    this._drawSelectOptionList(selectlist, optionlist);\n\n    this._pickerWithSelectboxForAddEvent(selectlist, optionlist);\n\n    return selectlist;\n  }\n  /**\r\n   * Make selectbox option list custom style\r\n   * @param {HTMLElement} selectlist - selectbox element\r\n   * @param {HTMLElement} optionlist - custom option list item element\r\n   * @private\r\n   */\n\n\n  _drawSelectOptionList(selectlist, optionlist) {\n    const options = selectlist.querySelectorAll('option');\n    snippet.forEach(options, option => {\n      const optionElement = document.createElement('li');\n      optionElement.innerHTML = option.innerHTML;\n      optionElement.setAttribute('data-item', option.value);\n      optionlist.appendChild(optionElement);\n    });\n  }\n  /**\r\n   * custome selectbox custom event\r\n   * @param {HTMLElement} selectlist - selectbox element\r\n   * @param {HTMLElement} optionlist - custom option list item element\r\n   * @private\r\n   */\n\n\n  _pickerWithSelectboxForAddEvent(selectlist, optionlist) {\n    optionlist.addEventListener('click', event => {\n      const optionValue = event.target.getAttribute('data-item');\n      const fireEvent = document.createEvent('HTMLEvents');\n      selectlist.querySelector(`[value=\"${optionValue}\"]`).selected = true;\n      fireEvent.initEvent('change', true, true);\n      selectlist.dispatchEvent(fireEvent);\n      this.selectBoxShow = false;\n      optionlist.style.display = 'none';\n    });\n    selectlist.addEventListener('mousedown', event => {\n      event.preventDefault();\n      this.selectBoxShow = !this.selectBoxShow;\n      optionlist.style.display = this.selectBoxShow ? 'block' : 'none';\n      optionlist.setAttribute('data-selectitem', selectlist.value);\n      optionlist.querySelector(`[data-item='${selectlist.value}']`).classList.add('active');\n    });\n  }\n  /**\r\n   * Make option list for select control\r\n   * @param {HTMLElement} selectlist - blend option select list element\r\n   * @private\r\n   */\n\n\n  _makeSelectOptionList(selectlist) {\n    snippet.forEach(BLEND_OPTIONS, option => {\n      const selectOption = document.createElement('option');\n      selectOption.setAttribute('value', option);\n      selectOption.innerHTML = option.replace(/^[a-z]/, $0 => $0.toUpperCase());\n      selectlist.appendChild(selectOption);\n    });\n  }\n\n}\n\nexport default Filter;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/src/js/ui/filter.js"],"names":["snippet","Colorpicker","Range","Submenu","templateHtml","toInteger","toCamelCase","assignmentForDestroy","defaultFilterRangeValus","FILTER_RANGE","PICKER_CONTROL_HEIGHT","BLEND_OPTIONS","FILTER_OPTIONS","filterNameMap","grayscale","invert","sepia","blur","sharpen","emboss","removeWhite","brightness","contrast","saturation","vintage","polaroid","noise","pixelate","colorFilter","tint","multiply","blend","hue","gamma","RANGE_INSTANCE_NAMES","COLORPICKER_INSTANCE_NAMES","Filter","constructor","subMenuElement","locale","menuBarPosition","usageStatistics","name","selectBoxShow","checkedMap","_makeControlElement","destroy","_removeEvent","_destroyToolInstance","forEach","filter","filterCheckElement","selector","filterNameCamelCase","removeEventListener","eventHandler","instanceName","_els","off","blendType","changeBlendFilter","addEvent","applyFilter","changeFilterState","filterName","_changeFilterState","bind","changeFilterStateForRange","value","isLast","blandTypeClick","event","stopPropagation","addEventListener","removewhiteDistanceRange","on","colorfilterThresholeRange","pixelateRange","noiseRange","brightnessRange","filterBlendColor","filterMultiplyColor","filterTintColor","tintOpacity","colorPickerChangeShow","setFilterState","chagedFilterInfos","type","options","action","_getFilterNameFromOptions","isRemove","_setFilterState","checked","distance","blocksize","alpha","color","isExisty","useAlpha","add","mode","apply","checkboxGroup","closest","classList","remove","_getFilterOption","option","parseFloat","blurRange","slider","toggleDirection","blurFilterRange","_pickerWithRange","pickerControl","_pickerWithSelectbox","colorPickerControls","push","rangeWrap","document","createElement","rangelabel","id","innerHTML","appendChild","style","height","tintOpacityRange","selectlistWrap","selectlist","optionlist","className","_makeSelectOptionList","_drawSelectOptionList","_pickerWithSelectboxForAddEvent","querySelectorAll","optionElement","setAttribute","optionValue","target","getAttribute","fireEvent","createEvent","querySelector","selected","initEvent","dispatchEvent","display","preventDefault","selectOption","replace","$0","toUpperCase"],"mappings":"AAAA,OAAOA,OAAP,MAAoB,kBAApB;AACA,OAAOC,WAAP,MAAwB,qBAAxB;AACA,OAAOC,KAAP,MAAkB,eAAlB;AACA,OAAOC,OAAP,MAAoB,eAApB;AACA,OAAOC,YAAP,MAAyB,2BAAzB;AACA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,oBAAjC,QAA6D,SAA7D;AACA,SAASC,uBAAuB,IAAIC,YAApC,QAAwD,WAAxD;AAEA,MAAMC,qBAAqB,GAAG,OAA9B;AACA,MAAMC,aAAa,GAAG,CAAC,KAAD,EAAQ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A0C,MAAAA,YAAY,CAAC1B,SAAb,GAAyBhB,MAAM,CAAC2C,OAAP,CAAe,QAAf,EAA0BC,EAAD,IAAQA,EAAE,CAACC,WAAH,EAAjC,CAAzB;AACAvB,MAAAA,UAAU,CAACL,WAAX,CAAuByB,YAAvB;AACD,KALD;AAMD;;AA3Y0B;;AA8Y7B,eAAelH,MAAf","sourcesContent":["import snippet from 'tui-code-snippet';\r\nimport Colorpicker from './tools/colorpicker';\r\nimport Range from './tools/range';\r\nimport Submenu from './submenuBase';\r\nimport templateHtml from './template/submenu/filter';\r\nimport { toInteger, toCamelCase, assignmentForDestroy } from '../util';\r\nimport { defaultFilterRangeValus as FILTER_RANGE } from '../consts';\r\n\r\nconst PICKER_CONTROL_HEIGHT = '130px';\r\nconst BLEND_OPTIONS = ['add', 'diff', 'subtract', 'multiply', 'screen', 'lighten', 'darken'];\r\nconst FILTER_OPTIONS = [\r\n  'grayscale',\r\n  'invert',\r\n  'sepia',\r\n  'vintage',\r\n  'blur',\r\n  'sharpen',\r\n  'emboss',\r\n  'remove-white',\r\n  'brightness',\r\n  'noise',\r\n  'pixelate',\r\n  'color-filter',\r\n  'tint',\r\n  'multiply',\r\n  'blend',\r\n];\r\n\r\nconst filterNameMap = {\r\n  grayscale: 'grayscale',\r\n  invert: 'invert',\r\n  sepia: 'sepia',\r\n  blur: 'blur',\r\n  sharpen: 'sharpen',\r\n  emboss: 'emboss',\r\n  removeWhite: 'removeColor',\r\n  brightness: 'brightness',\r\n  contrast: 'contrast',\r\n  saturation: 'saturation',\r\n  vintage: 'vintage',\r\n  polaroid: 'polaroid',\r\n  noise: 'noise',\r\n  pixelate: 'pixelate',\r\n  colorFilter: 'removeColor',\r\n  tint: 'blendColor',\r\n  multiply: 'blendColor',\r\n  blend: 'blendColor',\r\n  hue: 'hue',\r\n  gamma: 'gamma',\r\n};\r\n\r\nconst RANGE_INSTANCE_NAMES = [\r\n  'removewhiteDistanceRange',\r\n  'colorfilterThresholeRange',\r\n  'pixelateRange',\r\n  'noiseRange',\r\n  'brightnessRange',\r\n  'tintOpacity',\r\n];\r\nconst COLORPICKER_INSTANCE_NAMES = ['filterBlendColor', 'filterMultiplyColor', 'filterTintColor'];\r\n\r\n/**\r\n * Filter ui class\r\n * @class\r\n * @ignore\r\n */\r\nclass Filter extends Submenu {\r\n  constructor(subMenuElement, { locale, menuBarPosition, usageStatistics }) {\r\n    super(subMenuElement, {\r\n      locale,\r\n      name: 'filter',\r\n      menuBarPosition,\r\n      templateHtml,\r\n      usageStatistics,\r\n    });\r\n\r\n    this.selectBoxShow = false;\r\n\r\n    this.checkedMap = {};\r\n    this._makeControlElement();\r\n  }\r\n\r\n  /**\r\n   * Destroys the instance.\r\n   */\r\n  destroy() {\r\n    this._removeEvent();\r\n    this._destroyToolInstance();\r\n\r\n    assignmentForDestroy(this);\r\n  }\r\n\r\n  /**\r\n   * Remove event for filter\r\n   */\r\n  _removeEvent() {\r\n    snippet.forEach(FILTER_OPTIONS, (filter) => {\r\n      const filterCheckElement = this.selector(`.tie-${filter}`);\r\n      const filterNameCamelCase = toCamelCase(filter);\r\n\r\n      filterCheckElement.removeEventListener('change', this.eventHandler[filterNameCamelCase]);\r\n    });\r\n\r\n    snippet.forEach([...RANGE_INSTANCE_NAMES, ...COLORPICKER_INSTANCE_NAMES], (instanceName) => {\r\n      this._els[instanceName].off();\r\n    });\r\n\r\n    this._els.blendType.removeEventListener('change', this.eventHandler.changeBlendFilter);\r\n    this._els.blendType.removeEventListener('click', this.eventHandler.changeBlendFilter);\r\n  }\r\n\r\n  _destroyToolInstance() {\r\n    snippet.forEach([...RANGE_INSTANCE_NAMES, ...COLORPICKER_INSTANCE_NAMES], (instanceName) => {\r\n      this._els[instanceName].destroy();\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Add event for filter\r\n   * @param {Object} actions - actions for crop\r\n   *   @param {Function} actions.applyFilter - apply filter option\r\n   */\r\n  addEvent({ applyFilter }) {\r\n    const changeFilterState = (filterName) =>\r\n      this._changeFilterState.bind(this, applyFilter, filterName);\r\n    const changeFilterStateForRange = (filterName) => (value, isLast) =>\r\n      this._changeFilterState(applyFilter, filterName, isLast);\r\n\r\n    this.eventHandler = {\r\n      changeBlendFilter: changeFilterState('blend'),\r\n      blandTypeClick: (event) => event.stopPropagation(),\r\n    };\r\n\r\n    snippet.forEach(FILTER_OPTIONS, (filter) => {\r\n      const filterCheckElement = this.selector(`.tie-${filter}`);\r\n      const filterNameCamelCase = toCamelCase(filter);\r\n      this.checkedMap[filterNameCamelCase] = filterCheckElement;\r\n      this.eventHandler[filterNameCamelCase] = changeFilterState(filterNameCamelCase);\r\n\r\n      filterCheckElement.addEventListener('change', this.eventHandler[filterNameCamelCase]);\r\n    });\r\n\r\n    this._els.removewhiteDistanceRange.on('change', changeFilterStateForRange('removeWhite'));\r\n    this._els.colorfilterThresholeRange.on('change', changeFilterStateForRange('colorFilter'));\r\n    this._els.pixelateRange.on('change', changeFilterStateForRange('pixelate'));\r\n    this._els.noiseRange.on('change', changeFilterStateForRange('noise'));\r\n    this._els.brightnessRange.on('change', changeFilterStateForRange('brightness'));\r\n\r\n    this._els.filterBlendColor.on('change', this.eventHandler.changeBlendFilter);\r\n    this._els.filterMultiplyColor.on('change', changeFilterState('multiply'));\r\n    this._els.filterTintColor.on('change', changeFilterState('tint'));\r\n    this._els.tintOpacity.on('change', changeFilterStateForRange('tint'));\r\n    this._els.filterMultiplyColor.on('changeShow', this.colorPickerChangeShow.bind(this));\r\n    this._els.filterTintColor.on('changeShow', this.colorPickerChangeShow.bind(this));\r\n    this._els.filterBlendColor.on('changeShow', this.colorPickerChangeShow.bind(this));\r\n\r\n    this._els.blendType.addEventListener('change', this.eventHandler.changeBlendFilter);\r\n    this._els.blendType.addEventListener('click', this.eventHandler.blandTypeClick);\r\n  }\r\n\r\n  /**\r\n   * Set filter for undo changed\r\n   * @param {Object} chagedFilterInfos - changed command infos\r\n   *   @param {string} type - filter type\r\n   *   @param {string} action - add or remove\r\n   *   @param {Object} options - filter options\r\n   */\r\n  setFilterState(chagedFilterInfos) {\r\n    const { type, options, action } = chagedFilterInfos;\r\n    const filterName = this._getFilterNameFromOptions(type, options);\r\n    const isRemove = action === 'remove';\r\n\r\n    if (!isRemove) {\r\n      this._setFilterState(filterName, options);\r\n    }\r\n\r\n    this.checkedMap[filterName].checked = !isRemove;\r\n  }\r\n\r\n  /**\r\n   * Set filter for undo changed\r\n   * @param {string} filterName - filter name\r\n   * @param {Object} options - filter options\r\n   * @private\r\n   */\r\n  // eslint-disable-next-line complexity\r\n  _setFilterState(filterName, options) {\r\n    if (filterName === 'colorFilter') {\r\n      this._els.colorfilterThresholeRange.value = options.distance;\r\n    } else if (filterName === 'removeWhite') {\r\n      this._els.removewhiteDistanceRange.value = options.distance;\r\n    } else if (filterName === 'pixelate') {\r\n      this._els.pixelateRange.value = options.blocksize;\r\n    } else if (filterName === 'brightness') {\r\n      this._els.brightnessRange.value = options.brightness;\r\n    } else if (filterName === 'noise') {\r\n      this._els.noiseRange.value = options.noise;\r\n    } else if (filterName === 'tint') {\r\n      this._els.tintOpacity.value = options.alpha;\r\n      this._els.filterTintColor.color = options.color;\r\n    } else if (filterName === 'blend') {\r\n      this._els.filterBlendColor.color = options.color;\r\n    } else if (filterName === 'multiply') {\r\n      this._els.filterMultiplyColor.color = options.color;\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Get filter name\r\n   * @param {string} type - filter type\r\n   * @param {Object} options - filter options\r\n   * @returns {string} filter name\r\n   * @private\r\n   */\r\n  _getFilterNameFromOptions(type, options) {\r\n    let filterName = type;\r\n\r\n    if (type === 'removeColor') {\r\n      filterName = snippet.isExisty(options.useAlpha) ? 'removeWhite' : 'colorFilter';\r\n    } else if (type === 'blendColor') {\r\n      filterName = {\r\n        add: 'blend',\r\n        multiply: 'multiply',\r\n        tint: 'tint',\r\n      }[options.mode];\r\n    }\r\n\r\n    return filterName;\r\n  }\r\n\r\n  /**\r\n   * Add event for filter\r\n   * @param {Function} applyFilter - actions for firter\r\n   * @param {string} filterName - filter name\r\n   * @param {boolean} [isLast] - Is last change\r\n   */\r\n  _changeFilterState(applyFilter, filterName, isLast = true) {\r\n    const apply = this.checkedMap[filterName].checked;\r\n    const type = filterNameMap[filterName];\r\n\r\n    const checkboxGroup = this.checkedMap[filterName].closest('.tui-image-editor-checkbox-group');\r\n    if (checkboxGroup) {\r\n      if (apply) {\r\n        checkboxGroup.classList.remove('tui-image-editor-disabled');\r\n      } else {\r\n        checkboxGroup.classList.add('tui-image-editor-disabled');\r\n      }\r\n    }\r\n    applyFilter(apply, type, this._getFilterOption(filterName), !isLast);\r\n  }\r\n\r\n  /**\r\n   * Get filter option\r\n   * @param {String} type - filter type\r\n   * @returns {Object} filter option object\r\n   * @private\r\n   */\r\n  // eslint-disable-next-line complexity\r\n  _getFilterOption(type) {\r\n    const option = {};\r\n    switch (type) {\r\n      case 'removeWhite':\r\n        option.color = '#FFFFFF';\r\n        option.useAlpha = false;\r\n        option.distance = parseFloat(this._els.removewhiteDistanceRange.value);\r\n        break;\r\n      case 'colorFilter':\r\n        option.color = '#FFFFFF';\r\n        option.distance = parseFloat(this._els.colorfilterThresholeRange.value);\r\n        break;\r\n      case 'pixelate':\r\n        option.blocksize = toInteger(this._els.pixelateRange.value);\r\n        break;\r\n      case 'noise':\r\n        option.noise = toInteger(this._els.noiseRange.value);\r\n        break;\r\n      case 'brightness':\r\n        option.brightness = parseFloat(this._els.brightnessRange.value);\r\n        break;\r\n      case 'blend':\r\n        option.mode = 'add';\r\n        option.color = this._els.filterBlendColor.color;\r\n        option.mode = this._els.blendType.value;\r\n        break;\r\n      case 'multiply':\r\n        option.mode = 'multiply';\r\n        option.color = this._els.filterMultiplyColor.color;\r\n        break;\r\n      case 'tint':\r\n        option.mode = 'tint';\r\n        option.color = this._els.filterTintColor.color;\r\n        option.alpha = this._els.tintOpacity.value;\r\n        break;\r\n      case 'blur':\r\n        option.blur = this._els.blurRange.value;\r\n        break;\r\n      default:\r\n        break;\r\n    }\r\n\r\n    return option;\r\n  }\r\n\r\n  /**\r\n   * Make submenu range and colorpicker control\r\n   * @private\r\n   */\r\n  _makeControlElement() {\r\n    this._els = {\r\n      removewhiteDistanceRange: new Range(\r\n        { slider: this.selector('.tie-removewhite-distance-range') },\r\n        FILTER_RANGE.removewhiteDistanceRange\r\n      ),\r\n      brightnessRange: new Range(\r\n        { slider: this.selector('.tie-brightness-range') },\r\n        FILTER_RANGE.brightnessRange\r\n      ),\r\n      noiseRange: new Range({ slider: this.selector('.tie-noise-range') }, FILTER_RANGE.noiseRange),\r\n      pixelateRange: new Range(\r\n        { slider: this.selector('.tie-pixelate-range') },\r\n        FILTER_RANGE.pixelateRange\r\n      ),\r\n      colorfilterThresholeRange: new Range(\r\n        { slider: this.selector('.tie-colorfilter-threshole-range') },\r\n        FILTER_RANGE.colorfilterThresholeRange\r\n      ),\r\n      filterTintColor: new Colorpicker(\r\n        this.selector('.tie-filter-tint-color'),\r\n        '#03bd9e',\r\n        this.toggleDirection,\r\n        this.usageStatistics\r\n      ),\r\n      filterMultiplyColor: new Colorpicker(\r\n        this.selector('.tie-filter-multiply-color'),\r\n        '#515ce6',\r\n        this.toggleDirection,\r\n        this.usageStatistics\r\n      ),\r\n      filterBlendColor: new Colorpicker(\r\n        this.selector('.tie-filter-blend-color'),\r\n        '#ffbb3b',\r\n        this.toggleDirection,\r\n        this.usageStatistics\r\n      ),\r\n      blurRange: FILTER_RANGE.blurFilterRange,\r\n    };\r\n\r\n    this._els.tintOpacity = this._pickerWithRange(this._els.filterTintColor.pickerControl);\r\n    this._els.blendType = this._pickerWithSelectbox(this._els.filterBlendColor.pickerControl);\r\n\r\n    this.colorPickerControls.push(this._els.filterTintColor);\r\n    this.colorPickerControls.push(this._els.filterMultiplyColor);\r\n    this.colorPickerControls.push(this._els.filterBlendColor);\r\n  }\r\n\r\n  /**\r\n   * Make submenu control for picker & range mixin\r\n   * @param {HTMLElement} pickerControl - pickerControl dom element\r\n   * @returns {Range}\r\n   * @private\r\n   */\r\n  _pickerWithRange(pickerControl) {\r\n    const rangeWrap = document.createElement('div');\r\n    const rangelabel = document.createElement('label');\r\n    const slider = document.createElement('div');\r\n\r\n    slider.id = 'tie-filter-tint-opacity';\r\n    rangelabel.innerHTML = 'Opacity';\r\n    rangeWrap.appendChild(rangelabel);\r\n    rangeWrap.appendChild(slider);\r\n    pickerControl.appendChild(rangeWrap);\r\n    pickerControl.style.height = PICKER_CONTROL_HEIGHT;\r\n\r\n    return new Range({ slider }, FILTER_RANGE.tintOpacityRange);\r\n  }\r\n\r\n  /**\r\n   * Make submenu control for picker & selectbox\r\n   * @param {HTMLElement} pickerControl - pickerControl dom element\r\n   * @returns {HTMLElement}\r\n   * @private\r\n   */\r\n  _pickerWithSelectbox(pickerControl) {\r\n    const selectlistWrap = document.createElement('div');\r\n    const selectlist = document.createElement('select');\r\n    const optionlist = document.createElement('ul');\r\n\r\n    selectlistWrap.className = 'tui-image-editor-selectlist-wrap';\r\n    optionlist.className = 'tui-image-editor-selectlist';\r\n\r\n    selectlistWrap.appendChild(selectlist);\r\n    selectlistWrap.appendChild(optionlist);\r\n\r\n    this._makeSelectOptionList(selectlist);\r\n\r\n    pickerControl.appendChild(selectlistWrap);\r\n    pickerControl.style.height = PICKER_CONTROL_HEIGHT;\r\n\r\n    this._drawSelectOptionList(selectlist, optionlist);\r\n    this._pickerWithSelectboxForAddEvent(selectlist, optionlist);\r\n\r\n    return selectlist;\r\n  }\r\n\r\n  /**\r\n   * Make selectbox option list custom style\r\n   * @param {HTMLElement} selectlist - selectbox element\r\n   * @param {HTMLElement} optionlist - custom option list item element\r\n   * @private\r\n   */\r\n  _drawSelectOptionList(selectlist, optionlist) {\r\n    const options = selectlist.querySelectorAll('option');\r\n    snippet.forEach(options, (option) => {\r\n      const optionElement = document.createElement('li');\r\n      optionElement.innerHTML = option.innerHTML;\r\n      optionElement.setAttribute('data-item', option.value);\r\n      optionlist.appendChild(optionElement);\r\n    });\r\n  }\r\n\r\n  /**\r\n   * custome selectbox custom event\r\n   * @param {HTMLElement} selectlist - selectbox element\r\n   * @param {HTMLElement} optionlist - custom option list item element\r\n   * @private\r\n   */\r\n  _pickerWithSelectboxForAddEvent(selectlist, optionlist) {\r\n    optionlist.addEventListener('click', (event) => {\r\n      const optionValue = event.target.getAttribute('data-item');\r\n      const fireEvent = document.createEvent('HTMLEvents');\r\n\r\n      selectlist.querySelector(`[value=\"${optionValue}\"]`).selected = true;\r\n      fireEvent.initEvent('change', true, true);\r\n\r\n      selectlist.dispatchEvent(fireEvent);\r\n\r\n      this.selectBoxShow = false;\r\n      optionlist.style.display = 'none';\r\n    });\r\n\r\n    selectlist.addEventListener('mousedown', (event) => {\r\n      event.preventDefault();\r\n      this.selectBoxShow = !this.selectBoxShow;\r\n      optionlist.style.display = this.selectBoxShow ? 'block' : 'none';\r\n      optionlist.setAttribute('data-selectitem', selectlist.value);\r\n      optionlist.querySelector(`[data-item='${selectlist.value}']`).classList.add('active');\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Make option list for select control\r\n   * @param {HTMLElement} selectlist - blend option select list element\r\n   * @private\r\n   */\r\n  _makeSelectOptionList(selectlist) {\r\n    snippet.forEach(BLEND_OPTIONS, (option) => {\r\n      const selectOption = document.createElement('option');\r\n      selectOption.setAttribute('value', option);\r\n      selectOption.innerHTML = option.replace(/^[a-z]/, ($0) => $0.toUpperCase());\r\n      selectlist.appendChild(selectOption);\r\n    });\r\n  }\r\n}\r\n\r\nexport default Filter;\r\n"]},"metadata":{},"sourceType":"module"}