/[drupal]/contributions/modules/simplemenu/superfish.js
ViewVC logotype

Contents of /contributions/modules/simplemenu/superfish.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Fri Dec 12 06:24:18 2008 UTC (11 months, 2 weeks ago) by rz
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--2
Changes since 1.1: +100 -0 lines
File MIME type: text/javascript
merging DRUPAL-6--1 into HEAD
1 /*
2 * Superfish v1.4.1 - jQuery menu widget
3 * Copyright (c) 2008 Joel Birch
4 *
5 * Dual licensed under the MIT and GPL licenses:
6 * http://www.opensource.org/licenses/mit-license.php
7 * http://www.gnu.org/licenses/gpl.html
8 *
9 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
10 */
11
12 (function($){
13 $.superfish = {};
14 $.superfish.o = [];
15 $.superfish.op = {};
16 $.superfish.defaults = {
17 hoverClass : 'sfHover',
18 pathClass : 'overideThisToUse',
19 delay : 800,
20 animation : {opacity:'show'},
21 speed : 'normal',
22 oldJquery : false, /* set to true if using jQuery version below 1.2 */
23 disableHI : false, /* set to true to disable hoverIntent usage */
24 // callback functions:
25 onInit : function(){},
26 onBeforeShow: function(){},
27 onShow : function(){}, /* note this name changed ('onshow' to 'onShow') from version 1.4 onward */
28 onHide : function(){}
29 };
30 $.fn.superfish = function(op){
31 var bcClass = 'sfbreadcrumb',
32 over = function(){
33 var $$ = $(this), menu = getMenu($$);
34 getOpts(menu,true);
35 clearTimeout(menu.sfTimer);
36 $$.showSuperfishUl().siblings().hideSuperfishUl();
37 },
38 out = function(){
39 var $$ = $(this), menu = getMenu($$);
40 var o = getOpts(menu,true);
41 clearTimeout(menu.sfTimer);
42 if ( !$$.is('.'+bcClass) ) {
43 menu.sfTimer=setTimeout(function(){
44 $$.hideSuperfishUl();
45 if (o.$path.length){over.call(o.$path);}
46 },o.delay);
47 }
48 },
49 getMenu = function($el){ return $el.parents('ul.superfish:first')[0]; },
50 getOpts = function(el,menuFound){ el = menuFound ? el : getMenu(el); return $.superfish.op = $.superfish.o[el.serial]; },
51 hasUl = function(){ return $.superfish.op.oldJquery ? 'li[ul]' : 'li:has(ul)'; };
52
53 return this.each(function() {
54 var s = this.serial = $.superfish.o.length;
55 var o = $.extend({},$.superfish.defaults,op);
56 o.$path = $('li.'+o.pathClass,this).each(function(){
57 $(this).addClass(o.hoverClass+' '+bcClass)
58 .filter(hasUl()).removeClass(o.pathClass);
59 });
60 $.superfish.o[s] = $.superfish.op = o;
61
62 $(hasUl(),this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out)
63 .not('.'+bcClass)
64 .hideSuperfishUl();
65
66 var $a = $('a',this);
67 $a.each(function(i){
68 var $li = $a.eq(i).parents('li');
69 $a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
70 });
71
72 o.onInit.call(this);
73
74 }).addClass('superfish');
75 };
76
77 $.fn.extend({
78 hideSuperfishUl : function(){
79 var o = $.superfish.op,
80 $ul = $('li.'+o.hoverClass,this).add(this).removeClass(o.hoverClass)
81 .find('>ul').hide().css('visibility','hidden');
82 o.onHide.call($ul);
83 return this;
84 },
85 showSuperfishUl : function(){
86 var o = $.superfish.op,
87 $ul = this.addClass(o.hoverClass)
88 .find('>ul:hidden').css('visibility','visible');
89 o.onBeforeShow.call($ul);
90 $ul.animate(o.animation,o.speed,function(){ o.onShow.call(this); });
91 return this;
92 }
93 });
94
95 $(window).unload(function(){
96 $('ul.superfish').each(function(){
97 $('li',this).unbind('mouseover','mouseout','mouseenter','mouseleave');
98 });
99 });
100 })(jQuery);

  ViewVC Help
Powered by ViewVC 1.1.2