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