/******** signature collapse toggle ***********/ $(window).on('load', function() { window.setTimeout(function() { var maxHeight = 100; /*** check if expandable ***/ var eles = []; $('.message-signature').each(function() { var height = $(this).height(); if (height > maxHeight) { eles.push($(this)); } }); for (var i = 0; i < eles.length; i++) { eles[i].addClass('message-signature--expandable'); }; /**** expand function ***/ var expand = function(container, canClose) { var inner = container.find('.bbWrapper'); var eleHeight = inner.height(); var isExpanded = container.hasClass('message-signature--expanded'); if (isExpanded) { if (canClose) { container.css({ height: eleHeight }); container.removeClass('message-signature--expanded'); window.setTimeout(function() { container.css({ height: maxHeight }); window.setTimeout(function() { container.css({ height: '' }); }, 200); }, 17); } } else { container.css({ height: eleHeight }); window.setTimeout(function() { container.addClass('message-signature--expanded'); container.css({ height: '' }); }, 200); } } /*** handle hover ***/ /*** handle click ***/ $('.uix_signatureExpand').click(function() { var container = $(this).parent('.message-signature'); expand(container, true); }); }, 0); });