PHP Classes

File: toastui/src/js/command/addObject.js

Recommend this page to a friend!
  Classes of Mark de Leon   PHP Document Scanner using SANE or eSCL AirPrint   toastui/src/js/command/addObject.js   Download  
File: toastui/src/js/command/addObject.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,313 bytes
 

Contents

Class file image Download
/** * @author NHN Ent. FE Development Team <dl_javascript@nhn.com> * @fileoverview Add an object */ import commandFactory from '../factory/command'; import Promise from 'core-js/library/es6/promise'; import consts from '../consts'; const {commandNames, rejectMessages} = consts; const command = { name: commandNames.ADD_OBJECT, /** * Add an object * @param {Graphics} graphics - Graphics instance * @param {Object} object - Fabric object * @returns {Promise} */ execute(graphics, object) { return new Promise((resolve, reject) => { if (!graphics.contains(object)) { graphics.add(object); resolve(object); } else { reject(rejectMessages.addedObject); } }); }, /** * @param {Graphics} graphics - Graphics instance * @param {Object} object - Fabric object * @returns {Promise} */ undo(graphics, object) { return new Promise((resolve, reject) => { if (graphics.contains(object)) { graphics.remove(object); resolve(object); } else { reject(rejectMessages.noObject); } }); } }; commandFactory.register(command); module.exports = command;