2021-02-15 11:10:46 +00:00
|
|
|
/* global Plugins, __, require, PluginHost */
|
|
|
|
|
2018-12-07 19:56:34 +00:00
|
|
|
const _shorten_expanded_threshold = 1.5; //window heights
|
2013-07-31 14:58:56 +00:00
|
|
|
|
2018-12-07 19:56:34 +00:00
|
|
|
Plugins.Shorten_Expanded = {
|
|
|
|
expand: function(id) {
|
|
|
|
const row = $(id);
|
2013-07-31 14:58:56 +00:00
|
|
|
|
2018-12-07 19:56:34 +00:00
|
|
|
if (row) {
|
|
|
|
const content = row.select(".content-shrink-wrap")[0];
|
|
|
|
const link = row.select(".expand-prompt")[0];
|
2013-07-31 14:58:56 +00:00
|
|
|
|
2018-12-07 19:56:34 +00:00
|
|
|
if (content) content.removeClassName("content-shrink-wrap");
|
|
|
|
if (link) Element.hide(link);
|
|
|
|
}
|
2013-07-31 14:58:56 +00:00
|
|
|
|
2018-12-07 19:56:34 +00:00
|
|
|
return false;
|
|
|
|
}
|
2013-07-31 14:58:56 +00:00
|
|
|
}
|
|
|
|
|
2016-08-10 07:01:05 +00:00
|
|
|
require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
|
2016-08-10 09:22:55 +00:00
|
|
|
ready(function() {
|
2016-08-10 07:01:05 +00:00
|
|
|
PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) {
|
2018-11-30 10:51:54 +00:00
|
|
|
window.setTimeout(function() {
|
|
|
|
if (row) {
|
2018-12-07 19:56:34 +00:00
|
|
|
|
2021-02-15 11:10:46 +00:00
|
|
|
const content = row.querySelector(".content-inner");
|
2013-07-31 14:58:56 +00:00
|
|
|
|
2021-02-16 05:31:24 +00:00
|
|
|
//console.log('shorten', row.offsetHeight, 'vs', _shorten_expanded_threshold * window.innerHeight);
|
|
|
|
|
|
|
|
if (content && row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) {
|
|
|
|
|
|
|
|
const attachments = row.querySelector(".attachments-inline"); // optional
|
2013-07-31 14:58:56 +00:00
|
|
|
|
2021-02-15 11:10:46 +00:00
|
|
|
content.innerHTML = `
|
|
|
|
<div class="content-shrink-wrap">
|
|
|
|
${content.innerHTML}
|
2021-02-16 05:31:24 +00:00
|
|
|
${attachments ? attachments.innerHTML : ''}
|
2021-02-15 11:10:46 +00:00
|
|
|
</div>
|
2018-12-07 19:56:34 +00:00
|
|
|
<button dojoType="dijit.form.Button" class="alt-info expand-prompt" onclick="return Plugins.Shorten_Expanded.expand('${row.id}')" href="#">
|
|
|
|
${__("Click to expand article")}</button>`;
|
2016-08-10 07:01:05 +00:00
|
|
|
|
2021-02-16 05:31:24 +00:00
|
|
|
if (attachments)
|
|
|
|
attachments.innerHTML = "";
|
2021-02-15 11:10:46 +00:00
|
|
|
|
|
|
|
dojo.parser.parse(content);
|
2013-07-31 14:58:56 +00:00
|
|
|
}
|
2018-11-30 10:51:54 +00:00
|
|
|
}
|
|
|
|
}, 150);
|
2015-07-31 10:42:39 +00:00
|
|
|
|
2016-08-10 07:01:05 +00:00
|
|
|
return true;
|
|
|
|
});
|
2013-07-31 14:58:56 +00:00
|
|
|
});
|
|
|
|
});
|