2012-02-27 00:49:51 +00:00
|
|
|
/*!
|
2008-09-04 22:03:30 +00:00
|
|
|
* jQuery UI Effects Scale @VERSION
|
2012-07-04 13:08:08 +00:00
|
|
|
* http://jqueryui.com
|
2008-06-06 20:08:52 +00:00
|
|
|
*
|
2014-12-21 18:27:43 +00:00
|
|
|
* Copyright jQuery Foundation and other contributors
|
2012-08-09 14:13:24 +00:00
|
|
|
* Released under the MIT license.
|
2010-07-09 13:01:04 +00:00
|
|
|
* http://jquery.org/license
|
2008-11-20 04:10:34 +00:00
|
|
|
*
|
2012-09-26 23:06:20 +00:00
|
|
|
* http://api.jqueryui.com/scale-effect/
|
2008-06-06 20:08:52 +00:00
|
|
|
*/
|
2013-07-12 16:40:48 +00:00
|
|
|
(function( factory ) {
|
|
|
|
if ( typeof define === "function" && define.amd ) {
|
2008-06-06 19:47:31 +00:00
|
|
|
|
2013-07-12 16:40:48 +00:00
|
|
|
// AMD. Register as an anonymous module.
|
|
|
|
define([
|
|
|
|
"jquery",
|
2013-12-02 18:36:12 +00:00
|
|
|
"./effect",
|
|
|
|
"./effect-size"
|
2013-07-12 16:40:48 +00:00
|
|
|
], factory );
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Browser globals
|
|
|
|
factory( jQuery );
|
|
|
|
}
|
|
|
|
}(function( $ ) {
|
|
|
|
|
|
|
|
return $.effects.effect.scale = function( o, done ) {
|
2011-06-21 05:23:52 +00:00
|
|
|
|
|
|
|
// Create element
|
|
|
|
var el = $( this ),
|
|
|
|
options = $.extend( true, {}, o ),
|
|
|
|
mode = $.effects.setMode( el, o.mode || "effect" ),
|
2012-04-02 23:12:21 +00:00
|
|
|
percent = parseInt( o.percent, 10 ) ||
|
|
|
|
( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
|
2011-06-21 05:23:52 +00:00
|
|
|
direction = o.direction || "both",
|
|
|
|
origin = o.origin,
|
2012-04-19 01:57:51 +00:00
|
|
|
original = {
|
|
|
|
height: el.height(),
|
2011-05-20 01:25:34 +00:00
|
|
|
width: el.width(),
|
|
|
|
outerHeight: el.outerHeight(),
|
|
|
|
outerWidth: el.outerWidth()
|
2011-06-21 05:23:52 +00:00
|
|
|
},
|
|
|
|
factor = {
|
2012-04-02 23:12:21 +00:00
|
|
|
y: direction !== "horizontal" ? (percent / 100) : 1,
|
|
|
|
x: direction !== "vertical" ? (percent / 100) : 1
|
2012-04-19 01:57:51 +00:00
|
|
|
};
|
2011-03-07 00:34:18 +00:00
|
|
|
|
2011-06-21 05:23:52 +00:00
|
|
|
// We are going to pass this effect to the size effect:
|
|
|
|
options.effect = "size";
|
|
|
|
options.queue = false;
|
2011-06-21 06:11:46 +00:00
|
|
|
options.complete = done;
|
2011-06-21 05:23:52 +00:00
|
|
|
|
|
|
|
// Set default origin and restore for show/hide
|
2012-04-19 01:57:51 +00:00
|
|
|
if ( mode !== "effect" ) {
|
2013-10-16 18:43:09 +00:00
|
|
|
options.origin = origin || [ "middle", "center" ];
|
2011-06-21 05:23:52 +00:00
|
|
|
options.restore = true;
|
|
|
|
}
|
|
|
|
|
2012-11-22 10:12:30 +00:00
|
|
|
options.from = o.from || ( mode === "show" ? {
|
|
|
|
height: 0,
|
|
|
|
width: 0,
|
|
|
|
outerHeight: 0,
|
|
|
|
outerWidth: 0
|
|
|
|
} : original );
|
2011-06-21 05:23:52 +00:00
|
|
|
options.to = {
|
2012-04-19 01:57:51 +00:00
|
|
|
height: original.height * factor.y,
|
2011-06-21 05:23:52 +00:00
|
|
|
width: original.width * factor.x,
|
2012-04-19 01:57:51 +00:00
|
|
|
outerHeight: original.outerHeight * factor.y,
|
2011-06-21 05:23:52 +00:00
|
|
|
outerWidth: original.outerWidth * factor.x
|
2012-04-19 01:57:51 +00:00
|
|
|
};
|
2011-06-21 05:23:52 +00:00
|
|
|
|
2012-04-02 19:55:50 +00:00
|
|
|
// Fade option to support puff
|
|
|
|
if ( options.fade ) {
|
2012-04-02 23:12:21 +00:00
|
|
|
if ( mode === "show" ) {
|
2012-04-19 01:57:51 +00:00
|
|
|
options.from.opacity = 0;
|
2011-06-21 05:23:52 +00:00
|
|
|
options.to.opacity = 1;
|
|
|
|
}
|
2012-04-02 23:12:21 +00:00
|
|
|
if ( mode === "hide" ) {
|
2012-04-19 01:57:51 +00:00
|
|
|
options.from.opacity = 1;
|
2011-06-21 05:23:52 +00:00
|
|
|
options.to.opacity = 0;
|
|
|
|
}
|
2012-04-02 19:55:50 +00:00
|
|
|
}
|
2011-03-07 00:34:18 +00:00
|
|
|
|
2011-06-21 05:23:52 +00:00
|
|
|
// Animate
|
|
|
|
el.effect( options );
|
2011-03-07 00:34:18 +00:00
|
|
|
|
2011-06-21 05:23:52 +00:00
|
|
|
};
|
2011-03-07 00:34:18 +00:00
|
|
|
|
2013-07-12 16:40:48 +00:00
|
|
|
}));
|