Merge pull request #5128 from tobiasd/20180525-5067
[friendica.git/.git] / view / theme / frost / js / jquery.divgrow-1.3.1.f1.js
1 /*\r
2 * Copyright (c) 2010 Simon Hibbard\r
3\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
11 * conditions:\r
12 \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
15\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
24 */\r
25 \r
26 /*\r
27 * Version: V1.3.1-f1\r
28 * Release: 22-12-2010\r
29 * Based on jQuery 1.4.2\r
30 *\r
31 * 2012-10-29: Modified by Zach Prezkuta to allow dynamic full heights\r
32 */\r
33 \r
34 (function ($) {\r
35     var divgrowid = 0;\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
38 \r
39         return this.each(function () {\r
40             divgrowid++;\r
41 \r
42             obj = $(this);\r
43 \r
44             //var fullHeight = obj.height() + 10;\r
45 \r
46             obj.css('height', options.initialHeight).css('overflow', 'hidden');\r
47             if (options.showBrackets) {\r
48                 obj.after('<p class="divgrow-brackets">[&hellip;]</p><a href="#" class="divgrow-showmore' + " divgrow-obj-" + divgrowid + '"' + '></a>');\r
49             }\r
50             else {\r
51                 obj.after('<a href="#" class="divgrow-showmore' + " divgrow-obj-" + divgrowid + '"' + '></a>');\r
52             }\r
53             $("a.divgrow-showmore").html(options.moreText);\r
54 \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
59 \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
62 \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
66                     }\r
67                     $(this).nextAll("a.divgrow-showmore:first").html(options.lessText);\r
68 \r
69                 });\r
70 \r
71 \r
72             }, function () {\r
73 \r
74                 $(this).prevAll("div:first").stop(true, false).animate({ height: options.initialHeight }, options.speed, function () { // Animation complete.\r
75 \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
79                     }\r
80                     $(this).nextAll("a.divgrow-showmore:first").stop(true, false).html(options.moreText);\r
81 \r
82                 });\r
83             });\r
84 \r
85         });\r
86     };\r
87 })(jQuery);\r
88 \r
89 \r
90 \r
91 \r
92 \r