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;
});
|