- Javascript Superfish Jquery Menu troubleshooting
- /*
- * 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
- * http://www.gnu.org/licenses/gpl.html
- *
- * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
- */
- ;(function($){
- $.fn.superfish = function(op){
- var sf = $.fn.superfish,
- c = sf.c,
- $arrow = $(['<span class="',c.arrowClass,'"> ยป</span>'].join('')),
- over = function(){
- var $this = $(this), menu = getMenu($this);
- clearTimeout(menu.sfTimer);
- $this.showSuperfishUl().siblings().hideSuperfishUl();
- },
- out = function(){
- var $this = $(this), menu = getMenu($this), o = sf.op;
- clearTimeout(menu.sfTimer);
- menu.sfTimer=setTimeout(function(){
- o.retainPath=($.inArray($this[0],o.$path)>-1);
- $this.hideSuperfishUl();
- if (o.$path.length && $this.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
- },o.delay);
- },
- 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 $this = $(this);
- 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);
- });
- sf.o[s] = sf.op = o;
- // CHANGED: by KARL SWEDBERG
- if ( (o.eventType === 'hoverIntent' && !$.fn.hoverIntent) || !(/^(?:hover|hoverIntent|toggle)$/).test(o.eventType) ) {
- o.eventType = 'hover';
- }
- $this.find('li:has(ul)')[o.eventType](over,out).each(function() {
- if (o.autoArrows) {
- addArrow( $('>a:first-child',this) );
- // this.addClass("yourClass");
- }
- })
- .not('.'+c.bcClass)
- .hideSuperfishUl();
- $this.find('a').each(function(i){
- var $a = $(this), $li = $a.parents('li');
- $a.focus(function(){over.call($li);}).blur(function(){out.call($li);});
- $a.click(function(event) {
- event.preventDefault();
- if ( !$a.hasClass("sf-with-ul") ) {
- location.href = this.href;
- }
- });
- });
- o.onInit.call(this);
- }).each(function() {
- var 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.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 : 'current',
- pathLevels : 1,
- delay : 800,
- animation : {opacity:'show'},
- speed : 'normal',
- closeAnimation: {opacity: 'hide'},
- closeSpeed: 0,
- autoArrows : true,
- dropShadows : true,
- // CHANGED: by KARL SWEDBERG
- eventType : 'toggle', // one of 'toggle', 'hover', or 'hoverIntent'
- disableHI : false, // true disables hoverIntent detection
- onInit : function(){}, // callback functions
- onBeforeShow: function(){},
- onShow : function(){},
- onHide : function(){}
- };
- $.fn.extend({
- hideSuperfishUl : function(){
- var o = sf.op,
- not = (o.retainPath===true) ? o.$path : '';
- o.retainPath = false;
- var $closingLi = $(['li.',o.hoverClass].join(''),this).add(this).not(not);
- var $ul = $closingLi
- .find('>ul');
- $ul.animate(o.closeAnimation, o.closeSpeed, function() {
- $closingLi.removeClass(o.hoverClass);
- $ul.css('visibility','hidden');
- });
- o.onHide.call($ul);
- return this;
- },
- showSuperfishUl : function(){
- var o = sf.op,
- sh = sf.c.shadowClass+'-off',
- $ul = this.addClass(o.hoverClass)
- .find('>ul:hidden').css('visibility','visible');
- sf.IE7fix.call($ul);
- o.onBeforeShow.call($ul);
- $ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
- return this;
- }
- });
- })(jQuery);
- function show_splash(){
- var ssDuration=600,
- ssEasing='easeOutBounce',
- navDuration=200,
- navEasing='easeOutQuint'
- var content=$('#content'),
- nav=$('nav>ul>li>a')
- content
- .fadeOut(400,function(){
- nav.each(function(){
- var th=$(this),
- span=$('span',th)
- span
- .stop()
- .animate({top:'-100%'})
- th
- .unbind('mouseenter mouseleave')
- .stop()
- .animate({
- height:496,
- paddingBottom:10
- },{
- duration:ssDuration,
- easing:ssEasing,
- complete:function(){
- $(this)
- .bind('mouseenter',function(){
- var th=$(this)
- th
- .stop()
- .animate({
- backgroundPosition:'0px -20px'
- },{
- duration:navDuration,
- easing:navEasing
- })
- })
- .bind('mouseleave',function(){
- var th=$(this)
- th
- .stop()
- .animate({
- backgroundPosition:'0px 0px'
- },{
- duration:navDuration,
- easing:navEasing
- })
- })
- }
- })
- th.parent()
- .stop()
- .animate({
- height:516,
- borderBottom:0
- },{
- duration:ssDuration,
- easing:ssEasing
- })
- })
- })
- $('.sf').removeClass('sf-js-enabled')
- $('.backBu').fadeOut()
- splash=true
- }
- function show_subpages(){
- var ssDuration=600,
- ssEasing='easeOutBounce'
- $('nav>ul>li>a').each(function(){
- var th=$(this),
- span=$('span',th)
- span
- .show()
- .css({position:'absolute',top:'-100%'})
- th
- .unbind('mouseenter mouseleave')
- .stop()
- .animate({
- backgroundPosition:'0px 0px',
- height:73
- },{
- duration:ssDuration,
- easing:ssEasing,
- complete:function(){
- th
- .css({paddingBottom:0})
- span
- .stop()
- .animate({top:0},{duration:300})
- th.parent()
- .stop()
- .css({
- borderBottom:'1px '+th.css('backgroundColor')+' solid',
- height:73
- })
- .animate({
- borderBottomWidth:10
- },{
- duration:200
- })
- }
- })
- })
- setTimeout(function(){
- var content=$('#content'),
- navs=$('nav')
- content
- .show()
- .tabs({
- duration:200,
- showEf:''
- })
- navs.navs().refreshFu()
- $('.sf').addClass('sf-js-enabled')
- $('.backBu').fadeIn()
- },ssDuration)
- }
- $(window).load(function(){
- $('.gspinner').fadeOut()
- var ul=$('.scroll-wrap ul'),
- ulW=ul.width()-ul.parent().width(),
- slider=$('.track>div')
- slider.slider({
- min:1,max:100,value:0,
- slide:function(e,ui){
- ul
- .stop()
- .animate({left:-ui.value*ulW/100},1000)
- },
- change:function(e,ui){
- ul
- .stop()
- .animate({left:-ui.value*ulW/100},1000)
- }
- })
- $('.scroll-wrap .lf')
- .click(function(){
- var curr=slider.slider('value')
- curr-=20
- slider.slider('value',curr=curr>0?curr:1)
- return false
- })
- $('.scroll-wrap .rg')
- .click(function(){
- var curr=slider.slider('value')
- curr+=20
- slider.slider('value',curr=curr<ulW?curr:ulW)
- return false
- })
- })
- $(function(){
- window.splash=true
- var content=$('#content'),
- navs=$('nav')
- navs
- .navs({
- hover:true,
- click:function(n){
- if(splash)
- show_subpages(),
- splash=false
- Cufon.refresh()
- content.tabs(n)
- }
- })
- content.show()
- var gSlider=$('.gSlider')
- ._fw({
- gSlider:{
- easing:'easeOutBack',
- duration:1000,
- clone:true,
- show:4,
- mousewheel:true
- }
- }).width(940)
- .data('gSlider')
- $('.gSlider-controls .prev').click(function(){
- gSlider.changeFu('prev')
- return false
- })
- $('.gSlider-controls .next').click(function(){
- gSlider.changeFu('next')
- return false
- })
- $('#form1')._fw({
- forms:{
- backBu:'<a href="#" class="btn">back</a>'
- }
- })
- content.hide()
- $('.more')
- .bind('mouseenter',function(){
- $(this)
- .stop()
- .animate({
- color:'#9e702a',
- backgroundColor:'#fff'
- },{
- duration:400,
- easing:'easeInQuint'
- })
- })
- .bind('mouseleave',function(){
- $(this)
- .stop()
- .animate({
- color:'#fff',
- backgroundColor:'#e3a13c'
- },{
- duration:400,
- easing:'easeOutQuint'
- })
- })
- $('#form1 .btns a')
- .bind('mouseenter',function(){
- $(this)
- .stop()
- .animate({
- color:'#000',
- backgroundColor:'#fff'
- },{
- duration:400,
- easing:'easeInQuint'
- })
- })
- .bind('mouseleave',function(){
- $(this)
- .stop()
- .animate({
- color:'#fff',
- backgroundColor:'#4061a3'
- },{
- duration:400,
- easing:'easeOutQuint'
- })
- })
- $('.list a')
- .bind('mouseenter',function(){
- $(this)
- .stop()
- .animate({
- color:'#6c6721',
- paddingLeft:18
- },{
- duration:100,
- easing:'easeInQuint'
- })
- .animate({
- paddingLeft:28
- },{
- duration:100
- })
- })
- .bind('mouseleave',function(){
- $(this)
- .stop()
- .animate({
- color:'#fff',
- paddingLeft:28
- },{
- duration:200,
- easing:'easeOutQuint'
- })
- })
- show_splash()
- $('.sf').superfish()
- $('.sf').removeClass('sf-js-enabled')
- $(".scroll-wrap li a").fancybox();
- $('.backBu').click(function(){
- $('nav li a').trigger('mouseout')
- show_splash()
- return false
- }).hide()
- })