plugins/note: allow editing note by clicking on it

This commit is contained in:
Andrew Dolgov 2022-02-01 13:16:23 +03:00
parent 478c9b64a9
commit 6077175c57
3 changed files with 56 additions and 33 deletions

View File

@ -15,6 +15,9 @@ class Note extends Plugin {
return file_get_contents(__DIR__ . "/note.js");
}
function get_css() {
return file_get_contents(__DIR__ . "/note.css");
}
function hook_article_button($line) {
return "<i class='material-icons' onclick=\"Plugins.Note.edit(".$line["id"].")\"

3
plugins/note/note.css Normal file
View File

@ -0,0 +1,3 @@
.article-note[data-note-for] {
cursor : pointer;
}

View File

@ -1,6 +1,16 @@
/* global dojo, Plugins, xhr, App, Notify, fox, __ */
/* global require, Plugins, PluginHost, xhr, App, Notify, fox, __ */
require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
ready(function() {
Plugins.Note = {
set_click_handler: function() {
document.querySelectorAll(".article-note[data-note-for]").forEach((note) => {
note.onclick = function() {
Plugins.Note.edit(this.getAttribute('data-note-for'));
}
});
},
edit: function(id) {
const dialog = new fox.SingleUseDialog({
title: __("Edit article note"),
@ -39,3 +49,10 @@ Plugins.Note = {
dialog.show();
}
};
PluginHost.register(PluginHost.HOOK_HEADLINE_RENDERED, function() {
Plugins.Note.set_click_handler();
return true;
});
});
});