3 $(document).ready(function() {
4 loc = window.location.pathname;
5 if (loc.startsWith('/display')) {
10 $('head').append('<style type="text/css">.limit-height{max-height: ' + postLimitHeight + 'px; overflow: hidden; }</style>');
11 handleNewWallItemBodies();
13 document.addEventListener('postprocess_liveupdate', function() {
14 handleNewWallItemBodies();
19 function handleNewWallItemBodies() {
20 $('.wall-item-body:not(.showmore-done)').each(function() {
22 $el.addClass('showmore-done');
23 if ($el.has('button.content-filter-button').length > 0) {
24 $el.removeClass('limitable');
28 if (!$el.attr("id")) {
29 $el.attr("id", nextBodyIdx++);
31 addHeightToggleHandler($el);
32 var limited = processHeightLimit($el);
35 var mutationObserver = new MutationObserver(function() {
36 var limited = processHeightLimit($el);
38 mutationObserver.disconnect()
41 mutationObserver.observe($el[0], {
46 attributeOldValue: true,
47 characterDataOldValue: true
50 $el.imagesLoaded().then(function() {
51 processHeightLimit($el);
57 function addHeightToggleHandler($item) {
58 var itemId = parseInt($item.attr("id").replace("wall-item-body-", ""));
59 $item.data("item-id", itemId);
60 var toggleId = "wall-item-body-toggle-" + itemId;
62 $item.append('<div class="wall-item-body-toggle" data-item-id="' + itemId + '" id="' + toggleId + '" ><button type="button" class="wall-item-body-toggle-text">' + showmore_dyn_showmore_linktext + '</button></div>');
63 $item.addClass("limitable limit-height");
65 var $toggle = $("#" + toggleId);
67 $toggle.click(function(el) {
68 $item.toggleClass("limit-height");
70 $item.removeClass("limitable");
74 function processHeightLimit($item) {
75 if (!$item.hasClass("limitable")) {
79 var itemId = $item.data("item-id");
80 var $toggle = $("#wall-item-body-toggle-" + itemId);
81 if ($item.height() < postLimitHeight) {
82 $item.removeClass("limit-height");
86 $item.addClass("limit-height");