d0b1f2d507bb6a3215fce2a2e233dc37.json
10.2 KB
{"ast":null,"code":"import Range from './tools/range';\nimport Submenu from './submenuBase';\nimport templateHtml from './template/submenu/rotate';\nimport { toInteger, assignmentForDestroy } from '../util';\nimport { defaultRotateRangeValus } from '../consts';\nconst CLOCKWISE = 30;\nconst COUNTERCLOCKWISE = -30;\n/**\r\n * Rotate ui class\r\n * @class\r\n * @ignore\r\n */\n\nclass Rotate extends Submenu {\n constructor(subMenuElement, {\n locale,\n makeSvgIcon,\n menuBarPosition,\n usageStatistics\n }) {\n super(subMenuElement, {\n locale,\n name: 'rotate',\n makeSvgIcon,\n menuBarPosition,\n templateHtml,\n usageStatistics\n });\n this._value = 0;\n this._els = {\n rotateButton: this.selector('.tie-retate-button'),\n rotateRange: new Range({\n slider: this.selector('.tie-rotate-range'),\n input: this.selector('.tie-ratate-range-value')\n }, defaultRotateRangeValus)\n };\n }\n /**\r\n * Destroys the instance.\r\n */\n\n\n destroy() {\n this._removeEvent();\n\n this._els.rotateRange.destroy();\n\n assignmentForDestroy(this);\n }\n\n setRangeBarAngle(type, angle) {\n let resultAngle = angle;\n\n if (type === 'rotate') {\n resultAngle = parseInt(this._els.rotateRange.value, 10) + angle;\n }\n\n this._setRangeBarRatio(resultAngle);\n }\n\n _setRangeBarRatio(angle) {\n this._els.rotateRange.value = angle;\n }\n /**\r\n * Add event for rotate\r\n * @param {Object} actions - actions for crop\r\n * @param {Function} actions.rotate - rotate action\r\n * @param {Function} actions.setAngle - set angle action\r\n */\n\n\n addEvent(actions) {\n this.eventHandler.rotationAngleChanged = this._changeRotateForButton.bind(this); // {rotate, setAngle}\n\n this.actions = actions;\n\n this._els.rotateButton.addEventListener('click', this.eventHandler.rotationAngleChanged);\n\n this._els.rotateRange.on('change', this._changeRotateForRange.bind(this));\n }\n /**\r\n * Remove event\r\n * @private\r\n */\n\n\n _removeEvent() {\n this._els.rotateButton.removeEventListener('click', this.eventHandler.rotationAngleChanged);\n\n this._els.rotateRange.off();\n }\n /**\r\n * Change rotate for range\r\n * @param {number} value - angle value\r\n * @param {boolean} isLast - Is last change\r\n * @private\r\n */\n\n\n _changeRotateForRange(value, isLast) {\n const angle = toInteger(value);\n this.actions.setAngle(angle, !isLast);\n this._value = angle;\n }\n /**\r\n * Change rotate for button\r\n * @param {object} event - add button event object\r\n * @private\r\n */\n\n\n _changeRotateForButton(event) {\n const button = event.target.closest('.tui-image-editor-button');\n const angle = this._els.rotateRange.value;\n\n if (button) {\n const rotateType = this.getButtonType(button, ['counterclockwise', 'clockwise']);\n const rotateAngle = {\n clockwise: CLOCKWISE,\n counterclockwise: COUNTERCLOCKWISE\n }[rotateType];\n const newAngle = parseInt(angle, 10) + rotateAngle;\n const isRotatable = newAngle >= -360 && newAngle <= 360;\n\n if (isRotatable) {\n this.actions.rotate(rotateAngle);\n }\n }\n }\n\n}\n\nexport default Rotate;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/src/js/ui/rotate.js"],"names":["Range","Submenu","templateHtml","toInteger","assignmentForDestroy","defaultRotateRangeValus","CLOCKWISE","COUNTERCLOCKWISE","Rotate","constructor","subMenuElement","locale","makeSvgIcon","menuBarPosition","usageStatistics","name","_value","_els","rotateButton","selector","rotateRange","slider","input","destroy","_removeEvent","setRangeBarAngle","type","angle","resultAngle","parseInt","value","_setRangeBarRatio","addEvent","actions","eventHandler","rotationAngleChanged","_changeRotateForButton","bind","addEventListener","on","_changeRotateForRange","removeEventListener","off","isLast","setAngle","event","button","target","closest","rotateType","getButtonType","rotateAngle","clockwise","counterclockwise","newAngle","isRotatable","rotate"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,eAAlB;AACA,OAAOC,OAAP,MAAoB,eAApB;AACA,OAAOC,YAAP,MAAyB,2BAAzB;AACA,SAASC,SAAT,EAAoBC,oBAApB,QAAgD,SAAhD;AACA,SAASC,uBAAT,QAAwC,WAAxC;AAEA,MAAMC,SAAS,GAAG,EAAlB;AACA,MAAMC,gBAAgB,GA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AmBJ,MAAnB,EAA2B,CAAC,kBAAD,EAAqB,WAArB,CAA3B,CAAnB;AACA,YAAMK,WAAW,GAAG;AAClBC,QAAAA,SAAS,EAAE9C,SADO;AAElB+C,QAAAA,gBAAgB,EAAE9C;AAFA,QAGlB0C,UAHkB,CAApB;AAIA,YAAMK,QAAQ,GAAGzB,QAAQ,CAACF,KAAD,EAAQ,EAAR,CAAR,GAAsBwB,WAAvC;AACA,YAAMI,WAAW,GAAGD,QAAQ,IAAI,CAAC,GAAb,IAAoBA,QAAQ,IAAI,GAApD;;AACA,UAAIC,WAAJ,EAAiB;AACf,aAAKtB,OAAL,CAAauB,MAAb,CAAoBL,WAApB;AACD;AACF;AACF;;AAzG0B;;AA4G7B,eAAe3C,MAAf","sourcesContent":["import Range from './tools/range';\r\nimport Submenu from './submenuBase';\r\nimport templateHtml from './template/submenu/rotate';\r\nimport { toInteger, assignmentForDestroy } from '../util';\r\nimport { defaultRotateRangeValus } from '../consts';\r\n\r\nconst CLOCKWISE = 30;\r\nconst COUNTERCLOCKWISE = -30;\r\n\r\n/**\r\n * Rotate ui class\r\n * @class\r\n * @ignore\r\n */\r\nclass Rotate extends Submenu {\r\n constructor(subMenuElement, { locale, makeSvgIcon, menuBarPosition, usageStatistics }) {\r\n super(subMenuElement, {\r\n locale,\r\n name: 'rotate',\r\n makeSvgIcon,\r\n menuBarPosition,\r\n templateHtml,\r\n usageStatistics,\r\n });\r\n this._value = 0;\r\n\r\n this._els = {\r\n rotateButton: this.selector('.tie-retate-button'),\r\n rotateRange: new Range(\r\n {\r\n slider: this.selector('.tie-rotate-range'),\r\n input: this.selector('.tie-ratate-range-value'),\r\n },\r\n defaultRotateRangeValus\r\n ),\r\n };\r\n }\r\n\r\n /**\r\n * Destroys the instance.\r\n */\r\n destroy() {\r\n this._removeEvent();\r\n this._els.rotateRange.destroy();\r\n\r\n assignmentForDestroy(this);\r\n }\r\n\r\n setRangeBarAngle(type, angle) {\r\n let resultAngle = angle;\r\n\r\n if (type === 'rotate') {\r\n resultAngle = parseInt(this._els.rotateRange.value, 10) + angle;\r\n }\r\n\r\n this._setRangeBarRatio(resultAngle);\r\n }\r\n\r\n _setRangeBarRatio(angle) {\r\n this._els.rotateRange.value = angle;\r\n }\r\n\r\n /**\r\n * Add event for rotate\r\n * @param {Object} actions - actions for crop\r\n * @param {Function} actions.rotate - rotate action\r\n * @param {Function} actions.setAngle - set angle action\r\n */\r\n addEvent(actions) {\r\n this.eventHandler.rotationAngleChanged = this._changeRotateForButton.bind(this);\r\n\r\n // {rotate, setAngle}\r\n this.actions = actions;\r\n this._els.rotateButton.addEventListener('click', this.eventHandler.rotationAngleChanged);\r\n this._els.rotateRange.on('change', this._changeRotateForRange.bind(this));\r\n }\r\n\r\n /**\r\n * Remove event\r\n * @private\r\n */\r\n _removeEvent() {\r\n this._els.rotateButton.removeEventListener('click', this.eventHandler.rotationAngleChanged);\r\n this._els.rotateRange.off();\r\n }\r\n\r\n /**\r\n * Change rotate for range\r\n * @param {number} value - angle value\r\n * @param {boolean} isLast - Is last change\r\n * @private\r\n */\r\n _changeRotateForRange(value, isLast) {\r\n const angle = toInteger(value);\r\n this.actions.setAngle(angle, !isLast);\r\n this._value = angle;\r\n }\r\n\r\n /**\r\n * Change rotate for button\r\n * @param {object} event - add button event object\r\n * @private\r\n */\r\n _changeRotateForButton(event) {\r\n const button = event.target.closest('.tui-image-editor-button');\r\n const angle = this._els.rotateRange.value;\r\n\r\n if (button) {\r\n const rotateType = this.getButtonType(button, ['counterclockwise', 'clockwise']);\r\n const rotateAngle = {\r\n clockwise: CLOCKWISE,\r\n counterclockwise: COUNTERCLOCKWISE,\r\n }[rotateType];\r\n const newAngle = parseInt(angle, 10) + rotateAngle;\r\n const isRotatable = newAngle >= -360 && newAngle <= 360;\r\n if (isRotatable) {\r\n this.actions.rotate(rotateAngle);\r\n }\r\n }\r\n }\r\n}\r\n\r\nexport default Rotate;\r\n"]},"metadata":{},"sourceType":"module"}