mj-context-menu
Version:
A generic context menu
54 lines • 2.06 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Command = void 0;
var abstract_item_js_1 = require("./abstract_item.js");
var MenuUtil = require("./menu_util.js");
var Command = (function (_super) {
__extends(Command, _super);
function Command(menu, content, command, id) {
var _this = _super.call(this, menu, 'command', content, id) || this;
_this.command = command;
return _this;
}
Command.fromJson = function (_factory, _a, menu) {
var content = _a.content, action = _a.action, id = _a.id;
return new this(menu, content, action, id);
};
Command.prototype.mousedown = function (event) {
this.stop(event);
};
Command.prototype.mouseup = function (event) {
this.press();
this.stop(event);
};
Command.prototype.executeAction = function () {
try {
this.command(MenuUtil.getActiveElement(this));
}
catch (e) {
MenuUtil.error(e, 'Illegal command callback.');
}
MenuUtil.close(this);
};
Command.prototype.toJson = function () {
return { type: '' };
};
return Command;
}(abstract_item_js_1.AbstractItem));
exports.Command = Command;
//# sourceMappingURL=item_command.js.map