1/* 2 * Supposition v0.2 - an optional enhancer for Superfish jQuery menu widget. 3 * 4 * Copyright (c) 2008 Joel Birch - based mostly on work by Jesse Klaasse and credit goes largely to him. 5 * Special thanks to Karl Swedberg for valuable input. 6 * 7 * Dual licensed under the MIT and GPL licenses: 8 * http://www.opensource.org/licenses/mit-license.php 9 * http://www.gnu.org/licenses/gpl.html 10 */ 11/* 12 * This is not the original jQuery Supposition plugin. 13 * Please refer to the README for more information. 14 */ 15 16(function($){ 17 $.fn.supposition = function(){ 18 var $w = $(window), /*do this once instead of every onBeforeShow call*/ 19 _offset = function(dir) { 20 return window[dir == 'y' ? 'pageYOffset' : 'pageXOffset'] 21 || document.documentElement && document.documentElement[dir=='y' ? 'scrollTop' : 'scrollLeft'] 22 || document.body[dir=='y' ? 'scrollTop' : 'scrollLeft']; 23 }, 24 onHide = function(){ 25 this.css({bottom:''}); 26 }, 27 onBeforeShow = function(){ 28 this.each(function(){ 29 var $u = $(this); 30 $u.css('display','block'); 31 var $mul = $u.closest('.sf-menu'), 32 level = $u.parents('ul').length, 33 menuWidth = $u.width(), 34 menuParentWidth = $u.closest('li').outerWidth(true), 35 menuParentLeft = $u.closest('li').offset().left, 36 totalRight = $w.width() + _offset('x'), 37 menuRight = $u.offset().left + menuWidth, 38 exactMenuWidth = (menuRight > (menuParentWidth + menuParentLeft)) ? menuWidth - (menuRight - (menuParentWidth + menuParentLeft)) : menuWidth; 39 if ($u.parents('.sf-js-enabled').hasClass('rtl')) { 40 if (menuParentLeft < exactMenuWidth) { 41 if (($mul.hasClass('sf-horizontal') && level == 1) || ($mul.hasClass('sf-navbar') && level == 2)){ 42 $u.css({left:0,right:'auto'}); 43 } 44 else { 45 $u.css({left:menuParentWidth + 'px',right:'auto'}); 46 } 47 $u.parent().addClass('sf-supposition-active'); 48 } 49 } 50 else { 51 if (menuRight > totalRight && menuParentLeft > menuWidth) { 52 if (($mul.hasClass('sf-horizontal') && level == 1) || ($mul.hasClass('sf-navbar') && level == 2)){ 53 $u.css({right:0,left:'auto'}); 54 } 55 else { 56 $u.css({right:menuParentWidth + 'px',left:'auto'}); 57 } 58 $u.parent().addClass('sf-supposition-active'); 59 } 60 } 61 var windowHeight = $w.height(), 62 offsetTop = $u.offset().top, 63 menuParentShadow = ($mul.hasClass('sf-shadow') && $u.css('padding-bottom').length > 0) ? parseInt($u.css('padding-bottom').slice(0,-2)) : 0, 64 menuParentHeight = ($mul.hasClass('sf-vertical')) ? '-' + menuParentShadow : $u.parent().outerHeight(true) - menuParentShadow, 65 menuHeight = $u.height(), 66 baseline = windowHeight + _offset('y'); 67 var expandUp = ((offsetTop + menuHeight > baseline) && (offsetTop > menuHeight)); 68 if (expandUp) { 69 $u.css({bottom:menuParentHeight + 'px',top:'auto'}); 70 } 71 $u.css('display','none'); 72 }); 73 }; 74 75 return this.each(function() { 76 var o = $.fn.superfish.o[this.serial]; /* get this menu's options */ 77 78 /* if callbacks already set, store them */ 79 var _onBeforeShow = o.onBeforeShow, 80 _onHide = o.onHide; 81 82 $.extend($.fn.superfish.o[this.serial],{ 83 onBeforeShow: function() { 84 onBeforeShow.call(this); /* fire our Supposition callback */ 85 _onBeforeShow.call(this); /* fire stored callbacks */ 86 }, 87 onHide: function() { 88 onHide.call(this); /* fire our Supposition callback */ 89 _onHide.call(this); /* fire stored callbacks */ 90 } 91 }); 92 }); 93 }; 94})(jQuery);
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.