From 33ea8737b71466be84dfaaa0fa16cd2850805158 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Jul 2012 21:20:43 -0700 Subject: should be able to use this to get rid of vertical scrollbars but still restrict initial content height. It does not depend on text length but purely on the height of the contained html. --- js/main.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/js/main.js b/js/main.js index b201557f9..e8c5b060e 100644 --- a/js/main.js +++ b/js/main.js @@ -653,3 +653,36 @@ function previewTheme(elm) { } +// This can be used for dynamic "show more" based purely on the +// height of the enclosed HTML (which has overflow: hidden). +// if ($(el).vScrollable()) { +// show_more_link(el); +// } +// when link is clicked do $(el).css('overflow','visible') +// +// We do this by cloning the element in question but in a hidden div which displays overflow content and compare the heights +// of the two elements. Then we remove the hidden div we just created. + +(function($) { + $.fn.vScrollable = function() { + return this.each(function() { + var el = $(this); + var tooHigh = false; + + if(el.css("overflow") == "hidden") { + var text = el.html(); + var t = $(this.cloneNode(true)) + .hide() + .css('position', 'absolute') + .css('overflow', 'visible') + .width(el.width()) + .height('auto') + ; + el.after(t); + tooHigh = (t.height() > el.height()); + el.parentNode.removeChild(el); + } + return tooHigh; + }); + }; +})(jQuery); -- cgit v1.2.3