X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=plugins%2Fshorten_expanded%2Finit.js;h=a744aad005f27b7c443187752e3328b06b6eab27;hb=9563e3bcd662b87ea6779714b51afb61571dd32d;hp=ffec6271d70651b48a2a321faca8bb54561ee47d;hpb=2842cf6e4563d1665741dd4c151798e6e282c60b;p=tt-rss.git diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js index ffec6271..a744aad0 100644 --- a/plugins/shorten_expanded/init.js +++ b/plugins/shorten_expanded/init.js @@ -2,13 +2,13 @@ var _shorten_expanded_threshold = 1.5; //window heights function expandSizeWrapper(id) { try { - var row = $(id); + const row = $(id); console.log(row); if (row) { - var content = row.select(".contentSizeWrapper")[0]; - var link = row.select(".expandPrompt")[0]; + const content = row.select(".contentSizeWrapper")[0]; + const link = row.select(".expandPrompt")[0]; if (content) content.removeClassName("contentSizeWrapper"); if (link) Element.hide(link); @@ -26,23 +26,24 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { ready(function() { PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) { - if (getInitParam('cdm_expanded')) { + window.setTimeout(function() { + if (row) { + const c_inner = row.select(".cdmContentInner")[0]; + const c_inter = row.select(".cdmIntermediate")[0]; - window.setTimeout(function() { - if (row) { - if (row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) { - var content = row.select(".cdmContentInner")[0]; + if (c_inner && c_inter && + row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) { - if (content) { - content.innerHTML = "
" + - content.innerHTML + "
"; + c_inter.parentNode.removeChild(c_inter); - } - } + c_inner.innerHTML = "
" + + c_inner.innerHTML + + c_inter.innerHTML + "
" + + ""; } - }, 150); - } + } + }, 150); return true; });