aboutsummaryrefslogtreecommitdiffstats
path: root/js/main.js
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-07-22 21:20:43 -0700
committerfriendica <info@friendica.com>2012-07-22 21:20:43 -0700
commit33ea8737b71466be84dfaaa0fa16cd2850805158 (patch)
treea143112bc98bc3b3f52cbadad163a2acbda46dbf /js/main.js
parent9299050fcbb86f8c54775d5ec05d71234eae6184 (diff)
downloadvolse-hubzilla-33ea8737b71466be84dfaaa0fa16cd2850805158.tar.gz
volse-hubzilla-33ea8737b71466be84dfaaa0fa16cd2850805158.tar.bz2
volse-hubzilla-33ea8737b71466be84dfaaa0fa16cd2850805158.zip
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.
Diffstat (limited to 'js/main.js')
-rw-r--r--js/main.js33
1 files changed, 33 insertions, 0 deletions
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);