Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 15th, 2012  |  syntax: None  |  size: 13.58 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Javascript Superfish Jquery Menu troubleshooting
  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. ;(function($){
  14.     $.fn.superfish = function(op){
  15.  
  16.         var sf = $.fn.superfish,
  17.             c = sf.c,
  18.             $arrow = $(['<span class="',c.arrowClass,'"> ยป</span>'].join('')),
  19.             over = function(){
  20.                 var $this = $(this), menu = getMenu($this);
  21.                 clearTimeout(menu.sfTimer);
  22.                 $this.showSuperfishUl().siblings().hideSuperfishUl();
  23.             },
  24.             out = function(){
  25.                 var $this = $(this), menu = getMenu($this), o = sf.op;
  26.                 clearTimeout(menu.sfTimer);
  27.                 menu.sfTimer=setTimeout(function(){
  28.                     o.retainPath=($.inArray($this[0],o.$path)>-1);
  29.                     $this.hideSuperfishUl();
  30.                     if (o.$path.length && $this.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
  31.                 },o.delay);
  32.             },
  33.             getMenu = function($menu){
  34.                 var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
  35.                 sf.op = sf.o[menu.serial];
  36.                 return menu;
  37.             },
  38.             addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
  39.  
  40.         return this.each(function() {
  41.           var $this = $(this);
  42.             var s = this.serial = sf.o.length;
  43.             var o = $.extend({},sf.defaults,op);
  44.             o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
  45.                 $(this).addClass([o.hoverClass,c.bcClass].join(' '))
  46.                     .filter('li:has(ul)').removeClass(o.pathClass);
  47.             });
  48.             sf.o[s] = sf.op = o;
  49.       // CHANGED: by KARL SWEDBERG
  50.             if ( (o.eventType === 'hoverIntent' && !$.fn.hoverIntent) || !(/^(?:hover|hoverIntent|toggle)$/).test(o.eventType) ) {
  51.               o.eventType = 'hover';
  52.             }
  53.             $this.find('li:has(ul)')[o.eventType](over,out).each(function() {
  54.                 if (o.autoArrows) {
  55.                   addArrow( $('>a:first-child',this) );
  56.                  // this.addClass("yourClass");
  57.                 }
  58.             })
  59.             .not('.'+c.bcClass)
  60.                 .hideSuperfishUl();
  61.  
  62.  
  63.             $this.find('a').each(function(i){
  64.                 var $a = $(this), $li = $a.parents('li');
  65.                 $a.focus(function(){over.call($li);}).blur(function(){out.call($li);});
  66.                 $a.click(function(event) {
  67.                   event.preventDefault();
  68.                   if ( !$a.hasClass("sf-with-ul") ) {
  69.                     location.href = this.href;
  70.                   }
  71.                 });
  72.             });
  73.             o.onInit.call(this);
  74.  
  75.         }).each(function() {
  76.             var menuClasses = [c.menuClass];
  77.             if (sf.op.dropShadows  && !($.browser.msie && $.browser.version < 7)) {
  78.               menuClasses.push(c.shadowClass);
  79.             }
  80.             $(this).addClass(menuClasses.join(' '));
  81.         });
  82.     };
  83.  
  84.     var sf = $.fn.superfish;
  85.     sf.o = [];
  86.     sf.op = {};
  87.     sf.IE7fix = function(){
  88.         var o = sf.op;
  89.         if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined) {
  90.             this.toggleClass(sf.c.shadowClass+'-off');
  91.         }
  92.         };
  93.  
  94.     sf.c = {
  95.         bcClass     : 'sf-breadcrumb',
  96.         menuClass   : 'sf-js-enabled',
  97.         anchorClass : 'sf-with-ul',
  98.         arrowClass  : 'sf-sub-indicator',
  99.         shadowClass : 'sf-shadow'
  100.     };
  101.  
  102.     sf.defaults = {
  103.         hoverClass  : 'sfHover',
  104.         pathClass   : 'current',
  105.         pathLevels  : 1,
  106.         delay       : 800,
  107.         animation   : {opacity:'show'},    
  108.         speed       : 'normal',
  109.         closeAnimation: {opacity: 'hide'},
  110.         closeSpeed: 0,
  111.         autoArrows  : true,
  112.         dropShadows : true,
  113.     //  CHANGED: by KARL SWEDBERG
  114.         eventType   : 'toggle', // one of 'toggle', 'hover', or 'hoverIntent'
  115.         disableHI   : false,    // true disables hoverIntent detection
  116.         onInit      : function(){}, // callback functions
  117.         onBeforeShow: function(){},
  118.         onShow      : function(){},
  119.         onHide      : function(){}
  120.     };
  121.  
  122.     $.fn.extend({
  123.         hideSuperfishUl : function(){
  124.             var o = sf.op,
  125.                 not = (o.retainPath===true) ? o.$path : '';
  126.             o.retainPath = false;
  127.             var $closingLi = $(['li.',o.hoverClass].join(''),this).add(this).not(not);
  128.             var $ul = $closingLi
  129.                     .find('>ul');
  130.             $ul.animate(o.closeAnimation, o.closeSpeed, function() {
  131.               $closingLi.removeClass(o.hoverClass);
  132.         $ul.css('visibility','hidden');
  133.       });
  134.             o.onHide.call($ul);
  135.             return this;
  136.         },
  137.  
  138.         showSuperfishUl : function(){
  139.             var o = sf.op,
  140.                 sh = sf.c.shadowClass+'-off',
  141.                 $ul = this.addClass(o.hoverClass)
  142.                     .find('>ul:hidden').css('visibility','visible');
  143.             sf.IE7fix.call($ul);
  144.             o.onBeforeShow.call($ul);
  145.             $ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
  146.             return this;
  147.         }
  148.  
  149.     });
  150.  
  151. })(jQuery);
  152.        
  153. function show_splash(){
  154.     var ssDuration=600,
  155.         ssEasing='easeOutBounce',
  156.         navDuration=200,
  157.         navEasing='easeOutQuint'
  158.     var content=$('#content'),
  159.         nav=$('nav>ul>li>a')
  160.     content
  161.         .fadeOut(400,function(){
  162.             nav.each(function(){
  163.                 var th=$(this),
  164.                     span=$('span',th)
  165.                 span
  166.                     .stop()
  167.                     .animate({top:'-100%'})
  168.                 th
  169.                     .unbind('mouseenter mouseleave')
  170.                     .stop()
  171.                     .animate({
  172.                         height:496,
  173.                         paddingBottom:10
  174.                     },{
  175.                         duration:ssDuration,
  176.                         easing:ssEasing,
  177.                         complete:function(){
  178.                             $(this)
  179.                                 .bind('mouseenter',function(){
  180.                                     var th=$(this)
  181.                                     th
  182.                                         .stop()
  183.                                         .animate({
  184.                                             backgroundPosition:'0px -20px'
  185.                                         },{
  186.                                             duration:navDuration,
  187.                                             easing:navEasing
  188.                                         })
  189.                                 })
  190.                                 .bind('mouseleave',function(){
  191.                                     var th=$(this)
  192.                                     th
  193.                                         .stop()
  194.                                         .animate({
  195.                                             backgroundPosition:'0px 0px'
  196.                                         },{
  197.                                             duration:navDuration,
  198.                                             easing:navEasing
  199.                                         })
  200.                                 })
  201.                         }
  202.                     })                  
  203.                 th.parent()
  204.                     .stop()
  205.                     .animate({
  206.                         height:516,
  207.                         borderBottom:0
  208.                     },{
  209.                         duration:ssDuration,
  210.                         easing:ssEasing
  211.                     })
  212.             })
  213.         })
  214.     $('.sf').removeClass('sf-js-enabled')
  215.     $('.backBu').fadeOut()
  216.     splash=true
  217. }
  218.  
  219. function show_subpages(){  
  220.     var ssDuration=600,
  221.         ssEasing='easeOutBounce'
  222.     $('nav>ul>li>a').each(function(){
  223.         var th=$(this),
  224.             span=$('span',th)
  225.         span
  226.             .show()
  227.             .css({position:'absolute',top:'-100%'})
  228.         th
  229.             .unbind('mouseenter mouseleave')
  230.             .stop()
  231.             .animate({
  232.                 backgroundPosition:'0px 0px',
  233.                 height:73
  234.             },{
  235.                 duration:ssDuration,
  236.                 easing:ssEasing,                
  237.                 complete:function(){
  238.                     th
  239.                         .css({paddingBottom:0})
  240.                     span                        
  241.                         .stop()
  242.                         .animate({top:0},{duration:300})
  243.                     th.parent()
  244.                         .stop()
  245.                         .css({
  246.                             borderBottom:'1px '+th.css('backgroundColor')+' solid',
  247.                             height:73
  248.                         })
  249.                         .animate({                      
  250.                             borderBottomWidth:10
  251.                         },{
  252.                             duration:200
  253.                         })
  254.                 }
  255.             })
  256.     })
  257.     setTimeout(function(){
  258.         var content=$('#content'),
  259.             navs=$('nav')
  260.         content
  261.             .show()            
  262.             .tabs({
  263.                 duration:200,
  264.                 showEf:''
  265.             })
  266.         navs.navs().refreshFu()
  267.         $('.sf').addClass('sf-js-enabled')
  268.         $('.backBu').fadeIn()
  269.     },ssDuration)
  270. }
  271.  
  272. $(window).load(function(){
  273.     $('.gspinner').fadeOut()
  274.  
  275.     var ul=$('.scroll-wrap ul'),
  276.         ulW=ul.width()-ul.parent().width(),
  277.         slider=$('.track>div')
  278.  
  279.     slider.slider({
  280.         min:1,max:100,value:0,
  281.         slide:function(e,ui){
  282.             ul
  283.                 .stop()
  284.                 .animate({left:-ui.value*ulW/100},1000)
  285.         },
  286.         change:function(e,ui){
  287.             ul
  288.                 .stop()
  289.                 .animate({left:-ui.value*ulW/100},1000)
  290.         }
  291.     })
  292.  
  293.     $('.scroll-wrap .lf')
  294.         .click(function(){
  295.             var curr=slider.slider('value')
  296.             curr-=20
  297.             slider.slider('value',curr=curr>0?curr:1)
  298.             return false
  299.         })
  300.     $('.scroll-wrap .rg')
  301.         .click(function(){
  302.             var curr=slider.slider('value')
  303.             curr+=20
  304.             slider.slider('value',curr=curr<ulW?curr:ulW)
  305.             return false
  306.         })
  307. })
  308.  
  309. $(function(){
  310.     window.splash=true
  311.     var content=$('#content'),
  312.         navs=$('nav')
  313.     navs
  314.         .navs({
  315.             hover:true,
  316.             click:function(n){
  317.                 if(splash)
  318.                     show_subpages(),
  319.                     splash=false                    
  320.                 Cufon.refresh()
  321.                 content.tabs(n)
  322.             }              
  323.         })
  324.     content.show()
  325.     var gSlider=$('.gSlider')
  326.         ._fw({
  327.             gSlider:{
  328.                 easing:'easeOutBack',
  329.                 duration:1000,
  330.                 clone:true,
  331.                 show:4,
  332.                 mousewheel:true
  333.             }
  334.         }).width(940)
  335.         .data('gSlider')
  336.     $('.gSlider-controls .prev').click(function(){
  337.         gSlider.changeFu('prev')
  338.         return false
  339.     })
  340.     $('.gSlider-controls .next').click(function(){
  341.         gSlider.changeFu('next')
  342.         return false
  343.     })
  344.     $('#form1')._fw({
  345.         forms:{
  346.             backBu:'<a href="#" class="btn">back</a>'
  347.         }
  348.     })
  349.     content.hide()
  350.  
  351.  
  352.     $('.more')
  353.         .bind('mouseenter',function(){
  354.             $(this)
  355.                 .stop()
  356.                 .animate({
  357.                     color:'#9e702a',
  358.                     backgroundColor:'#fff'
  359.                 },{
  360.                     duration:400,
  361.                     easing:'easeInQuint'
  362.                 })
  363.         })
  364.         .bind('mouseleave',function(){
  365.             $(this)
  366.                 .stop()
  367.                 .animate({
  368.                     color:'#fff',
  369.                     backgroundColor:'#e3a13c'
  370.                 },{
  371.                     duration:400,
  372.                     easing:'easeOutQuint'
  373.                 })
  374.         })
  375.     $('#form1 .btns a')
  376.         .bind('mouseenter',function(){
  377.             $(this)
  378.                 .stop()
  379.                 .animate({
  380.                     color:'#000',
  381.                     backgroundColor:'#fff'
  382.                 },{
  383.                     duration:400,
  384.                     easing:'easeInQuint'
  385.                 })
  386.         })
  387.         .bind('mouseleave',function(){
  388.             $(this)
  389.                 .stop()
  390.                 .animate({
  391.                     color:'#fff',
  392.                     backgroundColor:'#4061a3'
  393.                 },{
  394.                     duration:400,
  395.                     easing:'easeOutQuint'
  396.                 })
  397.         })
  398.     $('.list a')
  399.         .bind('mouseenter',function(){
  400.             $(this)
  401.                 .stop()
  402.                 .animate({
  403.                     color:'#6c6721',
  404.                     paddingLeft:18
  405.                 },{
  406.                     duration:100,
  407.                     easing:'easeInQuint'
  408.                 })
  409.                 .animate({
  410.                     paddingLeft:28
  411.                 },{
  412.                     duration:100
  413.                 })
  414.         })
  415.         .bind('mouseleave',function(){
  416.             $(this)
  417.                 .stop()
  418.                 .animate({
  419.                     color:'#fff',
  420.                     paddingLeft:28
  421.                 },{
  422.                     duration:200,                  
  423.                     easing:'easeOutQuint'
  424.                 })
  425.         })
  426.  
  427.     show_splash()
  428.  
  429.     $('.sf').superfish()
  430.     $('.sf').removeClass('sf-js-enabled')
  431.  
  432.     $(".scroll-wrap li a").fancybox();
  433.  
  434.     $('.backBu').click(function(){
  435.         $('nav li a').trigger('mouseout')
  436.         show_splash()
  437.         return false
  438.     }).hide()
  439. })