81a450b55f5fe5e72de24bfc99ef6ceb.json 7.03 KB
{"ast":null,"code":"import snippet from 'tui-code-snippet';\nimport { assignmentForDestroy } from '../util';\nimport Submenu from './submenuBase';\nimport templateHtml from './template/submenu/flip';\n/**\r\n * Flip ui class\r\n * @class\r\n * @ignore\r\n */\n\nclass Flip extends Submenu {\n  constructor(subMenuElement, {\n    locale,\n    makeSvgIcon,\n    menuBarPosition,\n    usageStatistics\n  }) {\n    super(subMenuElement, {\n      locale,\n      name: 'flip',\n      makeSvgIcon,\n      menuBarPosition,\n      templateHtml,\n      usageStatistics\n    });\n    this.flipStatus = false;\n    this._els = {\n      flipButton: this.selector('.tie-flip-button')\n    };\n  }\n  /**\r\n   * Destroys the instance.\r\n   */\n\n\n  destroy() {\n    this._removeEvent();\n\n    assignmentForDestroy(this);\n  }\n  /**\r\n   * Add event for flip\r\n   * @param {Object} actions - actions for flip\r\n   *   @param {Function} actions.flip - flip action\r\n   */\n\n\n  addEvent(actions) {\n    this.eventHandler.changeFlip = this._changeFlip.bind(this);\n    this._actions = actions;\n\n    this._els.flipButton.addEventListener('click', this.eventHandler.changeFlip);\n  }\n  /**\r\n   * Remove event\r\n   * @private\r\n   */\n\n\n  _removeEvent() {\n    this._els.flipButton.removeEventListener('click', this.eventHandler.changeFlip);\n  }\n  /**\r\n   * change Flip status\r\n   * @param {object} event - change event\r\n   * @private\r\n   */\n\n\n  _changeFlip(event) {\n    const button = event.target.closest('.tui-image-editor-button');\n\n    if (button) {\n      const flipType = this.getButtonType(button, ['flipX', 'flipY', 'resetFlip']);\n\n      if (!this.flipStatus && flipType === 'resetFlip') {\n        return;\n      }\n\n      this._actions.flip(flipType).then(flipStatus => {\n        const flipClassList = this._els.flipButton.classList;\n        this.flipStatus = false;\n        flipClassList.remove('resetFlip');\n        snippet.forEach(['flipX', 'flipY'], type => {\n          flipClassList.remove(type);\n\n          if (flipStatus[type]) {\n            flipClassList.add(type);\n            flipClassList.add('resetFlip');\n            this.flipStatus = true;\n          }\n        });\n      });\n    }\n  }\n\n}\n\nexport default Flip;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/src/js/ui/flip.js"],"names":["snippet","assignmentForDestroy","Submenu","templateHtml","Flip","constructor","subMenuElement","locale","makeSvgIcon","menuBarPosition","usageStatistics","name","flipStatus","_els","flipButton","selector","destroy","_removeEvent","addEvent","actions","eventHandler","changeFlip","_changeFlip","bind","_actions","addEventListener","removeEventListener","event","button","target","closest","flipType","getButtonType","flip","then","flipClassList","classList","remove","forEach","type","add"],"mappings":"AAAA,OAAOA,OAAP,MAAoB,kBAApB;AACA,SAASC,oBAAT,QAAqC,SAArC;AACA,OAAOC,OAAP,MAAoB,eAApB;AACA,OAAOC,YAAP,MAAyB,yBAAzB;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,IAAN,SAAmBF,OAAnB,CAA2B;AACzBG,EAAAA,WAAW,CAACC,cAAD,EAAiB;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,WAAV;AAAuBC,IAAAA,eAAvB;AAAwCC,IAAAA;AAAxC,GAAjB,EAA4E;AACrF,UAAMJ,cAAN,EAAsB;AACpBC,MAAAA,MADoB;AAEpBI,MAAAA,IAAI,EAAE,MAFc;AAGpBH,MAAAA,WAHoB;AAIpBC,MAAAA,eAJoB;AAKpBN,MAAAA,YALoB;AAMpBO,MAAAA;AANoB,KAAtB;AAQA,SAAKE,UAAL,GAAkB,KAAlB;AAEA,SAAKC,IAAL,GAAY;AACVC,MAAAA,UAAU,EAAE,KAAKC,QAAL,CAAc,kBAAd;AADF,KAAZ;AAGD;AAED;AACF;AACA;;;AACEC,EAAAA,OAAO,GAAG;AACR,SAAKC,YAAL;;AAEAhB,IAAAA,oBAAoB,CAAC,IAAD,CAApB;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEiB,EAAAA,QAAQ,CAACC,OAAD,EAAU;AAChB,SAAKC,YAAL,CAAkBC,UAAlB,GAA+B,KAAKC,WAAL,CAAiBC,IAAj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B;AACD;AACF,SAPD;AAQD,OAbD;AAcD;AACF;;AAzEwB;;AA4E3B,eAAeR,IAAf","sourcesContent":["import snippet from 'tui-code-snippet';\r\nimport { assignmentForDestroy } from '../util';\r\nimport Submenu from './submenuBase';\r\nimport templateHtml from './template/submenu/flip';\r\n\r\n/**\r\n * Flip ui class\r\n * @class\r\n * @ignore\r\n */\r\nclass Flip extends Submenu {\r\n  constructor(subMenuElement, { locale, makeSvgIcon, menuBarPosition, usageStatistics }) {\r\n    super(subMenuElement, {\r\n      locale,\r\n      name: 'flip',\r\n      makeSvgIcon,\r\n      menuBarPosition,\r\n      templateHtml,\r\n      usageStatistics,\r\n    });\r\n    this.flipStatus = false;\r\n\r\n    this._els = {\r\n      flipButton: this.selector('.tie-flip-button'),\r\n    };\r\n  }\r\n\r\n  /**\r\n   * Destroys the instance.\r\n   */\r\n  destroy() {\r\n    this._removeEvent();\r\n\r\n    assignmentForDestroy(this);\r\n  }\r\n\r\n  /**\r\n   * Add event for flip\r\n   * @param {Object} actions - actions for flip\r\n   *   @param {Function} actions.flip - flip action\r\n   */\r\n  addEvent(actions) {\r\n    this.eventHandler.changeFlip = this._changeFlip.bind(this);\r\n    this._actions = actions;\r\n    this._els.flipButton.addEventListener('click', this.eventHandler.changeFlip);\r\n  }\r\n\r\n  /**\r\n   * Remove event\r\n   * @private\r\n   */\r\n  _removeEvent() {\r\n    this._els.flipButton.removeEventListener('click', this.eventHandler.changeFlip);\r\n  }\r\n\r\n  /**\r\n   * change Flip status\r\n   * @param {object} event - change event\r\n   * @private\r\n   */\r\n  _changeFlip(event) {\r\n    const button = event.target.closest('.tui-image-editor-button');\r\n    if (button) {\r\n      const flipType = this.getButtonType(button, ['flipX', 'flipY', 'resetFlip']);\r\n      if (!this.flipStatus && flipType === 'resetFlip') {\r\n        return;\r\n      }\r\n\r\n      this._actions.flip(flipType).then((flipStatus) => {\r\n        const flipClassList = this._els.flipButton.classList;\r\n        this.flipStatus = false;\r\n\r\n        flipClassList.remove('resetFlip');\r\n        snippet.forEach(['flipX', 'flipY'], (type) => {\r\n          flipClassList.remove(type);\r\n          if (flipStatus[type]) {\r\n            flipClassList.add(type);\r\n            flipClassList.add('resetFlip');\r\n            this.flipStatus = true;\r\n          }\r\n        });\r\n      });\r\n    }\r\n  }\r\n}\r\n\r\nexport default Flip;\r\n"]},"metadata":{},"sourceType":"module"}