2008-06-06 20:08:52 +00:00
|
|
|
/*
|
2008-09-04 22:03:30 +00:00
|
|
|
* jQuery UI Effects Fold @VERSION
|
2008-06-06 20:08:52 +00:00
|
|
|
*
|
2009-01-03 21:55:13 +00:00
|
|
|
* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
|
2008-06-06 20:08:52 +00:00
|
|
|
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
|
|
|
* and GPL (GPL-LICENSE.txt) licenses.
|
2008-11-20 04:10:34 +00:00
|
|
|
*
|
2008-06-06 20:08:52 +00:00
|
|
|
* http://docs.jquery.com/UI/Effects/Fold
|
|
|
|
*
|
|
|
|
* Depends:
|
|
|
|
* effects.core.js
|
|
|
|
*/
|
|
|
|
(function($) {
|
2008-05-23 09:26:18 +00:00
|
|
|
|
2008-06-06 19:47:31 +00:00
|
|
|
$.effects.fold = function(o) {
|
2008-05-23 09:26:18 +00:00
|
|
|
|
2008-06-06 19:47:31 +00:00
|
|
|
return this.queue(function() {
|
|
|
|
|
|
|
|
// Create element
|
|
|
|
var el = $(this), props = ['position','top','left'];
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-06 19:47:31 +00:00
|
|
|
// Set options
|
|
|
|
var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
|
|
|
|
var size = o.options.size || 15; // Default fold size
|
2008-06-16 10:20:41 +00:00
|
|
|
var horizFirst = !(!o.options.horizFirst); // Ensure a boolean value
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-06 19:47:31 +00:00
|
|
|
// Adjust
|
|
|
|
$.effects.save(el, props); el.show(); // Save & Show
|
|
|
|
var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
|
2008-06-16 10:20:41 +00:00
|
|
|
var widthFirst = ((mode == 'show') != horizFirst);
|
|
|
|
var ref = widthFirst ? ['width', 'height'] : ['height', 'width'];
|
|
|
|
var distance = widthFirst ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()];
|
|
|
|
var percent = /([0-9]+)%/.exec(size);
|
|
|
|
if(percent) size = parseInt(percent[1]) / 100 * distance[mode == 'hide' ? 0 : 1];
|
|
|
|
if(mode == 'show') wrapper.css(horizFirst ? {height: 0, width: size} : {height: size, width: 0}); // Shift
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-06 19:47:31 +00:00
|
|
|
// Animation
|
|
|
|
var animation1 = {}, animation2 = {};
|
|
|
|
animation1[ref[0]] = mode == 'show' ? distance[0] : size;
|
|
|
|
animation2[ref[1]] = mode == 'show' ? distance[1] : 0;
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-06 19:47:31 +00:00
|
|
|
// Animate
|
|
|
|
wrapper.animate(animation1, o.duration / 2, o.options.easing)
|
|
|
|
.animate(animation2, o.duration / 2, o.options.easing, function() {
|
|
|
|
if(mode == 'hide') el.hide(); // Hide
|
|
|
|
$.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
|
|
|
|
if(o.callback) o.callback.apply(el[0], arguments); // Callback
|
|
|
|
el.dequeue();
|
|
|
|
});
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-06 19:47:31 +00:00
|
|
|
});
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-06-06 19:47:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
})(jQuery);
|