]> git.sur5r.net Git - contagged/blob - scripts/interface/ifxblind.js
Version 0.6.5
[contagged] / scripts / interface / ifxblind.js
1 /**\r
2  * Interface Elements for jQuery\r
3  * FX - blind\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 blinding animation to element\r
16  */\r
17 jQuery.fn.extend(\r
18         {\r
19                 /**\r
20                  * @name BlindUp\r
21                  * @description blinds the element up\r
22                  * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast']\r
23                  * @param Function callback (optional) A function to be executed whenever the animation completes.\r
24                  * @param String easing (optional) The name of the easing effect that you want to use.\r
25                  * @type jQuery\r
26                  * @cat Plugins/Interface\r
27                  * @author Stefan Petre\r
28                  */\r
29                 BlindUp : function (speed, callback, easing)\r
30                 {\r
31                         return this.queue('interfaceFX',function(){\r
32                                 new jQuery.fx.BlindDirection(this, speed, callback, 'up', easing);\r
33                         });\r
34                 },\r
35                 \r
36                 /**\r
37                  * @name BlindDown\r
38                  * @description blinds the element down\r
39                  * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast']\r
40                  * @param Function callback (optional) A function to be executed whenever the animation completes.\r
41                  * @param String easing (optional) The name of the easing effect that you want to use.\r
42                  * @type jQuery\r
43                  * @cat Plugins/Interface\r
44                  * @author Stefan Petre\r
45                  */\r
46                 BlindDown : function (speed, callback, easing)\r
47                 {\r
48                         return this.queue('interfaceFX',function(){\r
49                                 new jQuery.fx.BlindDirection(this, speed, callback, 'down', easing);\r
50                         });\r
51                 },\r
52                 \r
53                 /**\r
54                  * @name BlindToggleVertically\r
55                  * @description blinds the element up or down\r
56                  * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast']\r
57                  * @param Function callback (optional) A function to be executed whenever the animation completes.\r
58                  * @param String easing (optional) The name of the easing effect that you want to use.\r
59                  * @type jQuery\r
60                  * @cat Plugins/Interface\r
61                  * @author Stefan Petre\r
62                  */\r
63                 BlindToggleVertically : function (speed, callback, easing)\r
64                 {\r
65                         return this.queue('interfaceFX',function(){\r
66                                 new jQuery.fx.BlindDirection(this, speed, callback, 'togglever', easing);\r
67                         });\r
68                 },\r
69                 \r
70                 /**\r
71                  * @name BlindLeft\r
72                  * @description blinds the element left\r
73                  * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast']\r
74                  * @param Function callback (optional) A function to be executed whenever the animation completes.\r
75                  * @param String easing (optional) The name of the easing effect that you want to use.\r
76                  * @type jQuery\r
77                  * @cat Plugins/Interface\r
78                  * @author Stefan Petre\r
79                  */\r
80                 BlindLeft : function (speed, callback, easing)\r
81                 {\r
82                         return this.queue('interfaceFX',function(){\r
83                                 new jQuery.fx.BlindDirection(this, speed, callback, 'left', easing);\r
84                         });\r
85                 },\r
86                 \r
87                 /**\r
88                  * @name BlindRight\r
89                  * @description blinds the element right\r
90                  * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast']\r
91                  * @param Function callback (optional) A function to be executed whenever the animation completes.\r
92                  * @param String easing (optional) The name of the easing effect that you want to use.\r
93                  * @type jQuery\r
94                  * @cat Plugins/Interface\r
95                  * @author Stefan Petre\r
96                  */\r
97                 BlindRight : function (speed, callback, easing)\r
98                 {\r
99                         return this.queue('interfaceFX',function(){\r
100                                 new jQuery.fx.BlindDirection(this, speed, callback, 'right', easing);\r
101                         });\r
102                 },\r
103                 \r
104                 /**\r
105                  * @name BlindToggleHorizontally\r
106                  * @description blinds the element left and right\r
107                  * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast']\r
108                  * @param Function callback (optional) A function to be executed whenever the animation completes.\r
109                  * @param String easing (optional) The name of the easing effect that you want to use.\r
110                  * @type jQuery\r
111                  * @cat Plugins/Interface\r
112                  * @author Stefan Petre\r
113                  */\r
114                 BlindToggleHorizontally : function (speed, callback, easing)\r
115                 {\r
116                         return this.queue('interfaceFX',function(){\r
117                                 new jQuery.fx.BlindDirection(this, speed, callback, 'togglehor', easing);\r
118                         });\r
119                 }\r
120         }\r
121 );\r
122 \r
123 jQuery.fx.BlindDirection = function (e, speed, callback, direction, easing)\r
124 {\r
125         if (!jQuery.fxCheckTag(e)) {\r
126                 jQuery.dequeue(e, 'interfaceFX');\r
127                 return false;\r
128         }\r
129         var z = this;\r
130         z.el = jQuery(e);\r
131         z.size = jQuery.iUtil.getSize(e);\r
132         z.easing = typeof callback == 'string' ? callback : easing||null;\r
133         if (!e.ifxFirstDisplay)\r
134                 e.ifxFirstDisplay = z.el.css('display');\r
135         if ( direction == 'togglever') {\r
136                 direction = z.el.css('display') == 'none' ? 'down' : 'up';\r
137         } else if (direction == 'togglehor') {\r
138                 direction = z.el.css('display') == 'none' ? 'right' : 'left';\r
139         }\r
140         z.el.show();\r
141         z.speed = speed;\r
142         z.callback = typeof callback == 'function' ? callback : null;\r
143         z.fx = jQuery.fx.buildWrapper(e);\r
144         z.direction = direction;\r
145         z.complete = function()\r
146         {\r
147                 if (z.callback && z.callback.constructor == Function) {\r
148                         z.callback.apply(z.el.get(0));\r
149                 }\r
150                 if(z.direction == 'down' || z.direction == 'right'){\r
151                         z.el.css('display', z.el.get(0).ifxFirstDisplay == 'none' ? 'block' : z.el.get(0).ifxFirstDisplay);\r
152                 } else {\r
153                         z.el.hide();\r
154                 }\r
155                 jQuery.fx.destroyWrapper(z.fx.wrapper.get(0), z.fx.oldStyle);\r
156                 jQuery.dequeue(z.el.get(0), 'interfaceFX');\r
157         };\r
158         switch (z.direction) {\r
159                 case 'up':\r
160                         fxh = new jQuery.fx(\r
161                                 z.fx.wrapper.get(0),\r
162                                 jQuery.speed(\r
163                                         z.speed,\r
164                                         z.easing,\r
165                                         z.complete\r
166                                 ),\r
167                                 'height'\r
168                         );\r
169                         fxh.custom(z.fx.oldStyle.sizes.hb, 0);\r
170                 break;\r
171                 case 'down':\r
172                         z.fx.wrapper.css('height', '1px');\r
173                         z.el.show();\r
174                         fxh = new jQuery.fx(\r
175                                 z.fx.wrapper.get(0),\r
176                                 jQuery.speed(\r
177                                         z.speed,\r
178                                         z.easing,\r
179                                         z.complete\r
180                                 ),\r
181                                 'height'\r
182                         );\r
183                         fxh.custom(0, z.fx.oldStyle.sizes.hb);\r
184                 break;\r
185                 case 'left':\r
186                         fxh = new jQuery.fx(\r
187                                 z.fx.wrapper.get(0),\r
188                                 jQuery.speed(\r
189                                         z.speed,\r
190                                         z.easing,\r
191                                         z.complete\r
192                                 ),\r
193                                 'width'\r
194                         );\r
195                         fxh.custom(z.fx.oldStyle.sizes.wb, 0);\r
196                 break;\r
197                 case 'right':\r
198                         z.fx.wrapper.css('width', '1px');\r
199                         z.el.show();\r
200                         fxh = new jQuery.fx(\r
201                                 z.fx.wrapper.get(0),\r
202                                 jQuery.speed(\r
203                                         z.speed,\r
204                                         z.easing,\r
205                                         z.complete\r
206                                 ),\r
207                                 'width'\r
208                         );\r
209                         fxh.custom(0, z.fx.oldStyle.sizes.wb);\r
210                 break;\r
211         }\r
212 };