Menu to typescript

This commit is contained in:
Paulo Gustavo Veiga 2022-01-08 16:23:05 -08:00
parent 934d127012
commit f5cab1fc60
2 changed files with 13 additions and 11 deletions

View File

@ -349,7 +349,7 @@ class Designer extends Events {
} }
} }
export(formatType: 'png' | 'svg' | 'jpg' | 'wxml'): String { export(formatType: 'png' | 'svg' | 'jpg' | 'wxml'): Promise<String> {
const workspace = this._workspace; const workspace = this._workspace;
const svgElement = workspace.getSVGElement(); const svgElement = workspace.getSVGElement();
const size = workspace.getSize(); const size = workspace.getSize();

View File

@ -28,9 +28,10 @@ import ToolbarItem from './ToolbarItem';
import KeyboardShortcutTooltip from './KeyboardShortcutTooltip'; import KeyboardShortcutTooltip from './KeyboardShortcutTooltip';
import KeyboardShortcutDialog from './KeyboardShortcutDialog'; import KeyboardShortcutDialog from './KeyboardShortcutDialog';
import AccountSettingsPanel from './AccountSettingsPanel'; import AccountSettingsPanel from './AccountSettingsPanel';
import Designer from '../Designer';
class Menu extends IMenu { class Menu extends IMenu {
constructor(designer, containerId, mapId, readOnly, baseUrl = '') { constructor(designer: Designer, containerId: string, mapId: string, readOnly: boolean = false, baseUrl = '') {
super(designer, containerId, mapId); super(designer, containerId, mapId);
const saveElem = $('#save'); const saveElem = $('#save');
@ -80,6 +81,7 @@ class Menu extends IMenu {
const fontSizeModel = { const fontSizeModel = {
getValue() { getValue() {
const nodes = designerModel.filterSelectedTopics(); const nodes = designerModel.filterSelectedTopics();
let result = null; let result = null;
for (let i = 0; i < nodes.length; i++) { for (let i = 0; i < nodes.length; i++) {
const fontSize = nodes[i].getFontSize(); const fontSize = nodes[i].getFontSize();
@ -218,10 +220,10 @@ class Menu extends IMenu {
const formatExtension = 'jpg'; const formatExtension = 'jpg';
designer.export(formatExtension) designer.export(formatExtension)
.then((url) => { .then((url: string) => {
// Create hidden anchor to force download ... // Create hidden anchor to force download ...
const anchor = document.createElement('a'); const anchor: HTMLAnchorElement = document.createElement('a');
anchor.style = 'display: none'; anchor.style.display = 'none';
anchor.download = `${mapId}.${formatExtension}`; anchor.download = `${mapId}.${formatExtension}`;
anchor.href = url; anchor.href = url;
document.body.appendChild(anchor); document.body.appendChild(anchor);
@ -362,7 +364,7 @@ class Menu extends IMenu {
const shareElem = $('#shareIt'); const shareElem = $('#shareIt');
if (shareElem) { if (shareElem) {
this._addButton('shareIt', false, false, () => { this._addButton('shareIt', false, false, () => {
BootstrapDialogRequest.active = new BootstrapDialogRequest(`c/maps/${mapId}/sharef`, $msg('COLLABORATE'), { const dialog = new BootstrapDialogRequest(`c/maps/${mapId}/sharef`, $msg('COLLABORATE'), {
closeButton: true, closeButton: true,
cancelButton: true, cancelButton: true,
}); });
@ -374,7 +376,7 @@ class Menu extends IMenu {
const publishElem = $('#publishIt'); const publishElem = $('#publishIt');
if (publishElem) { if (publishElem) {
this._addButton('publishIt', false, false, () => { this._addButton('publishIt', false, false, () => {
BootstrapDialogRequest.active = new BootstrapDialogRequest(`c/maps/${mapId}/publishf`, $msg('PUBLISH'), { const dialog = new BootstrapDialogRequest(`c/maps/${mapId}/publishf`, $msg('PUBLISH'), {
closeButton: true, closeButton: true,
cancelButton: true, cancelButton: true,
}); });
@ -386,7 +388,7 @@ class Menu extends IMenu {
const historyElem = $('#history'); const historyElem = $('#history');
if (historyElem) { if (historyElem) {
this._addButton('history', false, false, () => { this._addButton('history', false, false, () => {
BootstrapDialogRequest.active = new BootstrapDialogRequest(`c/maps/${mapId}/historyf`, $msg('HISTORY'), { const dialog = new BootstrapDialogRequest(`c/maps/${mapId}/historyf`, $msg('HISTORY'), {
closeButton: true, closeButton: true,
cancelButton: true, cancelButton: true,
}); });
@ -398,7 +400,7 @@ class Menu extends IMenu {
const keyboardShortcut = $('#keyboardShortcuts'); const keyboardShortcut = $('#keyboardShortcuts');
if (keyboardShortcut) { if (keyboardShortcut) {
keyboardShortcut.bind('click', (event) => { keyboardShortcut.bind('click', (event) => {
BootstrapDialogRequest.active = new KeyboardShortcutDialog(); const dialog = new KeyboardShortcutDialog();
designer.onObjectFocusEvent(); designer.onObjectFocusEvent();
event.preventDefault(); event.preventDefault();
}); });
@ -409,7 +411,7 @@ class Menu extends IMenu {
if (backTolist) { if (backTolist) {
backTolist.bind('click', (event) => { backTolist.bind('click', (event) => {
event.stopPropagation(); event.stopPropagation();
window.location = '/c/maps/'; window.location.href = '/c/maps/';
return false; return false;
}); });
Menu._registerTooltip('backToList', $msg('BACK_TO_MAP_LIST')); Menu._registerTooltip('backToList', $msg('BACK_TO_MAP_LIST'));
@ -490,7 +492,7 @@ class Menu extends IMenu {
return result; return result;
} }
static _registerTooltip(buttonId, text, shortcut) { static _registerTooltip(buttonId: string, text: string, shortcut: string = null) {
if ($(`#${buttonId}`)) { if ($(`#${buttonId}`)) {
let tooltip = text; let tooltip = text;
if (shortcut) { if (shortcut) {