source: trunk/template-common/lib/ui/effects.fold.js @ 3282

Last change on this file since 3282 was 3282, checked in by plg, 15 years ago

change: according to topic:15067, svn:keywords property was removed

  • Property svn:eol-style set to LF
File size: 1.8 KB
Line 
1/*
2 * jQuery UI Effects Fold
3 *
4 * Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
5 * Dual licensed under the MIT (MIT-LICENSE.txt)
6 * and GPL (GPL-LICENSE.txt) licenses.
7 *
8 * http://docs.jquery.com/UI/Effects/Fold
9 *
10 * Depends:
11 *      effects.core.js
12 */
13(function($) {
14
15$.effects.fold = function(o) {
16
17        return this.queue(function() {
18
19                // Create element
20                var el = $(this), props = ['position','top','left'];
21               
22                // Set options
23                var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
24                var size = o.options.size || 15; // Default fold size
25                var horizFirst = !(!o.options.horizFirst); // Ensure a boolean value
26               
27                // Adjust
28                $.effects.save(el, props); el.show(); // Save & Show
29                var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
30                var widthFirst = ((mode == 'show') != horizFirst);
31                var ref = widthFirst ? ['width', 'height'] : ['height', 'width'];
32                var distance = widthFirst ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()];
33                var percent = /([0-9]+)%/.exec(size);
34                if(percent) size = parseInt(percent[1]) / 100 * distance[mode == 'hide' ? 0 : 1];
35                if(mode == 'show') wrapper.css(horizFirst ? {height: 0, width: size} : {height: size, width: 0}); // Shift
36               
37                // Animation
38                var animation1 = {}, animation2 = {};
39                animation1[ref[0]] = mode == 'show' ? distance[0] : size;
40                animation2[ref[1]] = mode == 'show' ? distance[1] : 0;
41               
42                // Animate
43                wrapper.animate(animation1, o.duration / 2, o.options.easing)
44                .animate(animation2, o.duration / 2, o.options.easing, function() {
45                        if(mode == 'hide') el.hide(); // Hide
46                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
47                        if(o.callback) o.callback.apply(el[0], arguments); // Callback
48                        el.dequeue();
49                });
50               
51        });
52       
53};
54
55})(jQuery);
Note: See TracBrowser for help on using the repository browser.