commit d8c4956a22353ce1e5fa12d1732c617c76c3f6cf Author: Gilles Grandou Date: Wed May 1 18:21:04 2019 +0200 Initial commit diff --git a/init.js b/init.js new file mode 100644 index 0000000..d4254b8 --- /dev/null +++ b/init.js @@ -0,0 +1,28 @@ +require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { + ready(function () { + PluginHost.register(PluginHost.HOOK_INIT_COMPLETE, () => { + App.hotkey_actions["feed_toggle_title"] = toggleHeadlineOrderTitle; + }); + }); +}); + + +function toggleHeadlineOrderTitle() { + const toolbar = document.forms["toolbar-main"]; + const order_by = dijit.getEnclosingWidget(toolbar.order_by); + + let value = order_by.attr('value'); + switch(value) { + case 'date_reverse': + value = 'feed_dates'; + break; + case 'title': + value = 'date_reverse'; + break; + default: + value = 'title'; + } + + order_by.attr('value', value); + Feeds.reloadCurrent(); +} diff --git a/init.php b/init.php new file mode 100644 index 0000000..bf7d44a --- /dev/null +++ b/init.php @@ -0,0 +1,36 @@ +host = $host; + $host->add_hook($host::HOOK_HOTKEY_INFO, $this); + $host->add_hook($host::HOOK_HOTKEY_MAP, $this); + } + + function hook_hotkey_info($hotkeys) { + $hotkeys[__("Feed")]["feed_toggle_title"] = __("Toggle Headlines grouping by Titles"); + return $hotkeys; + } + + function hook_hotkey_map($hotkeys) { + $hotkeys["t"] = "feed_toggle_title"; + return $hotkeys; + } + + function get_js() { + return file_get_contents(__DIR__ . "/init.js"); + } + + function api_version() { + return 2; + } +} + +?>