js-draw
Version:
Draw pictures using a pen, touchscreen, or mouse! JS-draw is a drawing library for JavaScript and TypeScript.
57 lines (56 loc) • 2.78 kB
JavaScript
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _ActionButtonWidget_autoDisableInReadOnlyEditors, _ActionButtonWidget_helpText;
import BaseWidget from './BaseWidget.mjs';
class ActionButtonWidget extends BaseWidget {
constructor(editor, id, makeIcon, title, clickAction, localizationTable, mustBeToplevel = false, autoDisableInReadOnlyEditors = true) {
super(editor, id, localizationTable);
this.makeIcon = makeIcon;
this.title = title;
this.clickAction = clickAction;
this.mustBeToplevel = mustBeToplevel;
_ActionButtonWidget_autoDisableInReadOnlyEditors.set(this, void 0);
_ActionButtonWidget_helpText.set(this, undefined);
__classPrivateFieldSet(this, _ActionButtonWidget_autoDisableInReadOnlyEditors, autoDisableInReadOnlyEditors, "f");
}
/**
* Sets the text shown in a help overlay for this button.
*
* See {@link getHelpText}.
*/
setHelpText(helpText) {
__classPrivateFieldSet(this, _ActionButtonWidget_helpText, helpText, "f");
}
getHelpText() {
return __classPrivateFieldGet(this, _ActionButtonWidget_helpText, "f");
}
shouldAutoDisableInReadOnlyEditor() {
return __classPrivateFieldGet(this, _ActionButtonWidget_autoDisableInReadOnlyEditors, "f");
}
handleClick() {
this.clickAction();
}
getTitle() {
return this.title;
}
createIcon() {
return this.makeIcon();
}
fillDropdown(_dropdown) {
return false;
}
mustBeInToplevelMenu() {
return this.mustBeToplevel;
}
}
_ActionButtonWidget_autoDisableInReadOnlyEditors = new WeakMap(), _ActionButtonWidget_helpText = new WeakMap();
export default ActionButtonWidget;