]> git.wh0rd.org - tt-rss.git/blame - plugins/shorten_expanded/init.js
add experimental plugin to shorten articles which are too damn long in expanded cdm
[tt-rss.git] / plugins / shorten_expanded / init.js
CommitLineData
2fdbff06
AD
1var _shorten_expanded_threshold = 900; //px, longer than css height so that we would only clip articles significantly longer than limit
2
3function expandSizeWrapper(id) {
4 try {
5 var row = $(id);
6
7 console.log(row);
8
9 if (row) {
10 var content = row.select(".contentSizeWrapper")[0];
11 var 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
25dojo.addOnLoad(function() {
26 PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) {
27 if (getInitParam('cdm_expanded')) {
28
29 window.setTimeout(function() {
30 if (row) {
31 if (row.offsetHeight >= _shorten_expanded_threshold) {
32 var content = row.select(".cdmContentInner")[0];
33
34 if (content) {
35 content.innerHTML = "<div class='contentSizeWrapper'>" +
36 content.innerHTML + "</div><button class='expandPrompt' onclick='return expandSizeWrapper(\""+row.id+"\")' "+
37 "href='#'>" + __("Click to expand article") + "</button>";
38
39 }
40 }
41 }
42 }, 150);
43 }
44 });
45});