3 $(document).ready(function() {
4 loc = window.location.pathname;
5 if (loc.startsWith('/display')) {
9 $("head").append('<style type="text/css"></style>');
10 var newStyleElement = $("head").children(':last');
11 newStyleElement.html('.limit-height{max-height: ' + postLimitHeight + 'px; overflow: hidden; }');
13 handleNewWallItemBodies();
15 document.addEventListener("postprocess_liveupdate", function() {
16 handleNewWallItemBodies();
20 function handleNewWallItemBodies() {
21 $('.wall-item-body:not(.showmore-done)').each(function() {
23 $el.addClass('showmore-done');
24 if ($el.has('button.content-filter-button').length > 0) {
25 $el.removeClass('limitable');
29 if (!$el.attr("id")) {
30 $el.attr("id", nextBodyIdx++);
32 addHeightToggleHandler($el);
33 var limited = processHeightLimit($el);
36 var mutationObserver = new MutationObserver(function() {
37 var limited = processHeightLimit($el);
39 mutationObserver.disconnect()
42 mutationObserver.observe($el[0], {
47 attributeOldValue: true,
48 characterDataOldValue: true
51 $el.imagesLoaded().then(function() {
52 processHeightLimit($el);
58 function addHeightToggleHandler($item) {
59 var itemId = parseInt($item.attr("id").replace("wall-item-body-", ""));
60 $item.data("item-id", itemId);
61 var toggleId = "wall-item-body-toggle-" + itemId;
63 $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>');
64 $item.addClass("limitable limit-height");
66 var $toggle = $("#" + toggleId);
68 $toggle.click(function(el) {
69 $item.toggleClass("limit-height");
71 $item.removeClass("limitable");
75 function processHeightLimit($item) {
76 if (!$item.hasClass("limitable")) {
80 var itemId = $item.data("item-id");
81 var $toggle = $("#wall-item-body-toggle-" + itemId);
82 if ($item.height() < postLimitHeight) {
83 $item.removeClass("limit-height");
87 $item.addClass("limit-height");