2 * Copyright (c) 2010 Simon Hibbard
\r
4 * Permission is hereby granted, free of charge, to any person
\r
5 * obtaining a copy of this software and associated documentation
\r
6 * files (the "Software"), to deal in the Software without
\r
7 * restriction, including without limitation the rights to use,
\r
8 * copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
9 * copies of the Software, and to permit persons to whom the
\r
10 * Software is furnished to do so, subject to the following
\r
13 * The above copyright notice and this permission notice shall be
\r
14 * included in all copies or substantial portions of the Software.
\r
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
\r
18 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
\r
20 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
\r
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
\r
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
\r
23 * OTHER DEALINGS IN THE SOFTWARE.
\r
27 * Version: V1.3.1-f1
\r
28 * Release: 22-12-2010
\r
29 * Based on jQuery 1.4.2
\r
31 * 2012-10-29: Modified by Zach Prezkuta to allow dynamic full heights
\r
36 $.fn.divgrow = function (options) {
\r
37 var options = $.extend({}, { initialHeight: 100, moreText: "+ Show More", lessText: "- Show Less", speed: 1000, showBrackets: true }, options);
\r
39 return this.each(function () {
\r
44 //var fullHeight = obj.height() + 10;
\r
46 obj.css('height', options.initialHeight).css('overflow', 'hidden');
\r
47 if (options.showBrackets) {
\r
48 obj.after('<p class="divgrow-brackets">[…]</p><a href="#" class="divgrow-showmore' + " divgrow-obj-" + divgrowid + '"' + '></a>');
\r
51 obj.after('<a href="#" class="divgrow-showmore' + " divgrow-obj-" + divgrowid + '"' + '></a>');
\r
53 $("a.divgrow-showmore").html(options.moreText);
\r
55 $("." + "divgrow-obj-" + divgrowid).toggle(function () {
\r
56 //alert(obj.attr('class'));
\r
57 // Set the height from the elements rel value
\r
58 //var height = $(this).prevAll("div:first").attr('rel');
\r
60 var fullHeight = $(this).prevAll("div:first")[0].scrollHeight + 10;
\r
61 $(this).prevAll("div:first").animate({ height: fullHeight + "px" }, options.speed, function () { // Animation complete.
\r
63 // Hide the overlay text when expanded, change the link text
\r
64 if (options.showBrackets) {
\r
65 $(this).nextAll("p.divgrow-brackets:first").fadeOut();
\r
67 $(this).nextAll("a.divgrow-showmore:first").html(options.lessText);
\r
74 $(this).prevAll("div:first").stop(true, false).animate({ height: options.initialHeight }, options.speed, function () { // Animation complete.
\r
76 // show the overlay text while closed, change the link text
\r
77 if (options.showBrackets) {
\r
78 $(this).nextAll("p.divgrow-brackets:first").stop(true, false).fadeIn();
\r
80 $(this).nextAll("a.divgrow-showmore:first").stop(true, false).html(options.moreText);
\r