1 | /*
|
---|
2 | * jQuery UI Effects 1.8rc1
|
---|
3 | *
|
---|
4 | * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
|
---|
5 | * Dual licensed under the MIT (MIT-LICENSE.txt)
|
---|
6 | * and GPL (GPL-LICENSE.txt) licenses.
|
---|
7 | *
|
---|
8 | * http://docs.jquery.com/UI/Effects/
|
---|
9 | */
|
---|
10 | ;jQuery.effects || (function($) {
|
---|
11 |
|
---|
12 | $.effects = {};
|
---|
13 |
|
---|
14 |
|
---|
15 |
|
---|
16 | /******************************************************************************/
|
---|
17 | /****************************** COLOR ANIMATIONS ******************************/
|
---|
18 | /******************************************************************************/
|
---|
19 |
|
---|
20 | // override the animation for color styles
|
---|
21 | $.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor',
|
---|
22 | 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'],
|
---|
23 | function(i, attr) {
|
---|
24 | $.fx.step[attr] = function(fx) {
|
---|
25 | if (!fx.colorInit) {
|
---|
26 | fx.start = getColor(fx.elem, attr);
|
---|
27 | fx.end = getRGB(fx.end);
|
---|
28 | fx.colorInit = true;
|
---|
29 | }
|
---|
30 |
|
---|
31 | fx.elem.style[attr] = 'rgb(' +
|
---|
32 | Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10), 255), 0) + ',' +
|
---|
33 | Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10), 255), 0) + ',' +
|
---|
34 | Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10), 255), 0) + ')';
|
---|
35 | };
|
---|
36 | });
|
---|
37 |
|
---|
38 | // Color Conversion functions from highlightFade
|
---|
39 | // By Blair Mitchelmore
|
---|
40 | // http://jquery.offput.ca/highlightFade/
|
---|
41 |
|
---|
42 | // Parse strings looking for color tuples [255,255,255]
|
---|
43 | function getRGB(color) {
|
---|
44 | var result;
|
---|
45 |
|
---|
46 | // Check if we're already dealing with an array of colors
|
---|
47 | if ( color && color.constructor == Array && color.length == 3 )
|
---|
48 | return color;
|
---|
49 |
|
---|
50 | // Look for rgb(num,num,num)
|
---|
51 | if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
|
---|
52 | return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)];
|
---|
53 |
|
---|
54 | // Look for rgb(num%,num%,num%)
|
---|
55 | if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
|
---|
56 | return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
|
---|
57 |
|
---|
58 | // Look for #a0b1c2
|
---|
59 | if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
|
---|
60 | return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
|
---|
61 |
|
---|
62 | // Look for #fff
|
---|
63 | if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
|
---|
64 | return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
|
---|
65 |
|
---|
66 | // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
|
---|
67 | if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
|
---|
68 | return colors['transparent'];
|
---|
69 |
|
---|
70 | // Otherwise, we're most likely dealing with a named color
|
---|
71 | return colors[$.trim(color).toLowerCase()];
|
---|
72 | }
|
---|
73 |
|
---|
74 | function getColor(elem, attr) {
|
---|
75 | var color;
|
---|
76 |
|
---|
77 | do {
|
---|
78 | color = $.curCSS(elem, attr);
|
---|
79 |
|
---|
80 | // Keep going until we find an element that has color, or we hit the body
|
---|
81 | if ( color != '' && color != 'transparent' || $.nodeName(elem, "body") )
|
---|
82 | break;
|
---|
83 |
|
---|
84 | attr = "backgroundColor";
|
---|
85 | } while ( elem = elem.parentNode );
|
---|
86 |
|
---|
87 | return getRGB(color);
|
---|
88 | };
|
---|
89 |
|
---|
90 | // Some named colors to work with
|
---|
91 | // From Interface by Stefan Petre
|
---|
92 | // http://interface.eyecon.ro/
|
---|
93 |
|
---|
94 | var colors = {
|
---|
95 | aqua:[0,255,255],
|
---|
96 | azure:[240,255,255],
|
---|
97 | beige:[245,245,220],
|
---|
98 | black:[0,0,0],
|
---|
99 | blue:[0,0,255],
|
---|
100 | brown:[165,42,42],
|
---|
101 | cyan:[0,255,255],
|
---|
102 | darkblue:[0,0,139],
|
---|
103 | darkcyan:[0,139,139],
|
---|
104 | darkgrey:[169,169,169],
|
---|
105 | darkgreen:[0,100,0],
|
---|
106 | darkkhaki:[189,183,107],
|
---|
107 | darkmagenta:[139,0,139],
|
---|
108 | darkolivegreen:[85,107,47],
|
---|
109 | darkorange:[255,140,0],
|
---|
110 | darkorchid:[153,50,204],
|
---|
111 | darkred:[139,0,0],
|
---|
112 | darksalmon:[233,150,122],
|
---|
113 | darkviolet:[148,0,211],
|
---|
114 | fuchsia:[255,0,255],
|
---|
115 | gold:[255,215,0],
|
---|
116 | green:[0,128,0],
|
---|
117 | indigo:[75,0,130],
|
---|
118 | khaki:[240,230,140],
|
---|
119 | lightblue:[173,216,230],
|
---|
120 | lightcyan:[224,255,255],
|
---|
121 | lightgreen:[144,238,144],
|
---|
122 | lightgrey:[211,211,211],
|
---|
123 | lightpink:[255,182,193],
|
---|
124 | lightyellow:[255,255,224],
|
---|
125 | lime:[0,255,0],
|
---|
126 | magenta:[255,0,255],
|
---|
127 | maroon:[128,0,0],
|
---|
128 | navy:[0,0,128],
|
---|
129 | olive:[128,128,0],
|
---|
130 | orange:[255,165,0],
|
---|
131 | pink:[255,192,203],
|
---|
132 | purple:[128,0,128],
|
---|
133 | violet:[128,0,128],
|
---|
134 | red:[255,0,0],
|
---|
135 | silver:[192,192,192],
|
---|
136 | white:[255,255,255],
|
---|
137 | yellow:[255,255,0],
|
---|
138 | transparent: [255,255,255]
|
---|
139 | };
|
---|
140 |
|
---|
141 |
|
---|
142 |
|
---|
143 | /******************************************************************************/
|
---|
144 | /****************************** CLASS ANIMATIONS ******************************/
|
---|
145 | /******************************************************************************/
|
---|
146 |
|
---|
147 | var classAnimationActions = ['add', 'remove', 'toggle'],
|
---|
148 | shorthandStyles = {
|
---|
149 | border: 1,
|
---|
150 | borderBottom: 1,
|
---|
151 | borderColor: 1,
|
---|
152 | borderLeft: 1,
|
---|
153 | borderRight: 1,
|
---|
154 | borderTop: 1,
|
---|
155 | borderWidth: 1,
|
---|
156 | margin: 1,
|
---|
157 | padding: 1
|
---|
158 | };
|
---|
159 |
|
---|
160 | function getElementStyles() {
|
---|
161 | var style = document.defaultView
|
---|
162 | ? document.defaultView.getComputedStyle(this, null)
|
---|
163 | : this.currentStyle,
|
---|
164 | newStyle = {},
|
---|
165 | key,
|
---|
166 | camelCase;
|
---|
167 |
|
---|
168 | // webkit enumerates style porperties
|
---|
169 | if (style && style.length && style[0] && style[style[0]]) {
|
---|
170 | var len = style.length;
|
---|
171 | while (len--) {
|
---|
172 | key = style[len];
|
---|
173 | if (typeof style[key] == 'string') {
|
---|
174 | camelCase = key.replace(/\-(\w)/g, function(all, letter){
|
---|
175 | return letter.toUpperCase();
|
---|
176 | });
|
---|
177 | newStyle[camelCase] = style[key];
|
---|
178 | }
|
---|
179 | }
|
---|
180 | } else {
|
---|
181 | for (key in style) {
|
---|
182 | if (typeof style[key] === 'string') {
|
---|
183 | newStyle[key] = style[key];
|
---|
184 | }
|
---|
185 | }
|
---|
186 | }
|
---|
187 |
|
---|
188 | return newStyle;
|
---|
189 | }
|
---|
190 |
|
---|
191 | function filterStyles(styles) {
|
---|
192 | var name, value;
|
---|
193 | for (name in styles) {
|
---|
194 | value = styles[name];
|
---|
195 | if (
|
---|
196 | // ignore null and undefined values
|
---|
197 | value == null ||
|
---|
198 | // ignore functions (when does this occur?)
|
---|
199 | $.isFunction(value) ||
|
---|
200 | // shorthand styles that need to be expanded
|
---|
201 | name in shorthandStyles ||
|
---|
202 | // ignore scrollbars (break in IE)
|
---|
203 | (/scrollbar/).test(name) ||
|
---|
204 |
|
---|
205 | // only colors or values that can be converted to numbers
|
---|
206 | (!(/color/i).test(name) && isNaN(parseFloat(value)))
|
---|
207 | ) {
|
---|
208 | delete styles[name];
|
---|
209 | }
|
---|
210 | }
|
---|
211 |
|
---|
212 | return styles;
|
---|
213 | }
|
---|
214 |
|
---|
215 | function styleDifference(oldStyle, newStyle) {
|
---|
216 | var diff = { _: 0 }, // http://dev.jquery.com/ticket/5459
|
---|
217 | name;
|
---|
218 |
|
---|
219 | for (name in newStyle) {
|
---|
220 | if (oldStyle[name] != newStyle[name]) {
|
---|
221 | diff[name] = newStyle[name];
|
---|
222 | }
|
---|
223 | }
|
---|
224 |
|
---|
225 | return diff;
|
---|
226 | }
|
---|
227 |
|
---|
228 | $.effects.animateClass = function(value, duration, easing, callback) {
|
---|
229 | if ($.isFunction(easing)) {
|
---|
230 | callback = easing;
|
---|
231 | easing = null;
|
---|
232 | }
|
---|
233 |
|
---|
234 | return this.each(function() {
|
---|
235 |
|
---|
236 | var that = $(this),
|
---|
237 | originalStyleAttr = that.attr('style') || ' ',
|
---|
238 | originalStyle = filterStyles(getElementStyles.call(this)),
|
---|
239 | newStyle,
|
---|
240 | className = that.attr('className');
|
---|
241 |
|
---|
242 | $.each(classAnimationActions, function(i, action) {
|
---|
243 | if (value[action]) {
|
---|
244 | that[action + 'Class'](value[action]);
|
---|
245 | }
|
---|
246 | });
|
---|
247 | newStyle = filterStyles(getElementStyles.call(this));
|
---|
248 | that.attr('className', className);
|
---|
249 |
|
---|
250 | that.animate(styleDifference(originalStyle, newStyle), duration, easing, function() {
|
---|
251 | $.each(classAnimationActions, function(i, action) {
|
---|
252 | if (value[action]) { that[action + 'Class'](value[action]); }
|
---|
253 | });
|
---|
254 | // work around bug in IE by clearing the cssText before setting it
|
---|
255 | if (typeof that.attr('style') == 'object') {
|
---|
256 | that.attr('style').cssText = '';
|
---|
257 | that.attr('style').cssText = originalStyleAttr;
|
---|
258 | } else {
|
---|
259 | that.attr('style', originalStyleAttr);
|
---|
260 | }
|
---|
261 | if (callback) { callback.apply(this, arguments); }
|
---|
262 | });
|
---|
263 | });
|
---|
264 | };
|
---|
265 |
|
---|
266 | $.fn.extend({
|
---|
267 | _addClass: $.fn.addClass,
|
---|
268 | addClass: function(classNames, speed, easing, callback) {
|
---|
269 | return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames);
|
---|
270 | },
|
---|
271 |
|
---|
272 | _removeClass: $.fn.removeClass,
|
---|
273 | removeClass: function(classNames,speed,easing,callback) {
|
---|
274 | return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames);
|
---|
275 | },
|
---|
276 |
|
---|
277 | _toggleClass: $.fn.toggleClass,
|
---|
278 | toggleClass: function(classNames, force, speed, easing, callback) {
|
---|
279 | if ( typeof force == "boolean" || force === undefined ) {
|
---|
280 | if ( !speed ) {
|
---|
281 | // without speed parameter;
|
---|
282 | return this._toggleClass(classNames, force);
|
---|
283 | } else {
|
---|
284 | return $.effects.animateClass.apply(this, [(force?{add:classNames}:{remove:classNames}),speed,easing,callback]);
|
---|
285 | }
|
---|
286 | } else {
|
---|
287 | // without switch parameter;
|
---|
288 | return $.effects.animateClass.apply(this, [{ toggle: classNames },force,speed,easing]);
|
---|
289 | }
|
---|
290 | },
|
---|
291 |
|
---|
292 | switchClass: function(remove,add,speed,easing,callback) {
|
---|
293 | return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]);
|
---|
294 | }
|
---|
295 | });
|
---|
296 |
|
---|
297 |
|
---|
298 |
|
---|
299 | /******************************************************************************/
|
---|
300 | /*********************************** EFFECTS **********************************/
|
---|
301 | /******************************************************************************/
|
---|
302 |
|
---|
303 | $.extend($.effects, {
|
---|
304 | version: "1.8rc1",
|
---|
305 |
|
---|
306 | // Saves a set of properties in a data storage
|
---|
307 | save: function(element, set) {
|
---|
308 | for(var i=0; i < set.length; i++) {
|
---|
309 | if(set[i] !== null) element.data("ec.storage."+set[i], element[0].style[set[i]]);
|
---|
310 | }
|
---|
311 | },
|
---|
312 |
|
---|
313 | // Restores a set of previously saved properties from a data storage
|
---|
314 | restore: function(element, set) {
|
---|
315 | for(var i=0; i < set.length; i++) {
|
---|
316 | if(set[i] !== null) element.css(set[i], element.data("ec.storage."+set[i]));
|
---|
317 | }
|
---|
318 | },
|
---|
319 |
|
---|
320 | setMode: function(el, mode) {
|
---|
321 | if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle
|
---|
322 | return mode;
|
---|
323 | },
|
---|
324 |
|
---|
325 | getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value
|
---|
326 | // this should be a little more flexible in the future to handle a string & hash
|
---|
327 | var y, x;
|
---|
328 | switch (origin[0]) {
|
---|
329 | case 'top': y = 0; break;
|
---|
330 | case 'middle': y = 0.5; break;
|
---|
331 | case 'bottom': y = 1; break;
|
---|
332 | default: y = origin[0] / original.height;
|
---|
333 | };
|
---|
334 | switch (origin[1]) {
|
---|
335 | case 'left': x = 0; break;
|
---|
336 | case 'center': x = 0.5; break;
|
---|
337 | case 'right': x = 1; break;
|
---|
338 | default: x = origin[1] / original.width;
|
---|
339 | };
|
---|
340 | return {x: x, y: y};
|
---|
341 | },
|
---|
342 |
|
---|
343 | // Wraps the element around a wrapper that copies position properties
|
---|
344 | createWrapper: function(element) {
|
---|
345 |
|
---|
346 | // if the element is already wrapped, return it
|
---|
347 | if (element.parent().is('.ui-effects-wrapper')) {
|
---|
348 | return element.parent();
|
---|
349 | }
|
---|
350 |
|
---|
351 | // wrap the element
|
---|
352 | var props = {
|
---|
353 | width: element.outerWidth(true),
|
---|
354 | height: element.outerHeight(true),
|
---|
355 | 'float': element.css('float')
|
---|
356 | },
|
---|
357 | wrapper = $('<div></div>')
|
---|
358 | .addClass('ui-effects-wrapper')
|
---|
359 | .css({
|
---|
360 | fontSize: '100%',
|
---|
361 | background: 'transparent',
|
---|
362 | border: 'none',
|
---|
363 | margin: 0,
|
---|
364 | padding: 0
|
---|
365 | });
|
---|
366 |
|
---|
367 | element.wrap(wrapper);
|
---|
368 |
|
---|
369 | // transfer positioning properties to the wrapper
|
---|
370 | if (element.css('position') == 'static') {
|
---|
371 | wrapper.css({ position: 'relative' });
|
---|
372 | element.css({ position: 'relative' });
|
---|
373 | } else {
|
---|
374 | $.extend(props, {
|
---|
375 | position: element.css('position'),
|
---|
376 | zIndex: element.css('z-index')
|
---|
377 | });
|
---|
378 | $.each(['top', 'left', 'bottom', 'right'], function(i, pos) {
|
---|
379 | props[pos] = element.css(pos);
|
---|
380 | if (isNaN(parseInt(props[pos], 10))) {
|
---|
381 | props[pos] = 'auto';
|
---|
382 | }
|
---|
383 | });
|
---|
384 | element.css({position: 'relative', top: 0, left: 0 });
|
---|
385 | }
|
---|
386 |
|
---|
387 | return wrapper.css(props).show();
|
---|
388 | },
|
---|
389 |
|
---|
390 | removeWrapper: function(element) {
|
---|
391 | if (element.parent().is('.ui-effects-wrapper'))
|
---|
392 | return element.parent().replaceWith(element);
|
---|
393 | return element;
|
---|
394 | },
|
---|
395 |
|
---|
396 | setTransition: function(element, list, factor, value) {
|
---|
397 | value = value || {};
|
---|
398 | $.each(list, function(i, x){
|
---|
399 | unit = element.cssUnit(x);
|
---|
400 | if (unit[0] > 0) value[x] = unit[0] * factor + unit[1];
|
---|
401 | });
|
---|
402 | return value;
|
---|
403 | }
|
---|
404 | });
|
---|
405 |
|
---|
406 |
|
---|
407 | function _normalizeArguments(effect, options, speed, callback) {
|
---|
408 | // shift params for method overloading
|
---|
409 | if (typeof effect == 'object') {
|
---|
410 | callback = options;
|
---|
411 | speed = null;
|
---|
412 | options = effect;
|
---|
413 | effect = options.effect;
|
---|
414 | }
|
---|
415 | if ($.isFunction(options)) {
|
---|
416 | callback = options;
|
---|
417 | speed = null;
|
---|
418 | options = {};
|
---|
419 | }
|
---|
420 | if (typeof options == 'number') {
|
---|
421 | callback = speed;
|
---|
422 | speed = options;
|
---|
423 | options = {};
|
---|
424 | }
|
---|
425 |
|
---|
426 | options = options || {};
|
---|
427 |
|
---|
428 | speed = speed || options.duration;
|
---|
429 | speed = $.fx.off ? 0 : typeof speed == 'number'
|
---|
430 | ? speed : $.fx.speeds[speed] || $.fx.speeds._default;
|
---|
431 |
|
---|
432 | callback = callback || options.complete;
|
---|
433 |
|
---|
434 | return [effect, options, speed, callback];
|
---|
435 | }
|
---|
436 |
|
---|
437 | $.fn.extend({
|
---|
438 | effect: function(effect, options, speed, callback) {
|
---|
439 | var args = _normalizeArguments.apply(this, arguments),
|
---|
440 | // TODO: make effects takes actual parameters instead of a hash
|
---|
441 | args2 = {
|
---|
442 | options: args[1],
|
---|
443 | duration: args[2],
|
---|
444 | callback: args[3]
|
---|
445 | },
|
---|
446 | effectMethod = $.effects[effect];
|
---|
447 |
|
---|
448 | return effectMethod && !$.fx.off ? effectMethod.call(this, args2) : this;
|
---|
449 | },
|
---|
450 |
|
---|
451 | _show: $.fn.show,
|
---|
452 | show: function(speed) {
|
---|
453 | if (!speed || typeof speed == 'number' || $.fx.speeds[speed]) {
|
---|
454 | return this._show.apply(this, arguments);
|
---|
455 | } else {
|
---|
456 | var args = _normalizeArguments.apply(this, arguments);
|
---|
457 | args[1].mode = 'show';
|
---|
458 | return this.effect.apply(this, args);
|
---|
459 | }
|
---|
460 | },
|
---|
461 |
|
---|
462 | _hide: $.fn.hide,
|
---|
463 | hide: function(speed) {
|
---|
464 | if (!speed || typeof speed == 'number' || $.fx.speeds[speed]) {
|
---|
465 | return this._hide.apply(this, arguments);
|
---|
466 | } else {
|
---|
467 | var args = _normalizeArguments.apply(this, arguments);
|
---|
468 | args[1].mode = 'hide';
|
---|
469 | return this.effect.apply(this, args);
|
---|
470 | }
|
---|
471 | },
|
---|
472 |
|
---|
473 | // jQuery core overloads toggle and create _toggle
|
---|
474 | __toggle: $.fn.toggle,
|
---|
475 | toggle: function(speed) {
|
---|
476 | if (!speed || typeof speed == 'number' || $.fx.speeds[speed] ||
|
---|
477 | typeof speed == 'boolean' || $.isFunction(speed)) {
|
---|
478 | return this.__toggle.apply(this, arguments);
|
---|
479 | } else {
|
---|
480 | var args = _normalizeArguments.apply(this, arguments);
|
---|
481 | args[1].mode = 'toggle';
|
---|
482 | return this.effect.apply(this, args);
|
---|
483 | }
|
---|
484 | },
|
---|
485 |
|
---|
486 | // helper functions
|
---|
487 | cssUnit: function(key) {
|
---|
488 | var style = this.css(key), val = [];
|
---|
489 | $.each( ['em','px','%','pt'], function(i, unit){
|
---|
490 | if(style.indexOf(unit) > 0)
|
---|
491 | val = [parseFloat(style), unit];
|
---|
492 | });
|
---|
493 | return val;
|
---|
494 | }
|
---|
495 | });
|
---|
496 |
|
---|
497 |
|
---|
498 |
|
---|
499 | /******************************************************************************/
|
---|
500 | /*********************************** EASING ***********************************/
|
---|
501 | /******************************************************************************/
|
---|
502 |
|
---|
503 | /*
|
---|
504 | * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
|
---|
505 | *
|
---|
506 | * Uses the built in easing capabilities added In jQuery 1.1
|
---|
507 | * to offer multiple easing options
|
---|
508 | *
|
---|
509 | * TERMS OF USE - jQuery Easing
|
---|
510 | *
|
---|
511 | * Open source under the BSD License.
|
---|
512 | *
|
---|
513 | * Copyright 2008 George McGinley Smith
|
---|
514 | * All rights reserved.
|
---|
515 | *
|
---|
516 | * Redistribution and use in source and binary forms, with or without modification,
|
---|
517 | * are permitted provided that the following conditions are met:
|
---|
518 | *
|
---|
519 | * Redistributions of source code must retain the above copyright notice, this list of
|
---|
520 | * conditions and the following disclaimer.
|
---|
521 | * Redistributions in binary form must reproduce the above copyright notice, this list
|
---|
522 | * of conditions and the following disclaimer in the documentation and/or other materials
|
---|
523 | * provided with the distribution.
|
---|
524 | *
|
---|
525 | * Neither the name of the author nor the names of contributors may be used to endorse
|
---|
526 | * or promote products derived from this software without specific prior written permission.
|
---|
527 | *
|
---|
528 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
---|
529 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
---|
530 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
---|
531 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
---|
532 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
---|
533 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
---|
534 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
---|
535 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
---|
536 | * OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
537 | *
|
---|
538 | */
|
---|
539 |
|
---|
540 | // t: current time, b: begInnIng value, c: change In value, d: duration
|
---|
541 | $.easing.jswing = $.easing.swing;
|
---|
542 |
|
---|
543 | $.extend($.easing,
|
---|
544 | {
|
---|
545 | def: 'easeOutQuad',
|
---|
546 | swing: function (x, t, b, c, d) {
|
---|
547 | //alert($.easing.default);
|
---|
548 | return $.easing[$.easing.def](x, t, b, c, d);
|
---|
549 | },
|
---|
550 | easeInQuad: function (x, t, b, c, d) {
|
---|
551 | return c*(t/=d)*t + b;
|
---|
552 | },
|
---|
553 | easeOutQuad: function (x, t, b, c, d) {
|
---|
554 | return -c *(t/=d)*(t-2) + b;
|
---|
555 | },
|
---|
556 | easeInOutQuad: function (x, t, b, c, d) {
|
---|
557 | if ((t/=d/2) < 1) return c/2*t*t + b;
|
---|
558 | return -c/2 * ((--t)*(t-2) - 1) + b;
|
---|
559 | },
|
---|
560 | easeInCubic: function (x, t, b, c, d) {
|
---|
561 | return c*(t/=d)*t*t + b;
|
---|
562 | },
|
---|
563 | easeOutCubic: function (x, t, b, c, d) {
|
---|
564 | return c*((t=t/d-1)*t*t + 1) + b;
|
---|
565 | },
|
---|
566 | easeInOutCubic: function (x, t, b, c, d) {
|
---|
567 | if ((t/=d/2) < 1) return c/2*t*t*t + b;
|
---|
568 | return c/2*((t-=2)*t*t + 2) + b;
|
---|
569 | },
|
---|
570 | easeInQuart: function (x, t, b, c, d) {
|
---|
571 | return c*(t/=d)*t*t*t + b;
|
---|
572 | },
|
---|
573 | easeOutQuart: function (x, t, b, c, d) {
|
---|
574 | return -c * ((t=t/d-1)*t*t*t - 1) + b;
|
---|
575 | },
|
---|
576 | easeInOutQuart: function (x, t, b, c, d) {
|
---|
577 | if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
|
---|
578 | return -c/2 * ((t-=2)*t*t*t - 2) + b;
|
---|
579 | },
|
---|
580 | easeInQuint: function (x, t, b, c, d) {
|
---|
581 | return c*(t/=d)*t*t*t*t + b;
|
---|
582 | },
|
---|
583 | easeOutQuint: function (x, t, b, c, d) {
|
---|
584 | return c*((t=t/d-1)*t*t*t*t + 1) + b;
|
---|
585 | },
|
---|
586 | easeInOutQuint: function (x, t, b, c, d) {
|
---|
587 | if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
|
---|
588 | return c/2*((t-=2)*t*t*t*t + 2) + b;
|
---|
589 | },
|
---|
590 | easeInSine: function (x, t, b, c, d) {
|
---|
591 | return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
|
---|
592 | },
|
---|
593 | easeOutSine: function (x, t, b, c, d) {
|
---|
594 | return c * Math.sin(t/d * (Math.PI/2)) + b;
|
---|
595 | },
|
---|
596 | easeInOutSine: function (x, t, b, c, d) {
|
---|
597 | return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
|
---|
598 | },
|
---|
599 | easeInExpo: function (x, t, b, c, d) {
|
---|
600 | return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
|
---|
601 | },
|
---|
602 | easeOutExpo: function (x, t, b, c, d) {
|
---|
603 | return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
|
---|
604 | },
|
---|
605 | easeInOutExpo: function (x, t, b, c, d) {
|
---|
606 | if (t==0) return b;
|
---|
607 | if (t==d) return b+c;
|
---|
608 | if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
|
---|
609 | return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
|
---|
610 | },
|
---|
611 | easeInCirc: function (x, t, b, c, d) {
|
---|
612 | return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
|
---|
613 | },
|
---|
614 | easeOutCirc: function (x, t, b, c, d) {
|
---|
615 | return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
|
---|
616 | },
|
---|
617 | easeInOutCirc: function (x, t, b, c, d) {
|
---|
618 | if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
|
---|
619 | return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
|
---|
620 | },
|
---|
621 | easeInElastic: function (x, t, b, c, d) {
|
---|
622 | var s=1.70158;var p=0;var a=c;
|
---|
623 | if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
---|
624 | if (a < Math.abs(c)) { a=c; var s=p/4; }
|
---|
625 | else var s = p/(2*Math.PI) * Math.asin (c/a);
|
---|
626 | return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
---|
627 | },
|
---|
628 | easeOutElastic: function (x, t, b, c, d) {
|
---|
629 | var s=1.70158;var p=0;var a=c;
|
---|
630 | if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
---|
631 | if (a < Math.abs(c)) { a=c; var s=p/4; }
|
---|
632 | else var s = p/(2*Math.PI) * Math.asin (c/a);
|
---|
633 | return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
|
---|
634 | },
|
---|
635 | easeInOutElastic: function (x, t, b, c, d) {
|
---|
636 | var s=1.70158;var p=0;var a=c;
|
---|
637 | if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
|
---|
638 | if (a < Math.abs(c)) { a=c; var s=p/4; }
|
---|
639 | else var s = p/(2*Math.PI) * Math.asin (c/a);
|
---|
640 | if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
---|
641 | return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
|
---|
642 | },
|
---|
643 | easeInBack: function (x, t, b, c, d, s) {
|
---|
644 | if (s == undefined) s = 1.70158;
|
---|
645 | return c*(t/=d)*t*((s+1)*t - s) + b;
|
---|
646 | },
|
---|
647 | easeOutBack: function (x, t, b, c, d, s) {
|
---|
648 | if (s == undefined) s = 1.70158;
|
---|
649 | return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
|
---|
650 | },
|
---|
651 | easeInOutBack: function (x, t, b, c, d, s) {
|
---|
652 | if (s == undefined) s = 1.70158;
|
---|
653 | if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
|
---|
654 | return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
|
---|
655 | },
|
---|
656 | easeInBounce: function (x, t, b, c, d) {
|
---|
657 | return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b;
|
---|
658 | },
|
---|
659 | easeOutBounce: function (x, t, b, c, d) {
|
---|
660 | if ((t/=d) < (1/2.75)) {
|
---|
661 | return c*(7.5625*t*t) + b;
|
---|
662 | } else if (t < (2/2.75)) {
|
---|
663 | return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
|
---|
664 | } else if (t < (2.5/2.75)) {
|
---|
665 | return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
|
---|
666 | } else {
|
---|
667 | return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
|
---|
668 | }
|
---|
669 | },
|
---|
670 | easeInOutBounce: function (x, t, b, c, d) {
|
---|
671 | if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
|
---|
672 | return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
|
---|
673 | }
|
---|
674 | });
|
---|
675 |
|
---|
676 | /*
|
---|
677 | *
|
---|
678 | * TERMS OF USE - EASING EQUATIONS
|
---|
679 | *
|
---|
680 | * Open source under the BSD License.
|
---|
681 | *
|
---|
682 | * Copyright 2001 Robert Penner
|
---|
683 | * All rights reserved.
|
---|
684 | *
|
---|
685 | * Redistribution and use in source and binary forms, with or without modification,
|
---|
686 | * are permitted provided that the following conditions are met:
|
---|
687 | *
|
---|
688 | * Redistributions of source code must retain the above copyright notice, this list of
|
---|
689 | * conditions and the following disclaimer.
|
---|
690 | * Redistributions in binary form must reproduce the above copyright notice, this list
|
---|
691 | * of conditions and the following disclaimer in the documentation and/or other materials
|
---|
692 | * provided with the distribution.
|
---|
693 | *
|
---|
694 | * Neither the name of the author nor the names of contributors may be used to endorse
|
---|
695 | * or promote products derived from this software without specific prior written permission.
|
---|
696 | *
|
---|
697 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
---|
698 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
---|
699 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
---|
700 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
---|
701 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
---|
702 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
---|
703 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
---|
704 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
---|
705 | * OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
706 | *
|
---|
707 | */
|
---|
708 |
|
---|
709 | })(jQuery);
|
---|