3 $(document).ready(function() {
4 $("head").append('<style type="text/css"></style>');
5 var newStyleElement = $("head").children(':last');
6 newStyleElement.html('.limit-height{max-height: ' + postLimitHeight + 'px; overflow: hidden; display:inline-block;}');
8 handleNewWallItemBodies();
10 document.addEventListener("postprocess_liveupdate", function() {
11 handleNewWallItemBodies();
15 function handleNewWallItemBodies() {
16 $('.wall-item-body:not(.showmore-done)').each(function() {
18 $el.addClass('showmore-done');
19 if ($el.has('button.content-filter-button').length > 0) {
20 $el.removeClass('limitable');
24 if (!$el.attr("id")) {
25 $el.attr("id", nextBodyIdx++);
27 addHeightToggleHandler($el);
28 var limited = processHeightLimit($el);
31 var mutationObserver = new MutationObserver(function() {
32 var limited = processHeightLimit($el);
34 mutationObserver.disconnect()
37 mutationObserver.observe($el[0], {
42 attributeOldValue: true,
43 characterDataOldValue: true
46 $el.imagesLoaded().then(function() {
47 processHeightLimit($el);
53 function addHeightToggleHandler($item) {
54 var itemId = parseInt($item.attr("id").replace("wall-item-body-", ""));
55 $item.data("item-id", itemId);
56 var wrapperId = "wall-item-body-wrapper-" + itemId;
57 var toggleId = "wall-item-body-toggle-" + itemId;
59 $item.wrap('<div id="' + wrapperId + '" class="wall-item-body-wrapper"></div>');
60 $("#" + wrapperId).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>');
61 $item.addClass("limitable limit-height");
63 var $toggle = $("#" + toggleId);
65 $toggle.click(function(el) {
66 $item.toggleClass("limit-height");
68 $item.removeClass("limitable");
72 function processHeightLimit($item) {
73 if (!$item.hasClass("limitable")) {
77 var itemId = $item.data("item-id");
78 var $toggle = $("#wall-item-body-toggle-" + itemId);
79 if ($item.height() < postLimitHeight) {
80 $item.removeClass("limit-height");
84 $item.addClass("limit-height");