summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-12-16 09:00:27 +0300
committerAndrew Dolgov <[email protected]>2021-12-16 09:00:27 +0300
commit8e293e228e22bdc60efce098d4b9da37aaea7ffd (patch)
tree1cd1a21d6c24be6922e8691297a4dbeff18516da
parentdbf2962e8cd67805975597e1c01a10c4cbf74965 (diff)
switch to HOOK_HEADLINE_TOOLBAR_SELECT_MENU_ITEM2
-rw-r--r--init.php6
-rw-r--r--mail.js16
2 files changed, 18 insertions, 4 deletions
diff --git a/init.php b/init.php
index 44e64eb..6b0dc1c 100644
--- a/init.php
+++ b/init.php
@@ -15,15 +15,15 @@ class Mail extends Plugin {
$host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
$host->add_hook($host::HOOK_PREFS_TAB, $this);
- $host->add_hook($host::HOOK_HEADLINE_TOOLBAR_SELECT_MENU_ITEM, $this);
+ $host->add_hook($host::HOOK_HEADLINE_TOOLBAR_SELECT_MENU_ITEM2, $this);
}
function get_js() {
return file_get_contents(__DIR__ . "/mail.js");
}
- function hook_headline_toolbar_select_menu_item($feed_id, $is_cat) {
- return "<div dojoType='dijit.MenuItem' onclick='Plugins.Mail.send()'>".__('Forward by email')."</div>";
+ function hook_headline_toolbar_select_menu_item2($feed_id, $is_cat) {
+ return "<option value='Plugins.Mail.send()'>".__('Forward by email')."</option>";
}
function save() : void {
diff --git a/mail.js b/mail.js
index d2bafe0..2b81d23 100644
--- a/mail.js
+++ b/mail.js
@@ -1,6 +1,14 @@
-/* global Plugins, Headlines, dojo, App, xhr, Notify, fox, __ */
+/* global require, PluginHost, Plugins, Headlines, dojo, App, xhr, Notify, fox, __ */
Plugins.Mail = {
+ init: function() {
+ PluginHost.register(PluginHost.HOOK_HEADLINE_TOOLBAR_SELECT_MENU_ITEM2, (action) => {
+ if (action == "Plugins.Mail.send()")
+ this.send();
+
+ return true;
+ });
+ },
send: function(id) {
if (!id) {
const ids = Headlines.getSelected();
@@ -49,3 +57,9 @@ Plugins.Mail = {
Plugins.Mail.send(id);
}
};
+
+require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready, script) {
+ ready(function() {
+ Plugins.Mail.init();
+ })
+});