Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- // DOM Ready
- $(function() {
- var $el, $ps, $up, totalHeight;
- $(".sidebar-box .button").click(function() {
- if (totalHeight == 0) {
- totalHeight = 0
- $el = $(this);
- $p = $el.parent();
- $up = $p.parent();
- $ps = $up.find("p:not('.read-more')");
- // measure how tall inside should be by adding together heights of all inside paragraphs (except read-more paragraph)
- $ps.each(function() {
- totalHeight += $(this).outerHeight();
- // FAIL totalHeight += $(this).css("margin-bottom");
- });
- $up
- .css({
- // Set height to prevent instant jumpdown when max height is removed
- "height": $up.height(),
- "max-height": 9999
- })
- .animate({
- "height": totalHeight
- });
- // fade out read-more
- // $p.fadeOut();
- // prevent jump-down
- return false;
- }
- else {
- totalHeight = 0
- $el = $(this);
- $p = $el.parent();
- $up = $p.parent();
- $ps = $up.find("p:not('.read-more')");
- // measure how tall inside should be by adding together heights of all inside paragraphs (except read-more paragraph)
- $ps.each(function() {
- totalHeight += $(this).outerHeight();
- // FAIL totalHeight += $(this).css("margin-bottom");
- });
- $up
- .css({
- // Set height to prevent instant jumpdown when max height is removed
- "height": $up.height(),
- "max-height": 120
- })
- .animate({
- "height": totalHeight
- });
- // fade out read-more
- // $p.fadeOut();
- // prevent jump-down
- return false;
- }
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement