﻿(function($) { var divgrowid = 0; $.fn.divgrow = function(option) { var option = $.extend({}, { initialHeight: 100, moreLessParent: 'moreLessLink', moreText: "+ Show More", lessText: "- Show Less", speed: 1000 }, option); return this.each(function() { divgrowid++; obj = $(this); var thisClass = "divgrow-obj-" + divgrowid; var linkClass = "divgrow-lnk-" + divgrowid; obj.addClass(thisClass); var fullHeight = obj.height(); if (obj.height() > option.initialHeight) { obj.css({ 'height': option.initialHeight, 'overflow': 'hidden' }); $('.' + option.moreLessParent).html('<a href="#" class="divgrow-showmore' + " " + linkClass + '"' + '></a>'); $("a.divgrow-showmore").html(option.moreText); $("." + linkClass).toggle(function() { $('.' + thisClass).animate({ height: fullHeight + "px" }, option.speed, function() { $('.' + linkClass).html(option.lessText); }); }, function() { $('.' + thisClass).stop(true, false).animate({ height: option.initialHeight }, option.speed, function() { $('.' + linkClass).stop(true, false).html(option.moreText); }); $('html').css('overflow', ''); }); } }); }; })(jQuery);
