diff options
author | mattpiwik <matthieu.aubry@gmail.com> | 2009-02-11 03:05:26 +0300 |
---|---|---|
committer | mattpiwik <matthieu.aubry@gmail.com> | 2009-02-11 03:05:26 +0300 |
commit | bdd6990ea601273f1f46c763479f1a0c4a13bc74 (patch) | |
tree | a1a06d947cddddf68d32785e6053a439838b8bd8 /libs/jquery/superfish_modified.js | |
parent | f3ee0a6589fbcfbae33caf67543d51120021c535 (diff) |
- patch from vipsoft:
Summary of changes:
* jQuery updated from 1.2.2 to 1.2.6
* swfobject updated from 1.5 to 2.1
* sparkline updated from upstream cvs
* fdd2div fixed to work with jQuery 1.2.6, and yuicompress'd
* tooltip updated from 1.1 to 1.3
* superfish updated from 1.4.1 to 1.4.8, and yuicompress'd
* blockUI updated from 1.33 to 2.11
* dimensions updated from 1.1.2 to 1.2
* scrollTo updated from 1.3 to 1.4
Files added:
* libs/jquery/original\ lib/fdd2div-modified.js
* libs/jquery/original\ lib/superfish_modified.js
* libs/sparkline/LICENSE-BSD.txt
* libs/sparkline/LICENSE-GPL.txt
* libs/swfobject/expressInstall.swf
Files removed:
* libs/sparkline/LICENSE
* libs/swfobject/README.txt
No change to: ui.mouse, ui.sortable, and calendar
git-svn-id: http://dev.piwik.org/svn/trunk@886 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'libs/jquery/superfish_modified.js')
-rw-r--r-- | libs/jquery/superfish_modified.js | 201 |
1 files changed, 99 insertions, 102 deletions
diff --git a/libs/jquery/superfish_modified.js b/libs/jquery/superfish_modified.js index bae8b7eb29..d51cce4934 100644 --- a/libs/jquery/superfish_modified.js +++ b/libs/jquery/superfish_modified.js @@ -1,6 +1,7 @@ + /* - * Superfish v1.4.1 - jQuery menu widget - * Copyright (c) 2007 Joel Birch + * Superfish v1.4.8 - jQuery menu widget + * Copyright (c) 2008 Joel Birch * * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php @@ -9,141 +10,137 @@ * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt */ -(function($){ - $.superfish = {}; - $.superfish.o = []; - $.superfish.op = {}; - $.superfish.currentActiveMenu = 'init'; - $.superfish.defaults = { - hoverClass : 'sfHover', - pathClass : 'overideThisToUse', - delay : 800, - animation : {opacity:'show'}, - speed : 'normal', - oldJquery : false, /* set to true if using jQuery version below 1.2 */ - disableHI : true, /* set to true to disable hoverIntent usage */ - // callback functions: - onInit : function(){}, - onBeforeShow: function(){}, - onShow : function(){}, /* note this name changed ('onshow' to 'onShow') from version 1.4 onward */ - onHide : function(){} - }; +;(function($){ $.fn.superfish = function(op){ - var bcClass = 'sfbreadcrumb', + + var sf = $.fn.superfish, + c = sf.c, + $arrow = $(['<span class="',c.arrowClass,'"> ↓</span>'].join('')), // piwik +//begin piwik click = function(){ - //console.log('click'); - // no LI means level2 clicked - if($(this).find('ul li').size() == 0) - { - //console.log('clicked sub menu'); - - // case we clicked the submenu - $.superfish.currentActiveMenu = $(this).parents('li'); - - // case we clicked the main menu with NO submenu - if($.superfish.currentActiveMenu.size() == 0) - { - //console.log('clicked main menu with no submenu'); - $.superfish.currentActiveMenu = $(this); + var $$ = $(this); + if($$.find('ul li').size() == 0) { + sf.currentActiveMenu = $$.parents('li'); + if(sf.currentActiveMenu.size() == 0) { + sf.currentActiveMenu = $$; } + } else { + sf.currentActiveMenu = $$; } - else - { - //console.log('clicked main menu'); - $.superfish.currentActiveMenu = $(this); - } - //console.log($.superfish.currentActiveMenu.filter('.sfHover')); - //console.log($.superfish.currentActiveMenu.filter('.sfHover').html());//each(function(){ $(this).removeClass('sfHover'); }); - $.superfish.currentActiveMenu.parent().find('ul li.sfHover').removeClass('sfHover'); - //console.log('click, the main is '); console.log($.superfish.currentActiveMenu.html() ); - + sf.currentActiveMenu.parent().find('ul li.sfHover').removeClass('sfHover'); }, +//end piwik over = function(){ var $$ = $(this), menu = getMenu($$); - getOpts(menu,true); clearTimeout(menu.sfTimer); - $$.showSuperfishUl().siblings().hideSuperfishUl(); }, out = function(){ - var $$ = $(this), menu = getMenu($$); - var o = getOpts(menu,true); + var $$ = $(this), menu = getMenu($$), o = sf.op; clearTimeout(menu.sfTimer); - if (!$$.is('.'+bcClass) ) { - menu.sfTimer=setTimeout(function(){ - - // if there is an active menu (a clicked menu) - if($.superfish.currentActiveMenu != 'init') - { - //console.log('showing '); console.log($.superfish.currentActiveMenu.html()); - $.superfish.currentActiveMenu.siblings('.sfHover').removeClass('sfHover'); - $.superfish.currentActiveMenu.showSuperfishUl().siblings().hideSuperfishUl(); - } - else - { - $$.hideSuperfishUl(); - } - - //console.log($.superfish.currentActiveMenu); - if (o.$path.length){over.call(o.$path);} - },o.delay); - } + menu.sfTimer=setTimeout(function(){ + o.retainPath=($.inArray($$[0],o.$path)>-1); +//begin piwik + if(sf.currentActiveMenu != 'init') { + sf.currentActiveMenu.siblings('.sfHover').removeClass('sfHover'); + sf.currentActiveMenu.showSuperfishUl().siblings().hideSuperfishUl(); + } else { +//end piwik + $$.hideSuperfishUl(); +//begin piwik + } +//end piwik + if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);} + },o.delay); }, - getMenu = function($el){ return $el.parents('ul.superfish:first')[0]; }, - getOpts = function(el,menuFound){ el = menuFound ? el : getMenu(el); return $.superfish.op = $.superfish.o[el.serial]; }, - hasUl = function(){ return $.superfish.op.oldJquery ? 'li[ul]' : 'li:has(ul)'; }; - + getMenu = function($menu){ + var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0]; + sf.op = sf.o[menu.serial]; + return menu; + }, + addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); }; + return this.each(function() { - var s = this.serial = $.superfish.o.length; - var o = $.extend({},$.superfish.defaults,op); - o.$path = $('li.'+o.pathClass,this).each(function(){ - $(this).addClass(o.hoverClass+' '+bcClass) - .filter(hasUl()).removeClass(o.pathClass); + var s = this.serial = sf.o.length; + var o = $.extend({},sf.defaults,op); + o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){ + $(this).addClass([o.hoverClass,c.bcClass].join(' ')) + .filter('li:has(ul)').removeClass(o.pathClass); }); - $.superfish.o[s] = $.superfish.op = o; - - $('li',this).click(click); - - $(hasUl(),this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out) - - .not('.'+bcClass) - .hideSuperfishUl() - ; - + sf.o[s] = sf.op = o; + $('li',this).click(click); //piwik + $('li:has(ul li)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() { + if (o.autoArrows) addArrow( $('>a:first-child',this) ); + }) + .not('.'+c.bcClass) + .hideSuperfishUl(); var $a = $('a',this); $a.each(function(i){ var $li = $a.eq(i).parents('li'); $a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);}); }); - o.onInit.call(this); - }).addClass('superfish'); + }).each(function() { + menuClasses = [c.menuClass]; + if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass); + $(this).addClass(menuClasses.join(' ')); + }); + }; + + var sf = $.fn.superfish; + sf.o = []; + sf.op = {}; + sf.currentActiveMenu = 'init'; // piwik + sf.IE7fix = function(){ + var o = sf.op; + if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined) + this.toggleClass(sf.c.shadowClass+'-off'); + }; + sf.c = { + bcClass : 'sf-breadcrumb', + menuClass : 'sf-js-enabled', + anchorClass : 'sf-with-ul', + arrowClass : 'sf-sub-indicator', + shadowClass : 'sf-shadow' + }; + sf.defaults = { + hoverClass : 'sfHover', + pathClass : 'overideThisToUse', + pathLevels : 1, + delay : 800, + animation : {opacity:'show'}, + speed : 'normal', + autoArrows : true, + dropShadows : true, + disableHI : false, // true disables hoverIntent detection + onInit : function(){}, // callback functions + onBeforeShow: function(){}, + onShow : function(){}, + onHide : function(){} }; - $.fn.extend({ hideSuperfishUl : function(){ - var o = $.superfish.op, - $ul = $('li.'+o.hoverClass,this).add(this) + var o = sf.op, + not = (o.retainPath===true) ? o.$path : ''; + o.retainPath = false; +// var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass) + var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not) // piwik .find('>ul').hide().css('visibility','hidden'); o.onHide.call($ul); return this; }, showSuperfishUl : function(){ - var o = $.superfish.op, + var o = sf.op, + sh = sf.c.shadowClass+'-off', $ul = this.addClass(o.hoverClass) .find('>ul:hidden').css('visibility','visible'); - //console.log(this.html()); + sf.IE7fix.call($ul); o.onBeforeShow.call($ul); - $ul.animate(o.animation,o.speed,function(){ o.onShow.call(this); }); + $ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); }); return this; } }); - - $(window).unload(function(){ - $('ul.superfish').each(function(){ - $('li',this).unbind('mouseover','mouseout','mouseenter','mouseleave'); - }); - }); + })(jQuery); |