tui-image-editor.upgrade
Version:
TOAST UI Component: ImageEditor(fix bug)
72 lines (63 loc) • 1.77 kB
JavaScript
import Submenu from './submenuBase';
import templateHtml from './template/submenu/crop';
/**
* Crop ui class
* @class
* @ignore
*/
class Crop extends Submenu {
constructor(subMenuElement, {iconStyle, menuBarPosition}) {
super(subMenuElement, {
name: 'crop',
iconStyle,
menuBarPosition,
templateHtml
});
this.status = 'active';
this._els = {
apply: this.selector('#tie-crop-button .apply'),
cancel: this.selector('#tie-crop-button .cancel')
};
}
/**
* Add event for crop
* @param {Object} actions - actions for crop
* @param {Function} actions.crop - crop action
* @param {Function} actions.cancel - cancel action
*/
addEvent(actions) {
this.actions = actions;
this._els.apply.addEventListener('click', () => {
this.actions.crop();
this._els.apply.classList.remove('active');
});
this._els.cancel.addEventListener('click', () => {
this.actions.cancel();
this._els.apply.classList.remove('active');
});
}
/**
* Executed when the menu starts.
*/
changeStartMode() {
this.actions.modeChange('crop');
}
/**
* Returns the menu to its default state.
*/
changeStandbyMode() {
this.actions.stopDrawingMode();
}
/**
* Change apply button status
* @param {Boolean} enableStatus - apply button status
*/
changeApplyButtonStatus(enableStatus) {
if (enableStatus) {
this._els.apply.classList.add('active');
} else {
this._els.apply.classList.remove('active');
}
}
}
export default Crop;