-;(function($) {\r
- \r
- $.effects.puff = function(o) {\r
- \r
- return this.queue(function() {\r
- \r
- // Create element\r
- var el = $(this);\r
- \r
- // Set options\r
- var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode\r
- var percent = parseInt(o.options.percent) || 150; // Set default puff percent\r
- o.options.fade = true; // It's not a puff if it doesn't fade! :)\r
- var original = {height: el.height(), width: el.width()}; // Save original\r
- \r
- // Adjust\r
- var factor = percent / 100;\r
- el.from = (mode == 'hide') ? original : {height: original.height * factor, width: original.width * factor};\r
- \r
- // Animation\r
- o.options.from = el.from;\r
- o.options.percent = (mode == 'hide') ? percent : 100;\r
- o.options.mode = mode;\r
- \r
- // Animate\r
- el.effect('scale', o.options, o.duration, o.callback);\r
- el.dequeue();\r
- });\r
- \r
- };\r
-\r
- $.effects.scale = function(o) {\r
- \r
- return this.queue(function() {\r
- \r
- // Create element\r
- var el = $(this);\r
-\r
- // Set options\r
- var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode\r
- var percent = parseInt(o.options.percent) || (parseInt(o.options.percent) == 0 ? 0 : (mode == 'hide' ? 0 : 100)); // Set default scaling percent\r
- var direction = o.options.direction || 'both'; // Set default axis\r
- var origin = o.options.origin; // The origin of the scaling\r
- if (mode != 'effect') { // Set default origin and restore for show/hide\r
- origin = origin || ['middle','center'];\r
- o.options.restore = true;\r
- }\r
- var original = {height: el.height(), width: el.width()}; // Save original\r
- el.from = o.options.from || (mode == 'show' ? {height: 0, width: 0} : original); // Default from state\r
- \r
- // Adjust\r
- var factor = { // Set scaling factor\r
- y: direction != 'horizontal' ? (percent / 100) : 1,\r
- x: direction != 'vertical' ? (percent / 100) : 1\r
- };\r
- el.to = {height: original.height * factor.y, width: original.width * factor.x}; // Set to state\r
- if (origin) { // Calculate baseline shifts\r
- var baseline = $.effects.getBaseline(origin, original);\r
- el.from.top = (original.height - el.from.height) * baseline.y;\r
- el.from.left = (original.width - el.from.width) * baseline.x;\r
- el.to.top = (original.height - el.to.height) * baseline.y;\r
- el.to.left = (original.width - el.to.width) * baseline.x;\r
- };\r
- if (o.options.fade) { // Fade option to support puff\r
- if (mode == 'show') {el.from.opacity = 0; el.to.opacity = 1;};\r
- if (mode == 'hide') {el.from.opacity = 1; el.to.opacity = 0;};\r
- };\r
- \r
- // Animation\r
- o.options.from = el.from; o.options.to = el.to;\r
- \r
- // Animate\r
- el.effect('size', o.options, o.duration, o.callback);\r
- el.dequeue();\r
- });\r
- \r
- };\r
- \r
- $.effects.size = function(o) {\r
-\r
- return this.queue(function() {\r
- \r
- // Create element\r
- var el = $(this), props = ['position','top','left','width','height','overflow','opacity'];\r
- var props1 = ['position','overflow','opacity']; // Always restore\r
- var props2 = ['width','height','overflow']; // Copy for children\r
- var cProps = ['fontSize'];\r
- var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom'];\r
- var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight'];\r
- \r
- // Set options\r
- var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode\r
- var restore = o.options.restore || false; // Default restore\r
- var scale = o.options.scale || 'both'; // Default scale mode\r
- var original = {height: el.height(), width: el.width()}; // Save original\r
- el.from = o.options.from || original; // Default from state\r
- el.to = o.options.to || original; // Default to state\r
- \r
- // Adjust\r
- var factor = { // Set scaling factor\r
- from: {y: el.from.height / original.height, x: el.from.width / original.width},\r
- to: {y: el.to.height / original.height, x: el.to.width / original.width}\r
- };\r
- if (scale == 'box' || scale == 'both') { // Scale the css box\r
- if (factor.from.y != factor.to.y) { // Vertical props scaling\r
- props = props.concat(vProps);\r
- el.from = $.effects.setTransition(el, vProps, factor.from.y, el.from);\r
- el.to = $.effects.setTransition(el, vProps, factor.to.y, el.to);\r
- };\r
- if (factor.from.x != factor.to.x) { // Horizontal props scaling\r
- props = props.concat(hProps);\r
- el.from = $.effects.setTransition(el, hProps, factor.from.x, el.from);\r
- el.to = $.effects.setTransition(el, hProps, factor.to.x, el.to);\r
- };\r
- };\r
- if (scale == 'content' || scale == 'both') { // Scale the content\r
- if (factor.from.y != factor.to.y) { // Vertical props scaling\r
- props = props.concat(cProps);\r
- el.from = $.effects.setTransition(el, cProps, factor.from.y, el.from);\r
- el.to = $.effects.setTransition(el, cProps, factor.to.y, el.to);\r
- };\r
- };\r
- $.effects.save(el, restore ? props : props1); el.show(); // Save & Show\r
- $.effects.createWrapper(el); // Create Wrapper\r
- el.css('overflow','hidden').css(el.from); // Shift\r
- \r
- // Animate\r
- if (scale == 'content' || scale == 'both') { // Scale the children\r
- vProps = vProps.concat(['marginTop','marginBottom']).concat(cProps); // Add margins/font-size\r
- hProps = hProps.concat(['marginLeft','marginRight']); // Add margins\r
- props2 = props.concat(vProps).concat(hProps); // Concat\r
- el.find("*[width]").each(function(){\r
- child = $(this);\r
- if (restore) $.effects.save(child, props2);\r
- var c_original = {height: child.height(), width: child.width()}; // Save original\r
- child.from = {height: c_original.height * factor.from.y, width: c_original.width * factor.from.x};\r
- child.to = {height: c_original.height * factor.to.y, width: c_original.width * factor.to.x};\r
- if (factor.from.y != factor.to.y) { // Vertical props scaling\r
- child.from = $.effects.setTransition(child, vProps, factor.from.y, child.from);\r
- child.to = $.effects.setTransition(child, vProps, factor.to.y, child.to);\r
- };\r
- if (factor.from.x != factor.to.x) { // Horizontal props scaling\r
- child.from = $.effects.setTransition(child, hProps, factor.from.x, child.from);\r
- child.to = $.effects.setTransition(child, hProps, factor.to.x, child.to);\r
- };\r
- child.css(child.from); // Shift children\r
- child.animate(child.to, o.duration, o.options.easing, function(){\r
- if (restore) $.effects.restore(child, props2); // Restore children\r
- }); // Animate children\r
- });\r
- };\r
- \r
- // Animate\r
- el.animate(el.to, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {\r
- if(mode == 'hide') el.hide(); // Hide\r
- $.effects.restore(el, restore ? props : props1); $.effects.removeWrapper(el); // Restore\r
- if(o.callback) o.callback.apply(this, arguments); // Callback\r
- el.dequeue();\r
- }}); \r
- \r
- });\r
-\r
- };\r
- \r
+;(function($) {
+
+ $.effects.puff = function(o) {
+
+ return this.queue(function() {
+
+ // Create element
+ var el = $(this);
+
+ // Set options
+ var options = $.extend(true, {}, o);
+ var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
+ var percent = parseInt(o.options.percent) || 150; // Set default puff percent
+ options.fade = true; // It's not a puff if it doesn't fade! :)
+ var original = {height: el.height(), width: el.width()}; // Save original
+
+ // Adjust
+ var factor = percent / 100;
+ el.from = (mode == 'hide') ? original : {height: original.height * factor, width: original.width * factor};
+
+ // Animation
+ options.from = el.from;
+ options.percent = (mode == 'hide') ? percent : 100;
+ options.mode = mode;
+
+ // Animate
+ el.effect('scale', options, o.duration, o.callback);
+ el.dequeue();
+ });
+
+ };
+
+ $.effects.scale = function(o) {
+
+ return this.queue(function() {
+
+ // Create element
+ var el = $(this);
+
+ // Set options
+ var options = $.extend(true, {}, o);
+ var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
+ var percent = parseInt(o.options.percent) || (parseInt(o.options.percent) == 0 ? 0 : (mode == 'hide' ? 0 : 100)); // Set default scaling percent
+ var direction = o.options.direction || 'both'; // Set default axis
+ var origin = o.options.origin; // The origin of the scaling
+ if (mode != 'effect') { // Set default origin and restore for show/hide
+ origin = origin || ['middle','center'];
+ options.restore = true;
+ }
+ var original = {height: el.height(), width: el.width()}; // Save original
+ el.from = o.options.from || (mode == 'show' ? {height: 0, width: 0} : original); // Default from state
+
+ // Adjust
+ var factor = { // Set scaling factor
+ y: direction != 'horizontal' ? (percent / 100) : 1,
+ x: direction != 'vertical' ? (percent / 100) : 1
+ };
+ el.to = {height: original.height * factor.y, width: original.width * factor.x}; // Set to state
+ if (origin) { // Calculate baseline shifts
+ var baseline = $.effects.getBaseline(origin, original);
+ el.from.top = (original.height - el.from.height) * baseline.y;
+ el.from.left = (original.width - el.from.width) * baseline.x;
+ el.to.top = (original.height - el.to.height) * baseline.y;
+ el.to.left = (original.width - el.to.width) * baseline.x;
+ };
+ if (o.options.fade) { // Fade option to support puff
+ if (mode == 'show') {el.from.opacity = 0; el.to.opacity = 1;};
+ if (mode == 'hide') {el.from.opacity = 1; el.to.opacity = 0;};
+ };
+
+ // Animation
+ options.from = el.from; options.to = el.to; options.mode = mode;
+
+ // Animate
+ el.effect('size', options, o.duration, o.callback);
+ el.dequeue();
+ });
+
+ };
+
+ $.effects.size = function(o) {
+
+ return this.queue(function() {
+
+ // Create element
+ var el = $(this), props = ['position','top','left','width','height','overflow','opacity'];
+ var props1 = ['position','overflow','opacity']; // Always restore
+ var props2 = ['width','height','overflow']; // Copy for children
+ var cProps = ['fontSize'];
+ var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom'];
+ var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight'];
+
+ // Set options
+ var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
+ var restore = o.options.restore || false; // Default restore
+ var scale = o.options.scale || 'both'; // Default scale mode
+ var original = {height: el.height(), width: el.width()}; // Save original
+ el.from = o.options.from || original; // Default from state
+ el.to = o.options.to || original; // Default to state
+
+ // Adjust
+ var factor = { // Set scaling factor
+ from: {y: el.from.height / original.height, x: el.from.width / original.width},
+ to: {y: el.to.height / original.height, x: el.to.width / original.width}
+ };
+ if (scale == 'box' || scale == 'both') { // Scale the css box
+ if (factor.from.y != factor.to.y) { // Vertical props scaling
+ props = props.concat(vProps);
+ el.from = $.effects.setTransition(el, vProps, factor.from.y, el.from);
+ el.to = $.effects.setTransition(el, vProps, factor.to.y, el.to);
+ };
+ if (factor.from.x != factor.to.x) { // Horizontal props scaling
+ props = props.concat(hProps);
+ el.from = $.effects.setTransition(el, hProps, factor.from.x, el.from);
+ el.to = $.effects.setTransition(el, hProps, factor.to.x, el.to);
+ };
+ };
+ if (scale == 'content' || scale == 'both') { // Scale the content
+ if (factor.from.y != factor.to.y) { // Vertical props scaling
+ props = props.concat(cProps);
+ el.from = $.effects.setTransition(el, cProps, factor.from.y, el.from);
+ el.to = $.effects.setTransition(el, cProps, factor.to.y, el.to);
+ };
+ };
+ $.effects.save(el, restore ? props : props1); el.show(); // Save & Show
+ $.effects.createWrapper(el); // Create Wrapper
+ el.css('overflow','hidden').css(el.from); // Shift
+
+ // Animate
+ if (scale == 'content' || scale == 'both') { // Scale the children
+ vProps = vProps.concat(['marginTop','marginBottom']).concat(cProps); // Add margins/font-size
+ hProps = hProps.concat(['marginLeft','marginRight']); // Add margins
+ props2 = props.concat(vProps).concat(hProps); // Concat
+ el.find("*[width]").each(function(){
+ child = $(this);
+ if (restore) $.effects.save(child, props2);
+ var c_original = {height: child.height(), width: child.width()}; // Save original
+ child.from = {height: c_original.height * factor.from.y, width: c_original.width * factor.from.x};
+ child.to = {height: c_original.height * factor.to.y, width: c_original.width * factor.to.x};
+ if (factor.from.y != factor.to.y) { // Vertical props scaling
+ child.from = $.effects.setTransition(child, vProps, factor.from.y, child.from);
+ child.to = $.effects.setTransition(child, vProps, factor.to.y, child.to);
+ };
+ if (factor.from.x != factor.to.x) { // Horizontal props scaling
+ child.from = $.effects.setTransition(child, hProps, factor.from.x, child.from);
+ child.to = $.effects.setTransition(child, hProps, factor.to.x, child.to);
+ };
+ child.css(child.from); // Shift children
+ child.animate(child.to, o.duration, o.options.easing, function(){
+ if (restore) $.effects.restore(child, props2); // Restore children
+ }); // Animate children
+ });
+ };
+
+ // Animate
+ el.animate(el.to, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
+ if(mode == 'hide') el.hide(); // Hide
+ $.effects.restore(el, restore ? props : props1); $.effects.removeWrapper(el); // Restore
+ if(o.callback) o.callback.apply(this, arguments); // Callback
+ el.dequeue();
+ }});
+
+ });
+
+ };
+
})(jQuery);
\ No newline at end of file