]> git.wh0rd.org - tt-rss.git/blob - plugins/shorten_expanded/init.js
remove expandable CDM headlines
[tt-rss.git] / plugins / shorten_expanded / init.js
1 var _shorten_expanded_threshold = 1.5; //window heights
2
3 function expandSizeWrapper(id) {
4 try {
5 const row = $(id);
6
7 console.log(row);
8
9 if (row) {
10 const content = row.select(".contentSizeWrapper")[0];
11 const link = row.select(".expandPrompt")[0];
12
13 if (content) content.removeClassName("contentSizeWrapper");
14 if (link) Element.hide(link);
15
16 }
17 } catch (e) {
18 exception_error("expandSizeWrapper", e);
19 }
20
21 return false;
22
23 }
24
25 require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
26
27 ready(function() {
28 PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) {
29 window.setTimeout(function() {
30 if (row) {
31 const c_inner = row.select(".cdmContentInner")[0];
32 const c_inter = row.select(".cdmIntermediate")[0];
33
34 if (c_inner && c_inter &&
35 row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) {
36
37 c_inter.parentNode.removeChild(c_inter);
38
39 c_inner.innerHTML = "<div class='contentSizeWrapper'>" +
40 c_inner.innerHTML +
41 c_inter.innerHTML + "</div>" +
42 "<button class='expandPrompt' onclick='return expandSizeWrapper(\""+row.id+"\")' href='#'>" +
43 __("Click to expand article") + "</button>";
44 }
45 }
46 }, 150);
47
48 return true;
49 });
50 });
51
52 });