X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=plugins%2Fshorten_expanded%2Finit.js;h=d7564428655f90edc672de34a82f5d029b3e44d7;hb=dbb4cdbe3674f692f5f593cc46e26b73df078acc;hp=11ecbc5d5dea17b8af8326ff9d15d9cee581700b;hpb=0cf910991ef688a4bca76a056d44f11c828478d1;p=tt-rss.git diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js index 11ecbc5d..d7564428 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); @@ -22,26 +22,34 @@ function expandSizeWrapper(id) { } -dojo.addOnLoad(function() { - PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) { - if (getInitParam('cdm_expanded')) { +require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { - window.setTimeout(function() { - if (row) { - if (row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) { - var content = row.select(".cdmContentInner")[0]; + ready(function() { + PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) { + if (getInitParam('cdm_expanded')) { - if (content) { - var wrapperHeight = Math.round(window.innerHeight * 0.8) + 'px'; + window.setTimeout(function() { + if (row) { + const c_inner = row.select(".cdmContentInner")[0]; + const c_inter = row.select(".cdmIntermediate")[0]; - content.innerHTML = "
" + - content.innerHTML + "
"; + if (c_inner && c_inter && + row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) { + c_inter.parentNode.removeChild(c_inter); + + c_inner.innerHTML = "
" + + c_inner.innerHTML + + c_inter.innerHTML + "
" + + ""; } } - } - }, 150); - } + }, 150); + } + + return true; + }); }); + });