[3103] | 1 | /* |
---|
| 2 | * jQuery UI Effects Transfer |
---|
| 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/Transfer |
---|
| 9 | * |
---|
| 10 | * Depends: |
---|
| 11 | * effects.core.js |
---|
| 12 | */ |
---|
| 13 | (function($) { |
---|
| 14 | |
---|
| 15 | $.effects.transfer = function(o) { |
---|
| 16 | |
---|
| 17 | return this.queue(function() { |
---|
| 18 | |
---|
| 19 | // Create element |
---|
| 20 | var el = $(this); |
---|
| 21 | |
---|
| 22 | // Set options |
---|
| 23 | var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode |
---|
| 24 | var target = $(o.options.to); // Find Target |
---|
| 25 | var position = el.offset(); |
---|
| 26 | var transfer = $('<div class="ui-effects-transfer"></div>').appendTo(document.body); |
---|
| 27 | if(o.options.className) transfer.addClass(o.options.className); |
---|
| 28 | |
---|
| 29 | // Set target css |
---|
| 30 | transfer.addClass(o.options.className); |
---|
| 31 | transfer.css({ |
---|
| 32 | top: position.top, |
---|
| 33 | left: position.left, |
---|
| 34 | height: el.outerHeight() - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')), |
---|
| 35 | width: el.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth')), |
---|
| 36 | position: 'absolute' |
---|
| 37 | }); |
---|
| 38 | |
---|
| 39 | // Animation |
---|
| 40 | position = target.offset(); |
---|
| 41 | animation = { |
---|
| 42 | top: position.top, |
---|
| 43 | left: position.left, |
---|
| 44 | height: target.outerHeight() - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')), |
---|
| 45 | width: target.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth')) |
---|
| 46 | }; |
---|
| 47 | |
---|
| 48 | // Animate |
---|
| 49 | transfer.animate(animation, o.duration, o.options.easing, function() { |
---|
| 50 | transfer.remove(); // Remove div |
---|
| 51 | if(o.callback) o.callback.apply(el[0], arguments); // Callback |
---|
| 52 | el.dequeue(); |
---|
| 53 | }); |
---|
| 54 | |
---|
| 55 | }); |
---|
| 56 | |
---|
| 57 | }; |
---|
| 58 | |
---|
| 59 | })(jQuery); |
---|