Projet

Général

Profil

Paste
Télécharger (4,06 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / danland / scripts / superfish.js @ 87dbc3bf

1
// $Id: superfish.js,v 1.1.4.1 2010/11/11 13:58:25 danprobo Exp $
2
/*
3
 * Superfish v1.4.8 - jQuery menu widget
4
 * Copyright (c) 2008 Joel Birch
5
 *
6
 * Dual licensed under the MIT and GPL licenses:
7
 *         http://www.opensource.org/licenses/mit-license.php
8
 *         http://www.gnu.org/licenses/gpl.html
9
 *
10
 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
11
 */
12

    
13
 jQuery(document).ready(function($) {
14
    $("#superfish ul.menu").superfish({ 
15
            delay:       100,                           
16
            animation:   {opacity:'show',height:'show'},  
17
            speed:       'fast',                          
18
            autoArrows:  true,                           
19
            dropShadows: true                   
20
        });
21
  });
22

    
23
;(function($){
24
        $.fn.superfish = function(op){
25

    
26
                var sf = $.fn.superfish,
27
                        c = sf.c,
28
                        $arrow = $(['<span class="',c.arrowClass,'"> &#187;</span>'].join('')),
29
                        over = function(){
30
                                var $$ = $(this), menu = getMenu($$);
31
                                clearTimeout(menu.sfTimer);
32
                                $$.showSuperfishUl().siblings().hideSuperfishUl();
33
                        },
34
                        out = function(){
35
                                var $$ = $(this), menu = getMenu($$), o = sf.op;
36
                                clearTimeout(menu.sfTimer);
37
                                menu.sfTimer=setTimeout(function(){
38
                                        o.retainPath=($.inArray($$[0],o.$path)>-1);
39
                                        $$.hideSuperfishUl();
40
                                        if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
41
                                },o.delay);        
42
                        },
43
                        getMenu = function($menu){
44
                                var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
45
                                sf.op = sf.o[menu.serial];
46
                                return menu;
47
                        },
48
                        addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
49
                        
50
                return this.each(function() {
51
                        var s = this.serial = sf.o.length;
52
                        var o = $.extend({},sf.defaults,op);
53
                        o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
54
                                $(this).addClass([o.hoverClass,c.bcClass].join(' '))
55
                                        .filter('li:has(ul)').removeClass(o.pathClass);
56
                        });
57
                        sf.o[s] = sf.op = o;
58
                        
59
                        $('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
60
                                if (o.autoArrows) addArrow( $('>a:first-child',this) );
61
                        })
62
                        .not('.'+c.bcClass)
63
                                .hideSuperfishUl();
64
                        
65
                        var $a = $('a',this);
66
                        $a.each(function(i){
67
                                var $li = $a.eq(i).parents('li');
68
                                $a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
69
                        });
70
                        o.onInit.call(this);
71
                        
72
                }).each(function() {
73
                        var menuClasses = [c.menuClass];
74
                        if (sf.op.dropShadows  && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
75
                        $(this).addClass(menuClasses.join(' '));
76
                });
77
        };
78

    
79
        var sf = $.fn.superfish;
80
        sf.o = [];
81
        sf.op = {};
82
        sf.IE7fix = function(){
83
                var o = sf.op;
84
                if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
85
                        this.toggleClass(sf.c.shadowClass+'-off');
86
                };
87
        sf.c = {
88
                bcClass     : 'sf-breadcrumb',
89
                menuClass   : 'sf-js-enabled',
90
                anchorClass : 'sf-with-ul',
91
                arrowClass  : 'sf-sub-indicator',
92
                shadowClass : 'sf-shadow'
93
        };
94
        sf.defaults = {
95
                hoverClass        : 'sfHover',
96
                pathClass        : 'overideThisToUse',
97
                pathLevels        : 1,
98
                delay                : 800,
99
                animation        : {opacity:'show'},
100
                speed                : 'normal',
101
                autoArrows        : true,
102
                dropShadows : true,
103
                disableHI        : false,                // true disables hoverIntent detection
104
                onInit                : function(){}, // callback functions
105
                onBeforeShow: function(){},
106
                onShow                : function(){},
107
                onHide                : function(){}
108
        };
109
        $.fn.extend({
110
                hideSuperfishUl : function(){
111
                        var o = sf.op,
112
                                not = (o.retainPath===true) ? o.$path : '';
113
                        o.retainPath = false;
114
                        var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
115
                                        .find('>ul').hide().css('visibility','hidden');
116
                        o.onHide.call($ul);
117
                        return this;
118
                },
119
                showSuperfishUl : function(){
120
                        var o = sf.op,
121
                                sh = sf.c.shadowClass+'-off',
122
                                $ul = this.addClass(o.hoverClass)
123
                                        .find('>ul:hidden').css('visibility','visible');
124
                        sf.IE7fix.call($ul);
125
                        o.onBeforeShow.call($ul);
126
                        $ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
127
                        return this;
128
                }
129
        });
130

    
131
})(jQuery);