all files / spreadsheet/services/ action-events.js

100% Statements 45/45
97.96% Branches 48/49
100% Functions 7/7
100% Lines 45/45
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69   1256× 1256×   9863× 9863× 9863× 9863× 517× 517×   9863× 334× 334×   9863× 9863× 9863×               1367×   9863× 7766×   9863× 517×   9863× 334×     9988× 9988× 9988× 9988× 9988×   9988× 8976×   9988×   1256× 1256× 1256×   1256× 1256× 1256×        
define(["require", "exports", "../../workbook/index", "../../workbook/index", "../common/index", "../common/index"], function (require, exports, index_1, index_2, index_3, index_4) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ActionEvents = (function () {
        function ActionEvents(parent) {
            this.parent = parent;
            this.addEventListener();
        }
        ActionEvents.prototype.actionBeginHandler = function (args) {
            var preventAction = args.preventAction;
            delete args.preventAction;
            var actionArgs = { action: args.action };
            if (args.isUndo) {
                actionArgs.isUndo = true;
                delete args.isUndo;
            }
            if (args.isRedo) {
                actionArgs.isUndo = false;
                delete args.isRedo;
            }
            actionArgs.args = args;
            this.parent.trigger('actionBegin', actionArgs);
            if (!preventAction && !this.parent.isPrintingProcessing && (args.action === 'clipboard' || args.action === 'format' ||
                args.action === 'cellSave' || args.action === 'addNote' || args.action === 'editNote' || args.action === 'deleteNote' ||
                args.action === 'beforeWrap' || args.action === 'beforeReplace' || args.action === 'filter' || args.action === 'beforeClear' ||
                args.action === 'beforeInsertImage' || args.action === 'beforeInsertChart' || args.action === 'chartDesign' ||
                args.action === 'cellDelete' || args.action === 'autofill' || args.action === 'validation' ||
                args.action === 'removeValidation' || args.action === 'hyperlink' || args.action === 'removeHyperlink' || args.action === 'deleteImage' ||
                args.action === 'addComment' || args.action === 'editComment' || args.action === 'deleteComment' || args.action === 'resolveComment' ||
                args.action === 'reopenComment' || args.action === 'addReply' || args.action === 'editReply' || args.action === 'deleteReply')) {
                this.parent.notify(index_4.setActionData, { args: args });
            }
            if (preventAction) {
                args.preventAction = true;
            }
            if (actionArgs.isUndo) {
                args.isUndo = true;
            }
            if (actionArgs.isUndo === false) {
                args.isRedo = true;
            }
        };
        ActionEvents.prototype.actionCompleteHandler = function (args) {
            var preventAction = args.preventAction;
            delete args.preventAction;
            this.parent.notify(index_1.triggerDataChange, args);
            Eif (!args.preventEventTrigger) {
                this.parent.trigger('actionComplete', args);
            }
            if (!preventAction && args.action !== 'undoRedo' && args.action !== 'gotoSheet') {
                this.parent.notify(index_4.updateUndoRedoCollection, { args: args });
            }
            this.parent.notify(index_3.positionAutoFillElement, null);
        };
        ActionEvents.prototype.addEventListener = function () {
            this.parent.on(index_3.completeAction, this.actionCompleteHandler, this);
            this.parent.on(index_2.beginAction, this.actionBeginHandler, this);
            this.parent.on(index_4.spreadsheetDestroyed, this.removeEventListener, this);
        };
        ActionEvents.prototype.removeEventListener = function () {
            this.parent.off(index_3.completeAction, this.actionCompleteHandler);
            this.parent.off(index_2.beginAction, this.actionBeginHandler);
            this.parent.off(index_4.spreadsheetDestroyed, this.removeEventListener);
        };
        return ActionEvents;
    }());
    exports.ActionEvents = ActionEvents;
});