]> git.sur5r.net Git - contagged/blob - scripts/interface/ifxfold.js
Make it possible to disable private contacts
[contagged] / scripts / interface / ifxfold.js
1 /**\r
2  * Interface Elements for jQuery\r
3  * FX - fold\r
4  * \r
5  * http://interface.eyecon.ro\r
6  * \r
7  * Copyright (c) 2006 Stefan Petre\r
8  * Dual licensed under the MIT (MIT-LICENSE.txt) \r
9  * and GPL (GPL-LICENSE.txt) licenses.\r
10  *   \r
11  *\r
12  */\r
13 \r
14 /**\r
15  * Applies a folding animation to element\r
16  */\r
17 jQuery.fn.extend(\r
18         {\r
19                 /**\r
20                  * @name Fold\r
21                  * @description folds the element\r
22                  * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast']\r
23                  * @param Integer height the height in pixels to fold element to\r
24                  * @param Function callback (optional) A function to be executed whenever the animation completes.\r
25                  * @param String easing (optional) The name of the easing effect that you want to use.\r
26                  * @type jQuery\r
27                  * @cat Plugins/Interface\r
28                  * @author Stefan Petre\r
29                  */\r
30                 Fold : function (speed, height, callback, easing)\r
31                 {\r
32                         return this.queue('interfaceFX',function(){\r
33                                 new jQuery.fx.DoFold(this, speed, height, callback, 'fold', easing);\r
34                         });\r
35                 },\r
36                 \r
37                 /**\r
38                  * @name UnFold\r
39                  * @description unfolds the element\r
40                  * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast']\r
41                  * @param Integer height the height in pixels to unfold element to\r
42                  * @param Function callback (optional) A function to be executed whenever the animation completes.\r
43                  * @param String easing (optional) The name of the easing effect that you want to use.\r
44                  * @type jQuery\r
45                  * @cat Plugins/Interface\r
46                  * @author Stefan Petre\r
47                  */\r
48                 UnFold : function (speed, height, callback, easing)\r
49                 {\r
50                         return this.queue('interfaceFX',function(){\r
51                                 new jQuery.fx.DoFold(this, speed, height, callback, 'unfold', easing);\r
52                         });\r
53                 },\r
54                 \r
55                 /**\r
56                  * @name FoldToggle\r
57                  * @description folds/unfolds the element\r
58                  * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast']\r
59                  * @param Integer height the height in pixels to folds/unfolds element to\r
60                  * @param Function callback (optional) A function to be executed whenever the animation completes.\r
61                  * @param String easing (optional) The name of the easing effect that you want to use.\r
62                  * @type jQuery\r
63                  * @cat Plugins/Interface\r
64                  * @author Stefan Petre\r
65                  */\r
66                 FoldToggle : function (speed, height, callback, easing)\r
67                 {\r
68                         return this.queue('interfaceFX',function(){\r
69                                 new jQuery.fx.DoFold(this, speed, height, callback, 'toggle', easing);\r
70                         });\r
71                 }\r
72         }\r
73 );\r
74 \r
75 jQuery.fx.DoFold = function (e, speed, height, callback, type, easing)\r
76 {\r
77         if (!jQuery.fxCheckTag(e)) {\r
78                 jQuery.dequeue(e, 'interfaceFX');\r
79                 return false;\r
80         }\r
81         var z = this;\r
82         z.el = jQuery(e);\r
83         z.easing = typeof callback == 'string' ? callback : easing||null;\r
84         z.callback = typeof callback == 'function' ? callback : null;\r
85         if ( type == 'toggle') {\r
86                 type = z.el.css('display') == 'none' ? 'unfold' : 'fold';\r
87         }\r
88         //z.el.show();\r
89         z.speed = speed;\r
90         z.height = height && height.constructor == Number ? height : 20;\r
91         z.fx = jQuery.fx.buildWrapper(e);\r
92         z.type = type;\r
93         z.complete = function()\r
94         {\r
95                 if (z.callback && z.callback.constructor == Function) {\r
96                         z.callback.apply(z.el.get(0));\r
97                 }\r
98                 if(z.type == 'unfold'){\r
99                         z.el.show();\r
100                 } else {\r
101                         z.el.hide();\r
102                 }\r
103                 jQuery.fx.destroyWrapper(z.fx.wrapper.get(0), z.fx.oldStyle);\r
104                 jQuery.dequeue(z.el.get(0), 'interfaceFX');\r
105         };\r
106         if ( z.type == 'unfold') {\r
107                 z.el.show();\r
108                 z.fx.wrapper.css('height', z.height + 'px').css('width', '1px');\r
109                 \r
110                 z.ef = new jQuery.fx(\r
111                                 z.fx.wrapper.get(0),\r
112                                 jQuery.speed (\r
113                                         z.speed,\r
114                                         z.easing,\r
115                                         function()\r
116                                         {\r
117                                                 z.ef = new jQuery.fx(\r
118                                                         z.fx.wrapper.get(0),\r
119                                                         jQuery.speed(\r
120                                                                 z.speed,\r
121                                                                 z.easing, \r
122                                                                 z.complete\r
123                                                         ),\r
124                                                         'height'\r
125                                                 );\r
126                                                 z.ef.custom(z.height, z.fx.oldStyle.sizes.hb);\r
127                                         }\r
128                                 ), \r
129                                 'width'\r
130                         );\r
131                 z.ef.custom(0, z.fx.oldStyle.sizes.wb);\r
132         } else {\r
133                 z.ef = new jQuery.fx(\r
134                                 z.fx.wrapper.get(0),\r
135                                 jQuery.speed(\r
136                                         z.speed,\r
137                                         z.easing,\r
138                                         function()\r
139                                         {\r
140                                                 z.ef = new jQuery.fx(\r
141                                                         z.fx.wrapper.get(0),\r
142                                                         jQuery.speed(\r
143                                                                 z.speed,\r
144                                                                 z.easing,\r
145                                                                 z.complete\r
146                                                         ),\r
147                                                         'width'\r
148                                                 );\r
149                                                 z.ef.custom(z.fx.oldStyle.sizes.wb, 0);\r
150                                         }\r
151                                 ), \r
152                                 'height'\r
153                         );\r
154                 z.ef.custom(z.fx.oldStyle.sizes.hb, z.height);\r
155         }\r
156 };\r
157 \r