PageSourceSearch

https://carnegie-box.com/js/jquery.megamenu.js

js carnegie-box.com collected 2026-10-04 13:19:06 UTC 6,285 bytes, 143 lines download raw bytes

1/*
2 * jQuery MegaMenu Plugin
3 * Author: GeekTantra
4 * Author URI: http://www.geektantra.com
5 */
6
7var isIE6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;
8
9jQuery.fn.megamenu = function(options) {
10  options = jQuery.extend({
11                              activate_action: "mouseover",
12                              deactivate_action: "mouseleave",
13                              show_method: "slideDown",
14                              hide_method: "slideUp",
15                              justify: "left",
16                              enable_js_shadow: true,
17                              shadow_size: 3,
18                              mm_timeout: 250
19                          }, options);
20  var $megamenu_object = this;
21  if( options.activate_action == "click" ) options.mm_timeout = 0;
22  $megamenu_object.children("li").each(function(){
23    jQuery(this).addClass("mm-item");
24    jQuery(".mm-item").css({ 'float': options.justify });
25    
26    jQuery(this).find("div:first").addClass("mm-item-content");
27    jQuery(this).find("a:first").addClass("mm-item-link");
28    var $mm_item_content = jQuery(this).find(".mm-item-content");
29    var $mm_item_link = jQuery(this).find(".mm-item-link");
30    $mm_item_content.hide();
31    
32    jQuery(document).bind("click", function(){
33      jQuery(".mm-item-content").hide();
34      jQuery(".mm-item-link").removeClass("mm-item-link-hover");
35    });
36    jQuery(this).bind("click", function(e){
37      e.stopPropagation();
38    });
39    $mm_item_content.wrapInner('<div class="mm-content-base"></div>');
40    if(options.enable_js_shadow == true) {
41      $mm_item_content.append('<div class="mm-js-shadow"></div>');
42    }
43    var $mm_timer = 0;
44    // Activation Method Starts
45    jQuery(this).bind(options.activate_action, function(e){
46      e.stopPropagation();
47      var mm_item_link_obj = jQuery(this).find("a.mm-item-link");
48      var mm_item_content_obj = jQuery(this).find("div.mm-item-content");
49      clearTimeout($mm_timer);
50      $mm_timer = setTimeout(function(){ //Emulate HoverIntent
51        mm_item_link_obj.addClass("mm-item-link-hover");
52        mm_item_content_obj.css({
53          'top': ($mm_item_link.offset().top + $mm_item_link.outerHeight()) - 1 +"px",
54          'left': ($mm_item_link.offset().left) - 5 + 'px'
55        })
56        
57        if(options.justify == "left"){
58          var mm_object_right_end = $megamenu_object.offset().left + $megamenu_object.outerWidth();
59                                    // Coordinates of the right end of the megamenu object
60          var mm_content_right_end = $mm_item_link.offset().left + $mm_item_content.outerWidth() - 5 ;
61                                    // Coordinates of the right end of the megamenu content
62          if( mm_content_right_end >= mm_object_right_end ) { // Menu content exceeding the outer box
63            mm_item_content_obj.css({
64              'left': ($mm_item_link.offset().left - (mm_content_right_end - mm_object_right_end)) - 2 + 'px'
65            }); // Limit megamenu inside the outer box
66          }
67        } else if( options.justify == "right" ) {
68          var mm_object_left_end = $megamenu_object.offset().left;
69                                    // Coordinates of the left end of the megamenu object
70          var mm_content_left_end = $mm_item_link.offset().left - mm_item_content_obj.outerWidth() + 
71                                    $mm_item_link.outerWidth() + 5;
72                                    // Coordinates of the left end of the megamenu content
73          if( mm_content_left_end <= mm_object_left_end ) { // Menu content exceeding the outer box
74            mm_item_content_obj.css({
75              'left': mm_object_left_end + 2 + 'px'
76            }); // Limit megamenu inside the outer box
77          } else {
78            mm_item_content_obj.css({
79              'left': mm_content_left_end + 'px'
80            }); // Limit megamenu inside the outer box
81          }
82        }
83        if(options.enable_js_shadow == true) {
84          mm_item_content_obj.find(".mm-js-shadow").height( mm_item_content_obj.height() );
85          mm_item_content_obj.find(".mm-js-shadow").width( mm_item_content_obj.width() );
86          mm_item_content_obj.find(".mm-js-shadow").css({
87            'top': (options.shadow_size) + (isIE6 ? 2 : 0) + "px",
88            'left': (options.shadow_size) + (isIE6 ? 2 : 0) + "px",
89            'opacity': 0.5
90          });
91        }
92        switch(options.show_method) {
93          case "simple":
94                mm_item_content_obj.show();
95                break;
96          case "slideDown":
97                mm_item_content_obj.height("auto");
98                mm_item_content_obj.slideDown('fast');
99                break;
100          case "fadeIn":
101                mm_item_content_obj.fadeTo('fast', 1);
102                break;
103          default:
104                mm_item_content_obj.each( options.show_method );
105                break;
106        }
107      }, options.mm_timeout);
108    });
109    // Activation Method Ends
110    // Deactivation Method Starts
111    jQuery(this).bind(options.deactivate_action, function(e){
112      e.stopPropagation();
113      clearTimeout($mm_timer);
114      var mm_item_link_obj = jQuery(this).find("a.mm-item-link");
115      var mm_item_content_obj = jQuery(this).find("div.mm-item-content");
116//      mm_item_content_obj.stop();
117      switch(options.hide_method) {
118        case "simple":
119              mm_item_content_obj.hide();
120              mm_item_link_obj.removeClass("mm-item-link-hover");
121              break;
122        case "slideUp":
123              mm_item_content_obj.slideUp( 'fast',  function() {
124                mm_item_link_obj.removeClass("mm-item-link-hover");
125              });
126              break;
127        case "fadeOut":
128              mm_item_content_obj.fadeOut( 'fast', function() {
129                mm_item_link_obj.removeClass("mm-item-link-hover");
130              });
131              break;
132        default:
133              mm_item_content_obj.each( options.hide_method );
134              mm_item_link_obj.removeClass("mm-item-link-hover");
135              break;
136      }
137      if(mm_item_content_obj.length < 1) mm_item_link_obj.removeClass("mm-item-link-hover");
138    });
139//    Deactivation Method Ends
140  });
141  this.find(">li:last").after('<li class="clear-fix"></li>');
142  this.show();
143};

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.