PHP Classes

File: toastui/src/js/ui/mask.js

Recommend this page to a friend!
  Classes of Mark de Leon   PHP Document Scanner using SANE or eSCL AirPrint   toastui/src/js/ui/mask.js   Download  
File: toastui/src/js/ui/mask.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP Document Scanner using SANE or eSCL AirPrint
Web interface to scan printed documents
Author: By
Last change:
Date: 4 years ago
Size: 1,781 bytes
 

Contents

Class file image Download
import Submenu from './submenuBase'; import util from '../util'; import templateHtml from './template/submenu/mask'; /** * Mask ui class * @class * @ignore */ class Mask extends Submenu { constructor(subMenuElement, {locale, iconStyle, menuBarPosition}) { super(subMenuElement, { locale, name: 'mask', iconStyle, menuBarPosition, templateHtml }); this._els = { applyButton: this.selector('#tie-mask-apply'), maskImageButton: this.selector('#tie-mask-image-file') }; } /** * Add event for mask * @param {Object} actions - actions for crop * @param {Function} actions.loadImageFromURL - load image action * @param {Function} actions.applyFilter - apply filter action */ addEvent(actions) { this.actions = actions; this._els.maskImageButton.addEventListener('change', this._loadMaskFile.bind(this)); this._els.applyButton.addEventListener('click', this._applyMask.bind(this)); } /** * Apply mask * @private */ _applyMask() { this.actions.applyFilter(); this._els.applyButton.classList.remove('active'); } /** * Load mask file * @param {object} event - File change event object * @private */ _loadMaskFile(event) { let imgUrl; if (!util.isSupportFileApi()) { alert('This browser does not support file-api'); } const [file] = event.target.files; if (file) { imgUrl = URL.createObjectURL(file); this.actions.loadImageFromURL(imgUrl, file); this._els.applyButton.classList.add('active'); } } } export default Mask;