init.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. var _shorten_expanded_threshold = 1.5; //window heights
  2. function expandSizeWrapper(id) {
  3. try {
  4. var row = $(id);
  5. console.log(row);
  6. if (row) {
  7. var content = row.select(".contentSizeWrapper")[0];
  8. var link = row.select(".expandPrompt")[0];
  9. if (content) content.removeClassName("contentSizeWrapper");
  10. if (link) Element.hide(link);
  11. }
  12. } catch (e) {
  13. exception_error("expandSizeWrapper", e);
  14. }
  15. return false;
  16. }
  17. dojo.addOnLoad(function() {
  18. PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) {
  19. if (getInitParam('cdm_expanded')) {
  20. window.setTimeout(function() {
  21. if (row) {
  22. if (row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) {
  23. var content = row.select(".cdmContentInner")[0];
  24. if (content) {
  25. content.innerHTML = "<div class='contentSizeWrapper'>" +
  26. content.innerHTML + "</div><button class='expandPrompt' onclick='return expandSizeWrapper(\""+row.id+"\")' "+
  27. "href='#'>" + __("Click to expand article") + "</button>";
  28. }
  29. }
  30. }
  31. }, 150);
  32. }
  33. return true;
  34. });
  35. });