PageSourceSearch

https://savagesandscoundrels.org/scripts/superfish/superfish.js

js savagesandscoundrels.org collected 2026-10-02 13:30:51 UTC 4,024 bytes, 121 lines download raw bytes

1/*
2 * Superfish v1.4.8 - 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  $.fn.superfish = function(op){
14
15    var sf = $.fn.superfish,
16      c = sf.c,
17      $arrow = $(['<span class="',c.arrowClass,'"> &#187;</span>'].join('')),
18      over = function(){
19        var $$ = $(this), menu = getMenu($$);
20        clearTimeout(menu.sfTimer);
21        $$.showSuperfishUl().siblings().hideSuperfishUl();
22      },
23      out = function(){
24        var $$ = $(this), menu = getMenu($$), o = sf.op;
25        clearTimeout(menu.sfTimer);
26        menu.sfTimer=setTimeout(function(){
27          o.retainPath=($.inArray($$[0],o.$path)>-1);
28          $$.hideSuperfishUl();
29          if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
30        },o.delay);  
31      },
32      getMenu = function($menu){
33        var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
34        sf.op = sf.o[menu.serial];
35        return menu;
36      },
37      addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
38      
39    return this.each(function() {
40      var s = this.serial = sf.o.length;
41      var o = $.extend({},sf.defaults,op);
42      o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
43        $(this).addClass([o.hoverClass,c.bcClass].join(' '))
44          .filter('li:has(ul)').removeClass(o.pathClass);
45      });
46      sf.o[s] = sf.op = o;
47      
48      $('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
49        if (o.autoArrows) addArrow( $('>a:first-child',this) );
50      })
51      .not('.'+c.bcClass)
52        .hideSuperfishUl();
53      
54      var $a = $('a',this);
55      $a.each(function(i){
56        var $li = $a.eq(i).parents('li');
57        $a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
58      });
59      o.onInit.call(this);
60      
61    }).each(function() {
62      var menuClasses = [c.menuClass];
63      if (sf.op.dropShadows  && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
64      $(this).addClass(menuClasses.join(' '));
65    });
66  };
67
68  var sf = $.fn.superfish;
69  sf.o = [];
70  sf.op = {};
71  sf.IE7fix = function(){
72    var o = sf.op;
73    if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
74      this.toggleClass(sf.c.shadowClass+'-off');
75    };
76  sf.c = {
77    bcClass     : 'sf-breadcrumb',
78    menuClass   : 'sf-js-enabled',
79    anchorClass : 'sf-with-ul',
80    arrowClass  : 'sf-sub-indicator',
81    shadowClass : 'sf-shadow'
82  };
83  sf.defaults = {
84    hoverClass  : 'sfHover',
85    pathClass  : 'overideThisToUse',
86    pathLevels  : 1,
87    delay    : 800,
88    animation  : {opacity:'show'},
89    speed    : 'normal',
90    autoArrows  : true,
91    dropShadows : true,
92    disableHI  : false,    // true disables hoverIntent detection
93    onInit    : function(){}, // callback functions
94    onBeforeShow: function(){},
95    onShow    : function(){},
96    onHide    : function(){}
97  };
98  $.fn.extend({
99    hideSuperfishUl : function(){
100      var o = sf.op,
101        not = (o.retainPath===true) ? o.$path : '';
102      o.retainPath = false;
103      var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
104          .find('>ul').hide().css('visibility','hidden');
105      o.onHide.call($ul);
106      return this;
107    },
108    showSuperfishUl : function(){
109      var o = sf.op,
110        sh = sf.c.shadowClass+'-off',
111        $ul = this.addClass(o.hoverClass)
112          .find('>ul:hidden').css('visibility','visible');
113      sf.IE7fix.call($ul);
114      o.onBeforeShow.call($ul);
115      $ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
116      return this;
117    }
118  });
119
120})(jQuery);
121

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.