]> git.wh0rd.org - tt-rss.git/blame - plugins/shorten_expanded/init.js
plugins: run eslint const/let fixes
[tt-rss.git] / plugins / shorten_expanded / init.js
CommitLineData
0cf91099 1var _shorten_expanded_threshold = 1.5; //window heights
2fdbff06
AD
2
3function expandSizeWrapper(id) {
4 try {
dbb4cdbe 5 const row = $(id);
2fdbff06
AD
6
7 console.log(row);
8
9 if (row) {
dbb4cdbe
AD
10 const content = row.select(".contentSizeWrapper")[0];
11 const link = row.select(".expandPrompt")[0];
2fdbff06
AD
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
ee517042 25require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
2fdbff06 26
f6d2787a 27 ready(function() {
ee517042
AD
28 PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) {
29 if (getInitParam('cdm_expanded')) {
2fdbff06 30
ee517042
AD
31 window.setTimeout(function() {
32 if (row) {
dbb4cdbe
AD
33 const c_inner = row.select(".cdmContentInner")[0];
34 const c_inter = row.select(".cdmIntermediate")[0];
2fdbff06 35
df0115fc
AD
36 if (c_inner && c_inter &&
37 row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) {
ee517042 38
df0115fc
AD
39 c_inter.parentNode.removeChild(c_inter);
40
41 c_inner.innerHTML = "<div class='contentSizeWrapper'>" +
42 c_inner.innerHTML +
43 c_inter.innerHTML + "</div>" +
44 "<button class='expandPrompt' onclick='return expandSizeWrapper(\""+row.id+"\")' href='#'>" +
45 __("Click to expand article") + "</button>";
2fdbff06
AD
46 }
47 }
ee517042
AD
48 }, 150);
49 }
6fd79b12 50
ee517042
AD
51 return true;
52 });
2fdbff06 53 });
ee517042 54
2fdbff06 55});