X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=plugins%2Fshorten_expanded%2Finit.js;h=24d72b0a1a0ffe4f6052885cba9a8eb961e02402;hb=df0115fc7a443669f3326f5abb49eb9754b59263;hp=5e9e84aec56ff2d0cc2927b477da556ce92ae178;hpb=6fd79b12a55eb2fa7f156650a7734b209cb2c6f5;p=tt-rss.git diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js index 5e9e84ae..24d72b0a 100644 --- a/plugins/shorten_expanded/init.js +++ b/plugins/shorten_expanded/init.js @@ -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) { - content.innerHTML = "
" + - content.innerHTML + "
"; + window.setTimeout(function() { + if (row) { + var c_inner = row.select(".cdmContentInner")[0]; + var c_inter = row.select(".cdmIntermediate")[0]; + 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; + return true; + }); }); + });