2013-08-15 18:15:49 +00:00
|
|
|
define([
|
|
|
|
"../core"
|
|
|
|
], function( jQuery ) {
|
|
|
|
|
2013-09-09 15:39:02 +00:00
|
|
|
// A method for quickly swapping in/out CSS properties to get correct calculations.
|
|
|
|
jQuery.swap = function( elem, options, callback, args ) {
|
|
|
|
var ret, name,
|
|
|
|
old = {};
|
2013-08-15 18:15:49 +00:00
|
|
|
|
2013-09-09 15:39:02 +00:00
|
|
|
// Remember the old values, and insert the new ones
|
|
|
|
for ( name in options ) {
|
|
|
|
old[ name ] = elem.style[ name ];
|
|
|
|
elem.style[ name ] = options[ name ];
|
|
|
|
}
|
2013-08-15 18:15:49 +00:00
|
|
|
|
2013-09-09 15:39:02 +00:00
|
|
|
ret = callback.apply( elem, args || [] );
|
2013-08-15 18:15:49 +00:00
|
|
|
|
2013-09-09 15:39:02 +00:00
|
|
|
// Revert the old values
|
|
|
|
for ( name in options ) {
|
|
|
|
elem.style[ name ] = old[ name ];
|
|
|
|
}
|
2013-08-15 18:15:49 +00:00
|
|
|
|
2013-09-09 15:39:02 +00:00
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
|
|
|
return jQuery.swap;
|
2013-08-15 18:15:49 +00:00
|
|
|
|
|
|
|
});
|