1 /* This file was modified to look for superfish in $.fn.superfish instead of $.superfish */
4 * Supposition v0.2 - an optional enhancer for Superfish jQuery menu widget
6 * Copyright (c) 2008 Joel Birch - based mostly on work by Jesse Klaasse and credit goes largely to him.
7 * Special thanks to Karl Swedberg for valuable input.
9 * Dual licensed under the MIT and GPL licenses:
10 * http://www.opensource.org/licenses/mit-license.php
11 * http://www.gnu.org/licenses/gpl.html
16 $.fn.supposition = function(){
17 var $w = $(window), /*do this once instead of every onBeforeShow call*/
18 _offset = function(dir) {
19 return window[dir == 'y' ? 'pageYOffset' : 'pageXOffset']
20 || document.documentElement && document.documentElement[dir=='y' ? 'scrollTop' : 'scrollLeft']
21 || document.body[dir=='y' ? 'scrollTop' : 'scrollLeft'];
24 /* I haven't touched this bit - needs work as there are still z-index issues */
25 $topNav = $('li',this);
26 var cZ=parseInt($topNav.css('z-index')) + $topNav.length;
27 $topNav.each(function() {
28 $(this).css({zIndex:--cZ});
32 this.css({marginTop:'',marginLeft:''});
34 onBeforeShow = function(){
37 $u.css('display','block');
38 var menuWidth = $u.width(),
39 parentWidth = $u.parents('ul').width(),
40 totalRight = $w.width() + _offset('x'),
41 menuRight = $u.offset().left + menuWidth;
42 if (menuRight > totalRight) {
43 $u.css('margin-left', ($u.parents('ul').length == 1 ? totalRight - menuRight : -(menuWidth + parentWidth)) + 'px');
46 var windowHeight = $w.height(),
47 offsetTop = $u.offset().top,
48 menuHeight = $u.height(),
49 baseline = windowHeight + _offset('y');
50 var expandUp = (offsetTop + menuHeight > baseline);
52 $u.css('margin-top',baseline - (menuHeight + offsetTop));
54 $u.css('display','none');
58 return this.each(function() {
59 var o = $.fn.superfish.o[this.serial]; /* get this menu's options */
61 /* if callbacks already set, store them */
62 var _onInit = o.onInit,
63 _onBeforeShow = o.onBeforeShow,
66 $.extend($.fn.superfish.o[this.serial],{
68 onInit.call(this); /* fire our Supposition callback */
69 _onInit.call(this); /* fire stored callbacks */
71 onBeforeShow: function() {
72 onBeforeShow.call(this); /* fire our Supposition callback */
73 _onBeforeShow.call(this); /* fire stored callbacks */
76 onHide.call(this); /* fire our Supposition callback */
77 _onHide.call(this); /* fire stored callbacks */