| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 // $Id: supposition.js,v 1.1 2009/08/19 04:28:07 sociotech Exp $ 2 3 /* 4 * Supposition v0.2 - an optional enhancer for Superfish jQuery menu widget 5 * 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. 8 * 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 12 */ 13 14 (function($){ 15 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']; 22 }, 23 onInit = function(){ 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}); 29 }); 30 }, 31 onHide = function(){ 32 this.css({marginTop:'',marginLeft:''}); 33 }, 34 onBeforeShow = function(){ 35 this.each(function(){ 36 var $u = $(this); 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'); 44 } 45 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); 51 if (expandUp) { 52 $u.css('margin-top',baseline - (menuHeight + offsetTop)); 53 } 54 $u.css('display','none'); 55 }); 56 }; 57 58 return this.each(function() { 59 var o = $.fn.superfish.o[this.serial]; /* get this menu's options */ 60 61 /* if callbacks already set, store them */ 62 var _onInit = o.onInit, 63 _onBeforeShow = o.onBeforeShow, 64 _onHide = o.onHide; 65 66 $.extend($.fn.superfish.o[this.serial],{ 67 onInit : function() { 68 onInit.call(this); /* fire our Supposition callback */ 69 _onInit.call(this); /* fire stored callbacks */ 70 }, 71 onBeforeShow: function() { 72 onBeforeShow.call(this); /* fire our Supposition callback */ 73 _onBeforeShow.call(this); /* fire stored callbacks */ 74 }, 75 onHide : function() { 76 onHide.call(this); /* fire our Supposition callback */ 77 _onHide.call(this); /* fire stored callbacks */ 78 } 79 }); 80 }); 81 }; 82 83 })(jQuery);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |