Initial commit
This commit is contained in:
commit
d8c4956a22
28
init.js
Normal file
28
init.js
Normal file
@ -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();
|
||||
}
|
36
init.php
Normal file
36
init.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
class Toggle_Sort_Titles extends Plugin {
|
||||
private $host;
|
||||
|
||||
function about() {
|
||||
return array(1.0,
|
||||
"Add a 't' hotkey to toggle headlines sorting by title and by default",
|
||||
"ggrandou" );
|
||||
}
|
||||
|
||||
function init($host) {
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user