2020-01-19 13:19:40 +01:00
|
|
|
import TabAwareWidget from "./tab_aware_widget.js";
|
|
|
|
|
|
|
|
const TPL = `
|
2020-01-25 18:29:32 +01:00
|
|
|
<div style="display: inline-flex;">
|
2020-01-19 15:36:42 +01:00
|
|
|
<button class="btn btn-sm icon-button bx bx-play-circle render-button"
|
|
|
|
title="Render"></button>
|
|
|
|
|
|
|
|
<button class="btn btn-sm icon-button bx bx-play-circle execute-script-button"
|
|
|
|
title="Execute (Ctrl+Enter)"></button>
|
|
|
|
</div>`;
|
2020-01-19 13:19:40 +01:00
|
|
|
|
|
|
|
export default class RunScriptButtonsWidget extends TabAwareWidget {
|
|
|
|
doRender() {
|
|
|
|
this.$widget = $(TPL);
|
|
|
|
|
2020-01-19 15:36:42 +01:00
|
|
|
this.$renderButton = this.$widget.find('.render-button');
|
|
|
|
this.$executeScriptButton = this.$widget.find('.execute-script-button');
|
2020-01-19 13:19:40 +01:00
|
|
|
|
|
|
|
return this.$widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
refreshWithNote(note) {
|
2020-05-05 22:18:09 +02:00
|
|
|
this.$renderButton.toggle(note.type === 'render');console.log("note.mime", note.mime);
|
2020-01-19 15:36:42 +01:00
|
|
|
this.$executeScriptButton.toggle(note.mime.startsWith('application/javascript'));
|
2020-01-19 13:19:40 +01:00
|
|
|
}
|
2020-05-05 22:18:09 +02:00
|
|
|
|
|
|
|
async entitiesReloadedEvent({loadResults}) {
|
|
|
|
if (loadResults.isNoteReloaded(this.noteId)) {
|
|
|
|
this.refresh();
|
|
|
|
}
|
|
|
|
}
|
2020-01-19 13:19:40 +01:00
|
|
|
}
|