mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-16 08:35:57 +00:00
af_readability: allow get full text button to work as a toggle; in cdm, scroll to article after embedding
This commit is contained in:
@@ -1053,7 +1053,7 @@
|
|||||||
"close_article" => __("Close/collapse article"),
|
"close_article" => __("Close/collapse article"),
|
||||||
"toggle_expand" => __("Toggle article expansion (combined mode)"),
|
"toggle_expand" => __("Toggle article expansion (combined mode)"),
|
||||||
"toggle_widescreen" => __("Toggle widescreen mode"),
|
"toggle_widescreen" => __("Toggle widescreen mode"),
|
||||||
"embed_full_text" => __("Get full article text via Readability")),
|
"toggle_full_text" => __("Toggle full article text via Readability")),
|
||||||
__("Article selection") => array(
|
__("Article selection") => array(
|
||||||
"select_all" => __("Select all articles"),
|
"select_all" => __("Select all articles"),
|
||||||
"select_unread" => __("Select unread"),
|
"select_unread" => __("Select unread"),
|
||||||
@@ -1124,7 +1124,7 @@
|
|||||||
"N" => "article_scroll_down",
|
"N" => "article_scroll_down",
|
||||||
"P" => "article_scroll_up",
|
"P" => "article_scroll_up",
|
||||||
"a W" => "toggle_widescreen",
|
"a W" => "toggle_widescreen",
|
||||||
"a e" => "embed_full_text",
|
"a e" => "toggle_full_text",
|
||||||
"e" => "email_article",
|
"e" => "email_article",
|
||||||
"a q" => "close_article",
|
"a q" => "close_article",
|
||||||
"a a" => "select_all",
|
"a a" => "select_all",
|
||||||
|
|||||||
@@ -476,7 +476,7 @@ require(["dojo/_base/kernel",
|
|||||||
this.hotkey_actions["collapse_sidebar"] = function () {
|
this.hotkey_actions["collapse_sidebar"] = function () {
|
||||||
Feeds.toggle();
|
Feeds.toggle();
|
||||||
};
|
};
|
||||||
this.hotkey_actions["embed_full_text"] = function () {
|
this.hotkey_actions["toggle_full_text"] = function () {
|
||||||
if (typeof Plugins.Af_Readability != "undefined") {
|
if (typeof Plugins.Af_Readability != "undefined") {
|
||||||
if (Article.getActive())
|
if (Article.getActive())
|
||||||
Plugins.Af_Readability.embed(Article.getActive());
|
Plugins.Af_Readability.embed(Article.getActive());
|
||||||
|
|||||||
@@ -1,16 +1,32 @@
|
|||||||
Plugins.Af_Readability = {
|
Plugins.Af_Readability = {
|
||||||
|
orig_attr_name: 'data-readability-orig-content',
|
||||||
|
self: this,
|
||||||
embed: function(id) {
|
embed: function(id) {
|
||||||
|
const content = $$(App.isCombinedMode() ? ".cdm[data-article-id=" + id + "] .content-inner" :
|
||||||
|
".post[data-article-id=" + id + "] .content")[0];
|
||||||
|
|
||||||
|
if (content.hasAttribute(self.orig_attr_name)) {
|
||||||
|
content.innerHTML = content.getAttribute(self.orig_attr_name);
|
||||||
|
content.removeAttribute(self.orig_attr_name);
|
||||||
|
|
||||||
|
if (App.isCombinedMode()) Article.cdmScrollToId(id);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Notify.progress("Loading, please wait...");
|
Notify.progress("Loading, please wait...");
|
||||||
|
|
||||||
xhrJson("backend.php",{ op: "pluginhandler", plugin: "af_readability", method: "embed", param: id }, (reply) => {
|
xhrJson("backend.php",{ op: "pluginhandler", plugin: "af_readability", method: "embed", param: id }, (reply) => {
|
||||||
const content = $$(App.isCombinedMode() ? ".cdm[data-article-id=" + id + "] .content-inner" :
|
|
||||||
".post[data-article-id=" + id + "] .content")[0];
|
|
||||||
|
|
||||||
if (content && reply.content) {
|
if (content && reply.content) {
|
||||||
|
content.setAttribute(self.orig_attr_name, content.innerHTML);
|
||||||
content.innerHTML = reply.content;
|
content.innerHTML = reply.content;
|
||||||
Notify.close();
|
Notify.close();
|
||||||
|
|
||||||
|
if (App.isCombinedMode()) Article.cdmScrollToId(id);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Notify.error("Unable to fetch content for this article");
|
Notify.error("Unable to fetch full text for this article");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class Af_Readability extends Plugin {
|
|||||||
|
|
||||||
function hook_article_button($line) {
|
function hook_article_button($line) {
|
||||||
return "<i class='material-icons' onclick=\"Plugins.Af_Readability.embed(".$line["id"].")\"
|
return "<i class='material-icons' onclick=\"Plugins.Af_Readability.embed(".$line["id"].")\"
|
||||||
style='cursor : pointer' title='".__('Get full article text')."'>description</i>";
|
style='cursor : pointer' title='".__('Toggle full article text')."'>description</i>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function hook_prefs_tab($args) {
|
function hook_prefs_tab($args) {
|
||||||
|
|||||||
Reference in New Issue
Block a user