source: extensions/iPiwigo/www/extensions/jqt.floaty.js @ 9188

Last change on this file since 9188 was 9188, checked in by Polly, 13 years ago

Adding the Phonegap www folder needed to compile.

  • Property svn:executable set to *
File size: 3.3 KB
Line 
1/*
2
3            _/    _/_/    _/_/_/_/_/                              _/       
4               _/    _/      _/      _/_/    _/    _/    _/_/_/  _/_/_/   
5          _/  _/  _/_/      _/    _/    _/  _/    _/  _/        _/    _/   
6         _/  _/    _/      _/    _/    _/  _/    _/  _/        _/    _/   
7        _/    _/_/  _/    _/      _/_/      _/_/_/    _/_/_/  _/    _/     
8       _/                                                                 
9    _/
10
11    Created by David Kaneda <http://www.davidkaneda.com>
12    Documentation and issue tracking on Google Code <http://code.google.com/p/jqtouch/>
13   
14    Special thanks to Jonathan Stark <http://jonathanstark.com/>
15    and pinch/zoom <http://www.pinchzoom.com/>
16   
17    (c) 2009 by jQTouch project members.
18    See LICENSE.txt for license.
19
20*/
21
22(function($) {
23    if ($.jQTouch)
24    {
25        $.jQTouch.addExtension(function Floaty(jQT){
26           
27            $.fn.makeFloaty = function(options){
28                var defaults = {
29                    align: 'top',
30                    spacing: 20,
31                    time: '.3s'
32                }
33                var settings = $.extend({}, defaults, options);
34                settings.align = (settings.align == 'top') ? 'top' : 'bottom';
35               
36                return this.each(function(){
37                    var $el = $(this);
38                   
39                    $el.css({
40                        '-webkit-transition': 'top ' + settings.time + ' ease-in-out',
41                        'display': 'block',
42                        'min-height': '0 !important'
43                    }).data('settings', settings);
44                   
45                    $(document).bind('scroll', function(){
46                        if ($el.data('floatyVisible') === true)
47                        {
48                            $el.scrollFloaty();
49                        }
50                    });
51                    $el.scrollFloaty();
52                });
53            }
54
55            $.fn.scrollFloaty = function(){
56                return this.each(function(){
57                    var $el = $(this);
58                    var settings = $el.data('settings');
59                    var wHeight = $('html').attr('clientHeight'); // WRONG
60                   
61                    var newY = window.pageYOffset +
62                        ((settings.align == 'top') ? 
63                            settings.spacing : wHeight - settings.spacing - $el.get(0).offsetHeight);
64                   
65                    $el.css('top', newY).data('floatyVisible', true);
66                });
67            }
68
69            $.fn.hideFloaty = function(){
70                return this.each(function(){
71                    var $el = $(this);
72                    var oh = $el.get(0).offsetHeight;
73                   
74                    $el.css('top', -oh-10).data('floatyVisible', false);
75                });
76            }
77           
78            $.fn.toggleFloaty = function(){
79                return this.each(function(){
80                    var $el = $(this);
81                    if ($el.data('floatyVisible') === true){
82                        $el.hideFloaty();
83                    }
84                    else
85                    {
86                        $el.scrollFloaty();
87                    }
88                });
89            }
90        });
91    }
92})(jQuery);
Note: See TracBrowser for help on using the repository browser.