Version Description
Download this release
Release Info
Developer | megamenu |
Plugin | Max Mega Menu |
Version | 2.2.3.2 |
Comparing to | |
See all releases |
Code changes from version 2.2.3.1 to 2.2.3.2
- classes/nav-menus.class.php +2 -1
- classes/settings.class.php +15 -5
- classes/style-manager.class.php +4 -3
- classes/toggle-blocks.class.php +2 -4
- css/megamenu.scss +10 -2
- js/maxmegamenu.js +240 -123
- js/settings.js +5 -0
- megamenu.php +54 -3
- readme.txt +5 -5
classes/nav-menus.class.php
CHANGED
@@ -357,7 +357,8 @@ class Mega_Menu_Nav_Menus {
|
|
357 |
<td><?php _e("Event", "megamenu") ?></td>
|
358 |
<td>
|
359 |
<select name='megamenu_meta[<?php echo $location ?>][event]'>
|
360 |
-
<option value='hover' <?php selected( isset( $settings[$location]['event'] ) && $settings[$location]['event'] == 'hover'); ?>><?php _e("Hover", "megamenu"); ?></option>
|
|
|
361 |
<option value='click' <?php selected( isset( $settings[$location]['event'] ) && $settings[$location]['event'] == 'click'); ?>><?php _e("Click", "megamenu"); ?></option>
|
362 |
</select>
|
363 |
</td>
|
357 |
<td><?php _e("Event", "megamenu") ?></td>
|
358 |
<td>
|
359 |
<select name='megamenu_meta[<?php echo $location ?>][event]'>
|
360 |
+
<option value='hover' <?php selected( isset( $settings[$location]['event'] ) && $settings[$location]['event'] == 'hover'); ?>><?php _e("Hover Intent", "megamenu"); ?></option>
|
361 |
+
<option value='hover_' <?php selected( isset( $settings[$location]['event'] ) && $settings[$location]['event'] == 'hover_'); ?>><?php _e("Hover", "megamenu"); ?></option>
|
362 |
<option value='click' <?php selected( isset( $settings[$location]['event'] ) && $settings[$location]['event'] == 'click'); ?>><?php _e("Click", "megamenu"); ?></option>
|
363 |
</select>
|
364 |
</td>
|
classes/settings.class.php
CHANGED
@@ -120,6 +120,10 @@ class Mega_Menu_Settings {
|
|
120 |
|
121 |
}
|
122 |
|
|
|
|
|
|
|
|
|
123 |
if ( isset( $submitted_settings['toggle_blocks'] ) ) {
|
124 |
unset( $submitted_settings['toggle_blocks'] );
|
125 |
}
|
@@ -1103,22 +1107,28 @@ class Mega_Menu_Settings {
|
|
1103 |
|
1104 |
$header_links = apply_filters( "megamenu_header_links", array(
|
1105 |
'homepage' => array(
|
1106 |
-
'url' => 'https://www.maxmegamenu.com/?utm_source=free&utm_medium=
|
1107 |
'target' => '_mmmpro',
|
1108 |
'text' => __("Homepage", "megamenu"),
|
1109 |
'class' => ''
|
1110 |
),
|
1111 |
'documentation' => array(
|
1112 |
-
'url' => 'https://www.maxmegamenu.com/documentation/
|
1113 |
'text' => __("Documentation", "megamenu"),
|
1114 |
'target' => '_mmmpro',
|
1115 |
'class' => ''
|
|
|
|
|
|
|
|
|
|
|
|
|
1116 |
)
|
1117 |
) );
|
1118 |
|
1119 |
if ( ! is_plugin_active('megamenu-pro/megamenu-pro.php') ) {
|
1120 |
$header_links['pro'] = array(
|
1121 |
-
'url' => 'https://www.maxmegamenu.com/upgrade/?utm_source=free&utm_medium=
|
1122 |
'target' => '_mmmpro',
|
1123 |
'text' => __("Upgrade to Pro - $19", "megamenu"),
|
1124 |
'class' => 'mega-highlight'
|
@@ -1131,7 +1141,7 @@ class Mega_Menu_Settings {
|
|
1131 |
'text' => __("Core version", "megamenu")
|
1132 |
),
|
1133 |
'pro' => array(
|
1134 |
-
'version' => "<a href='https://www.maxmegamenu.com/upgrade/?utm_source=free&utm_medium=
|
1135 |
'text' => __("Pro extension", "megamenu")
|
1136 |
)
|
1137 |
) );
|
@@ -3140,7 +3150,7 @@ class Mega_Menu_Settings {
|
|
3140 |
foreach ( $group['settings'] as $setting_id => $setting ) {
|
3141 |
if ( isset( $setting['validation'] ) ) {
|
3142 |
|
3143 |
-
echo "<div class='mega-validation-message mega-validation-message-{$setting['key']}'>";
|
3144 |
|
3145 |
if ( $setting['validation'] == 'int' ) {
|
3146 |
$message = __("Enter a whole number (e.g. 1, 5, 100, 999)");
|
120 |
|
121 |
}
|
122 |
|
123 |
+
if ( is_numeric( $submitted_settings['responsive_breakpoint'] ) ) {
|
124 |
+
$submitted_settings['responsive_breakpoint'] = $submitted_settings['responsive_breakpoint'] . "px";
|
125 |
+
}
|
126 |
+
|
127 |
if ( isset( $submitted_settings['toggle_blocks'] ) ) {
|
128 |
unset( $submitted_settings['toggle_blocks'] );
|
129 |
}
|
1107 |
|
1108 |
$header_links = apply_filters( "megamenu_header_links", array(
|
1109 |
'homepage' => array(
|
1110 |
+
'url' => 'https://www.maxmegamenu.com/?utm_source=free&utm_medium=settings&utm_campaign=pro',
|
1111 |
'target' => '_mmmpro',
|
1112 |
'text' => __("Homepage", "megamenu"),
|
1113 |
'class' => ''
|
1114 |
),
|
1115 |
'documentation' => array(
|
1116 |
+
'url' => 'https://www.maxmegamenu.com/documentation/installation/?utm_source=free&utm_medium=settings&utm_campaign=pro',
|
1117 |
'text' => __("Documentation", "megamenu"),
|
1118 |
'target' => '_mmmpro',
|
1119 |
'class' => ''
|
1120 |
+
),
|
1121 |
+
'troubleshooting' => array(
|
1122 |
+
'url' => 'https://www.maxmegamenu.com/articles/troubleshooting/?utm_source=free&utm_medium=settings&utm_campaign=pro',
|
1123 |
+
'text' => __("Troubleshooting", "megamenu"),
|
1124 |
+
'target' => '_mmmpro',
|
1125 |
+
'class' => ''
|
1126 |
)
|
1127 |
) );
|
1128 |
|
1129 |
if ( ! is_plugin_active('megamenu-pro/megamenu-pro.php') ) {
|
1130 |
$header_links['pro'] = array(
|
1131 |
+
'url' => 'https://www.maxmegamenu.com/upgrade/?utm_source=free&utm_medium=settings&utm_campaign=pro',
|
1132 |
'target' => '_mmmpro',
|
1133 |
'text' => __("Upgrade to Pro - $19", "megamenu"),
|
1134 |
'class' => 'mega-highlight'
|
1141 |
'text' => __("Core version", "megamenu")
|
1142 |
),
|
1143 |
'pro' => array(
|
1144 |
+
'version' => "<a href='https://www.maxmegamenu.com/upgrade/?utm_source=free&utm_medium=settings&utm_campaign=pro' target='_mmmpro'>not installed</a>",
|
1145 |
'text' => __("Pro extension", "megamenu")
|
1146 |
)
|
1147 |
) );
|
3150 |
foreach ( $group['settings'] as $setting_id => $setting ) {
|
3151 |
if ( isset( $setting['validation'] ) ) {
|
3152 |
|
3153 |
+
echo "<div class='mega-validation-message mega-validation-message-mega-{$setting['key']}'>";
|
3154 |
|
3155 |
if ( $setting['validation'] == 'int' ) {
|
3156 |
$message = __("Enter a whole number (e.g. 1, 5, 100, 999)");
|
classes/style-manager.class.php
CHANGED
@@ -386,12 +386,13 @@ final class Mega_Menu_Style_Manager {
|
|
386 |
|
387 |
|
388 |
/**
|
|
|
389 |
*
|
390 |
* @since 1.3.1
|
391 |
*/
|
392 |
private function is_debug_mode() {
|
393 |
|
394 |
-
return ( defined( 'MEGAMENU_DEBUG' ) && MEGAMENU_DEBUG === true ) || isset( $_GET['nocache'] );
|
395 |
|
396 |
}
|
397 |
|
@@ -702,7 +703,7 @@ final class Mega_Menu_Style_Manager {
|
|
702 |
|
703 |
$scss .= $this->load_scss_file();
|
704 |
|
705 |
-
$scss .= stripslashes( html_entity_decode( $theme['custom_css'] ) );
|
706 |
|
707 |
return apply_filters( "megamenu_scss", $scss, $location, $theme, $menu_id );
|
708 |
|
@@ -1033,7 +1034,7 @@ final class Mega_Menu_Style_Manager {
|
|
1033 |
$languages = icl_get_languages('skip_missing=N');
|
1034 |
|
1035 |
foreach ( $languages as $language ) {
|
1036 |
-
delete_transient(
|
1037 |
}
|
1038 |
|
1039 |
}
|
386 |
|
387 |
|
388 |
/**
|
389 |
+
*
|
390 |
*
|
391 |
* @since 1.3.1
|
392 |
*/
|
393 |
private function is_debug_mode() {
|
394 |
|
395 |
+
return ( defined( 'MEGAMENU_DEBUG' ) && MEGAMENU_DEBUG === true ) || ( current_user_can('edit_theme_options') && isset( $_GET['nocache'] ) );
|
396 |
|
397 |
}
|
398 |
|
703 |
|
704 |
$scss .= $this->load_scss_file();
|
705 |
|
706 |
+
$scss .= stripslashes( html_entity_decode( $theme['custom_css'], ENT_QUOTES ) );
|
707 |
|
708 |
return apply_filters( "megamenu_scss", $scss, $location, $theme, $menu_id );
|
709 |
|
1034 |
$languages = icl_get_languages('skip_missing=N');
|
1035 |
|
1036 |
foreach ( $languages as $language ) {
|
1037 |
+
delete_transient( 'megamenu_css_' . $language['language_code'] );
|
1038 |
}
|
1039 |
|
1040 |
}
|
classes/toggle-blocks.class.php
CHANGED
@@ -134,8 +134,6 @@ class Mega_Menu_Toggle_Blocks {
|
|
134 |
"id" => "mega-toggle-block-{$block_id}"
|
135 |
), $block, $content, $nav_menu, $args, $theme_id);
|
136 |
|
137 |
-
|
138 |
-
|
139 |
$blocks_html .= "<div";
|
140 |
|
141 |
foreach ( $attributes as $attribute => $val ) {
|
@@ -557,10 +555,10 @@ class Mega_Menu_Toggle_Blocks {
|
|
557 |
<input type='hidden' class='type' name='toggle_blocks[<?php echo $block_id; ?>][type]' value='menu_toggle' />
|
558 |
<input type='hidden' class='align' name='toggle_blocks[<?php echo $block_id; ?>][align]' value='<?php echo $settings['align'] ?>'>
|
559 |
<label>
|
560 |
-
<?php _e("Closed Text", "megamenu") ?><input type='text' class='closed_text' name='toggle_blocks[<?php echo $block_id; ?>][closed_text]' value='<?php echo $settings['closed_text'] ?>' />
|
561 |
</label>
|
562 |
<label>
|
563 |
-
<?php _e("Open Text", "megamenu") ?><input type='text' class='open_text' name='toggle_blocks[<?php echo $block_id; ?>][open_text]' value='<?php echo $settings['open_text'] ?>' />
|
564 |
</label>
|
565 |
<label>
|
566 |
<?php _e("Closed Icon", "megamenu") ?>
|
134 |
"id" => "mega-toggle-block-{$block_id}"
|
135 |
), $block, $content, $nav_menu, $args, $theme_id);
|
136 |
|
|
|
|
|
137 |
$blocks_html .= "<div";
|
138 |
|
139 |
foreach ( $attributes as $attribute => $val ) {
|
555 |
<input type='hidden' class='type' name='toggle_blocks[<?php echo $block_id; ?>][type]' value='menu_toggle' />
|
556 |
<input type='hidden' class='align' name='toggle_blocks[<?php echo $block_id; ?>][align]' value='<?php echo $settings['align'] ?>'>
|
557 |
<label>
|
558 |
+
<?php _e("Closed Text", "megamenu") ?><input type='text' class='closed_text' name='toggle_blocks[<?php echo $block_id; ?>][closed_text]' value='<?php echo stripslashes( esc_attr( $settings['closed_text'] ) ) ?>' />
|
559 |
</label>
|
560 |
<label>
|
561 |
+
<?php _e("Open Text", "megamenu") ?><input type='text' class='open_text' name='toggle_blocks[<?php echo $block_id; ?>][open_text]' value='<?php echo stripslashes( esc_attr( $settings['open_text'] ) ) ?>' />
|
562 |
</label>
|
563 |
<label>
|
564 |
<?php _e("Closed Icon", "megamenu") ?>
|
css/megamenu.scss
CHANGED
@@ -92,6 +92,10 @@
|
|
92 |
cursor: default;
|
93 |
}
|
94 |
|
|
|
|
|
|
|
|
|
95 |
&.mega-keyboard-navigation + .mega-menu-toggle.mega-menu-open,
|
96 |
&.mega-keyboard-navigation a:focus,
|
97 |
&.mega-keyboard-navigation input:focus {
|
@@ -257,7 +261,10 @@
|
|
257 |
|
258 |
&.mega-item-align-right {
|
259 |
float: right;
|
260 |
-
|
|
|
|
|
|
|
261 |
}
|
262 |
|
263 |
&.mega-toggle-on > a.mega-menu-link,
|
@@ -273,7 +280,8 @@
|
|
273 |
@if $menu_item_highlight_current == 'on' {
|
274 |
|
275 |
&.mega-current-menu-item,
|
276 |
-
&.mega-current-menu-ancestor
|
|
|
277 |
> a.mega-menu-link {
|
278 |
@include background($menu_item_background_hover_from, $menu_item_background_hover_to);
|
279 |
color: $menu_item_link_color_hover;
|
92 |
cursor: default;
|
93 |
}
|
94 |
|
95 |
+
li.mega-menu-item-has-children.mega-disable-link > a.mega-menu-link {
|
96 |
+
cursor: pointer;
|
97 |
+
}
|
98 |
+
|
99 |
&.mega-keyboard-navigation + .mega-menu-toggle.mega-menu-open,
|
100 |
&.mega-keyboard-navigation a:focus,
|
101 |
&.mega-keyboard-navigation input:focus {
|
261 |
|
262 |
&.mega-item-align-right {
|
263 |
float: right;
|
264 |
+
|
265 |
+
@include desktop {
|
266 |
+
margin: 0 0 0 $menu_item_spacing;
|
267 |
+
}
|
268 |
}
|
269 |
|
270 |
&.mega-toggle-on > a.mega-menu-link,
|
280 |
@if $menu_item_highlight_current == 'on' {
|
281 |
|
282 |
&.mega-current-menu-item,
|
283 |
+
&.mega-current-menu-ancestor,
|
284 |
+
&.mega-current-page-ancestor {
|
285 |
> a.mega-menu-link {
|
286 |
@include background($menu_item_background_hover_from, $menu_item_background_hover_to);
|
287 |
color: $menu_item_link_color_hover;
|
js/maxmegamenu.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
/*jslint browser: true, white: true */
|
2 |
/*global console,jQuery,megamenu,window,navigator*/
|
3 |
|
4 |
/**
|
@@ -14,65 +14,77 @@
|
|
14 |
var $menu = $(menu);
|
15 |
|
16 |
var defaults = {
|
17 |
-
event: $menu.attr(
|
18 |
-
effect: $menu.attr(
|
19 |
-
effect_speed: parseInt($menu.attr(
|
20 |
-
panel_width: $menu.attr(
|
21 |
-
panel_inner_width: $menu.attr(
|
22 |
-
second_click: $menu.attr(
|
23 |
-
vertical_behaviour: $menu.attr(
|
24 |
-
reverse_mobile_items: $menu.attr(
|
25 |
-
document_click: $menu.attr(
|
26 |
-
breakpoint: $menu.attr(
|
27 |
};
|
28 |
|
29 |
plugin.settings = {};
|
30 |
|
|
|
|
|
|
|
31 |
var isTouchDevice = function() {
|
32 |
-
return (
|
33 |
};
|
34 |
|
35 |
-
plugin.hidePanel = function(anchor, immediate) {
|
36 |
|
37 |
-
|
|
|
|
|
|
|
|
|
38 |
|
39 |
if (immediate) {
|
40 |
-
anchor.siblings(
|
41 |
-
anchor.parent().removeClass(
|
42 |
return;
|
43 |
}
|
44 |
|
45 |
-
var timeout = plugin.settings.effect_speed + parseInt(megamenu.timeout, 10);
|
46 |
-
|
47 |
if ( megamenu.effect[plugin.settings.effect] ) {
|
48 |
-
var effect = megamenu.effect[plugin.settings.effect][
|
49 |
var speed = plugin.settings.effect_speed;
|
50 |
|
51 |
if (effect.css) {
|
52 |
-
anchor.siblings(
|
53 |
}
|
54 |
|
55 |
if (effect.animate) {
|
56 |
|
57 |
-
anchor.siblings(
|
58 |
-
anchor.parent().removeClass(
|
59 |
});
|
60 |
-
anchor.siblings(
|
61 |
-
add_animating_class(anchor.parent());
|
62 |
});
|
63 |
} else {
|
64 |
-
anchor.parent().removeClass(
|
65 |
-
add_animating_class(anchor.parent());
|
66 |
}
|
67 |
} else {
|
68 |
-
anchor.parent().removeClass(
|
69 |
-
add_animating_class(anchor.parent());
|
70 |
}
|
71 |
|
72 |
};
|
73 |
|
74 |
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
var timeout = plugin.settings.effect_speed + parseInt(megamenu.timeout, 10);
|
77 |
|
78 |
element.addClass("mega-animating");
|
@@ -80,136 +92,161 @@
|
|
80 |
setTimeout(function() {
|
81 |
element.removeClass("mega-animating");
|
82 |
}, timeout );
|
83 |
-
}
|
84 |
|
85 |
|
|
|
|
|
|
|
86 |
plugin.hideAllPanels = function() {
|
87 |
-
$(
|
88 |
plugin.hidePanel($(this), false);
|
89 |
});
|
90 |
};
|
91 |
|
92 |
|
|
|
|
|
|
|
93 |
plugin.hideSiblingPanels = function(anchor, immediate) {
|
94 |
// jQuery 1.7.2 compatibility for themes/plugins that load old versions of jQuery
|
95 |
if ( $.fn.addBack !== undefined ) {
|
96 |
// all open children of open siblings
|
97 |
-
anchor.parent().siblings().find(
|
98 |
plugin.hidePanel($(this), immediate);
|
99 |
});
|
100 |
} else {
|
101 |
// all open children of open siblings
|
102 |
-
anchor.parent().siblings().find(
|
103 |
plugin.hidePanel($(this), immediate);
|
104 |
});
|
105 |
}
|
106 |
-
}
|
107 |
|
|
|
|
|
|
|
|
|
|
|
108 |
plugin.isDesktopView = function() {
|
109 |
return $(window).width() > plugin.settings.breakpoint;
|
110 |
-
}
|
|
|
111 |
|
|
|
|
|
|
|
|
|
112 |
plugin.hideOpenSiblings = function() {
|
113 |
// desktops, horizontal
|
114 |
-
if ( plugin.isDesktopView() && ( $menu.hasClass(
|
115 |
-
return
|
116 |
}
|
117 |
|
118 |
// mobile, keyboard navigation
|
119 |
-
if ( ! plugin.isDesktopView() && $menu.hasClass(
|
120 |
-
return
|
121 |
}
|
122 |
|
123 |
-
if ( plugin.settings.vertical_behaviour
|
124 |
-
return
|
125 |
}
|
126 |
-
}
|
127 |
|
128 |
-
|
|
|
129 |
|
130 |
-
|
|
|
|
|
|
|
|
|
|
|
131 |
return;
|
132 |
}
|
133 |
|
|
|
134 |
switch( plugin.hideOpenSiblings() ) {
|
135 |
-
case
|
136 |
plugin.hideSiblingPanels(anchor, true);
|
137 |
break;
|
138 |
-
case
|
139 |
plugin.hideSiblingPanels(anchor, false);
|
140 |
break;
|
141 |
}
|
142 |
|
143 |
// apply dynamic width and sub menu position
|
144 |
-
if ( anchor.parent().hasClass(
|
145 |
var submenu_offset = $menu.offset();
|
146 |
var target_offset = $(plugin.settings.panel_width).offset();
|
147 |
|
148 |
-
anchor.siblings(
|
149 |
width: $(plugin.settings.panel_width).outerWidth(),
|
150 |
left: (target_offset.left - submenu_offset.left) + "px"
|
151 |
});
|
152 |
}
|
153 |
|
154 |
-
|
155 |
// apply inner width to sub menu by adding padding to the left and right of the mega menu
|
156 |
-
if ( anchor.parent().hasClass(
|
|
|
157 |
|
158 |
if ( $(plugin.settings.panel_inner_width).length ) {
|
159 |
// jQuery selector
|
160 |
-
|
161 |
} else {
|
162 |
-
// we
|
163 |
-
|
164 |
}
|
165 |
|
166 |
-
var submenu_width = parseInt(anchor.siblings(
|
167 |
|
168 |
if ( (target_width > 0) && (target_width < submenu_width) ) {
|
169 |
-
anchor.siblings(
|
170 |
-
|
171 |
-
|
172 |
});
|
173 |
}
|
174 |
}
|
175 |
|
176 |
-
|
177 |
if ( megamenu.effect[plugin.settings.effect] ) {
|
178 |
-
var effect = megamenu.effect[plugin.settings.effect][
|
179 |
var speed = plugin.settings.effect_speed;
|
180 |
|
181 |
if (effect.css) {
|
182 |
-
anchor.siblings(
|
183 |
}
|
184 |
|
185 |
if (effect.animate) {
|
186 |
-
anchor.siblings(
|
187 |
-
$(this).css(
|
188 |
});
|
189 |
}
|
190 |
}
|
191 |
|
192 |
-
anchor.parent().addClass(
|
193 |
};
|
194 |
|
|
|
|
|
|
|
|
|
195 |
var openOnClick = function() {
|
196 |
// hide menu when clicked away from
|
197 |
-
$(document).on(
|
198 |
-
if ( ( plugin.settings.document_click
|
199 |
plugin.hideAllPanels();
|
200 |
}
|
201 |
});
|
202 |
|
203 |
-
$(
|
204 |
click: function(e) {
|
205 |
-
|
206 |
// all clicks on parent items when sub menu is hidden on mobile
|
207 |
-
if ( ! plugin.isDesktopView() && $(this).parent().hasClass(
|
208 |
return;
|
209 |
}
|
210 |
|
211 |
// check for second click
|
212 |
-
if ( plugin.settings.second_click
|
213 |
if ( ! $(this).parent().hasClass("mega-toggle-on") ) {
|
214 |
e.preventDefault();
|
215 |
plugin.showPanel($(this));
|
@@ -227,114 +264,195 @@
|
|
227 |
});
|
228 |
};
|
229 |
|
|
|
|
|
|
|
|
|
230 |
var openOnHover = function() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
|
232 |
-
|
|
|
|
|
|
|
|
|
233 |
over: function () {
|
234 |
-
plugin.showPanel($(this).children(
|
235 |
},
|
236 |
out: function () {
|
237 |
if ($(this).hasClass("mega-toggle-on")) {
|
238 |
-
plugin.hidePanel($(this).children(
|
239 |
}
|
240 |
},
|
241 |
timeout: megamenu.timeout,
|
242 |
interval: megamenu.interval
|
243 |
});
|
244 |
-
|
245 |
};
|
246 |
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
if ( $(window).width() <= plugin.settings.breakpoint && $menu.data('view') == 'desktop' ) {
|
252 |
-
$menu.data('view', 'mobile');
|
253 |
-
$menu.append($menu.children('li.mega-item-align-right').get().reverse());
|
254 |
-
}
|
255 |
-
|
256 |
-
if ( $(window).width() >= plugin.settings.breakpoint && $menu.data('view') == 'mobile' ) {
|
257 |
-
$menu.data('view', 'desktop');
|
258 |
-
$menu.append($menu.children('li.mega-item-align-right').get().reverse());
|
259 |
-
}
|
260 |
-
|
261 |
-
}
|
262 |
-
|
263 |
-
}
|
264 |
-
|
265 |
plugin.keyboard_navigation = function() {
|
266 |
var tab_key = 9;
|
267 |
var escape_key = 27;
|
268 |
|
269 |
-
$(
|
270 |
var keyCode = e.keyCode || e.which;
|
271 |
|
272 |
-
if (keyCode
|
273 |
-
$menu.removeClass(
|
274 |
plugin.hideAllPanels();
|
275 |
}
|
276 |
|
277 |
-
if ( $menu.hasClass(
|
278 |
-
$menu.removeClass(
|
279 |
plugin.hideAllPanels();
|
280 |
}
|
281 |
});
|
282 |
|
283 |
-
$menu.parent().on(
|
284 |
var keyCode = e.keyCode || e.which;
|
285 |
var active_link = $(e.target);
|
286 |
|
287 |
-
if (keyCode
|
288 |
-
$menu.addClass(
|
289 |
|
290 |
-
if ( active_link.parent().hasClass(
|
291 |
// menu item with sub menu
|
292 |
plugin.showPanel(active_link);
|
293 |
-
} else if ( active_link.parent().parent().hasClass(
|
294 |
// top level item with no children
|
295 |
plugin.hideAllPanels();
|
296 |
}
|
297 |
|
298 |
-
if ( active_link.hasClass(
|
299 |
-
active_link.toggleClass(
|
300 |
}
|
301 |
}
|
302 |
});
|
303 |
-
}
|
304 |
-
|
305 |
-
plugin.init = function() {
|
306 |
-
plugin.settings = $.extend({}, defaults, options);
|
307 |
|
308 |
-
$menu.removeClass('mega-no-js');
|
309 |
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
|
|
315 |
|
316 |
-
$('li.mega-menu-item, ul.mega-sub-menu', menu).unbind();
|
317 |
|
318 |
-
|
|
|
|
|
|
|
|
|
|
|
319 |
openOnClick();
|
|
|
|
|
320 |
} else {
|
321 |
openOnHover();
|
322 |
}
|
|
|
323 |
|
324 |
-
|
325 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
} else {
|
327 |
-
$menu.data(
|
|
|
328 |
}
|
329 |
|
330 |
-
plugin.
|
331 |
|
332 |
$(window).resize(function() {
|
333 |
-
plugin.
|
334 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
plugin.keyboard_navigation();
|
337 |
|
|
|
|
|
338 |
};
|
339 |
|
340 |
plugin.init();
|
@@ -343,9 +461,9 @@
|
|
343 |
|
344 |
$.fn.maxmegamenu = function(options) {
|
345 |
return this.each(function() {
|
346 |
-
if (undefined === $(this).data(
|
347 |
var plugin = new $.maxmegamenu(this, options);
|
348 |
-
$(this).data(
|
349 |
}
|
350 |
});
|
351 |
};
|
@@ -355,5 +473,4 @@
|
|
355 |
$(".mega-menu").maxmegamenu();
|
356 |
});
|
357 |
|
358 |
-
|
359 |
})(jQuery);
|
1 |
+
/*jslint browser: true, white: true, this: true */
|
2 |
/*global console,jQuery,megamenu,window,navigator*/
|
3 |
|
4 |
/**
|
14 |
var $menu = $(menu);
|
15 |
|
16 |
var defaults = {
|
17 |
+
event: $menu.attr("data-event"),
|
18 |
+
effect: $menu.attr("data-effect"),
|
19 |
+
effect_speed: parseInt($menu.attr("data-effect-speed")),
|
20 |
+
panel_width: $menu.attr("data-panel-width"),
|
21 |
+
panel_inner_width: $menu.attr("data-panel-inner-width"),
|
22 |
+
second_click: $menu.attr("data-second-click"),
|
23 |
+
vertical_behaviour: $menu.attr("data-vertical-behaviour"),
|
24 |
+
reverse_mobile_items: $menu.attr("data-reverse-mobile-items"),
|
25 |
+
document_click: $menu.attr("data-document-click"),
|
26 |
+
breakpoint: $menu.attr("data-breakpoint")
|
27 |
};
|
28 |
|
29 |
plugin.settings = {};
|
30 |
|
31 |
+
/**
|
32 |
+
* Returns true if touch events are detected
|
33 |
+
*/
|
34 |
var isTouchDevice = function() {
|
35 |
+
return ("ontouchstart" in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0 || (window.DocumentTouch && document instanceof DocumentTouch));
|
36 |
};
|
37 |
|
|
|
38 |
|
39 |
+
/**
|
40 |
+
* Hides a single panel (sub menu)
|
41 |
+
*/
|
42 |
+
plugin.hidePanel = function(anchor, immediate) {
|
43 |
+
anchor.siblings(".mega-sub-menu").children(".mega-toggle-on").removeClass("mega-toggle-on");
|
44 |
|
45 |
if (immediate) {
|
46 |
+
anchor.siblings(".mega-sub-menu").removeClass("mega-toggle-on");
|
47 |
+
anchor.parent().removeClass("mega-toggle-on").triggerHandler("close_panel");
|
48 |
return;
|
49 |
}
|
50 |
|
|
|
|
|
51 |
if ( megamenu.effect[plugin.settings.effect] ) {
|
52 |
+
var effect = megamenu.effect[plugin.settings.effect]["out"];
|
53 |
var speed = plugin.settings.effect_speed;
|
54 |
|
55 |
if (effect.css) {
|
56 |
+
anchor.siblings(".mega-sub-menu").css(effect.css);
|
57 |
}
|
58 |
|
59 |
if (effect.animate) {
|
60 |
|
61 |
+
anchor.siblings(".mega-sub-menu").animate(effect.animate, speed, function() {
|
62 |
+
anchor.parent().removeClass("mega-toggle-on").triggerHandler("close_panel");
|
63 |
});
|
64 |
+
anchor.siblings(".mega-sub-menu").each( function() {
|
65 |
+
plugin.add_animating_class(anchor.parent());
|
66 |
});
|
67 |
} else {
|
68 |
+
anchor.parent().removeClass("mega-toggle-on").triggerHandler("close_panel");
|
69 |
+
plugin.add_animating_class(anchor.parent());
|
70 |
}
|
71 |
} else {
|
72 |
+
anchor.parent().removeClass("mega-toggle-on").triggerHandler("close_panel");
|
73 |
+
plugin.add_animating_class(anchor.parent());
|
74 |
}
|
75 |
|
76 |
};
|
77 |
|
78 |
|
79 |
+
/**
|
80 |
+
* Adds an animating class to the sub menu whilst it is closing.
|
81 |
+
* This allows the CSS3 animation to complete before the element is hidden.
|
82 |
+
*/
|
83 |
+
plugin.add_animating_class = function(element) {
|
84 |
+
if (plugin.settings.effect === "disabled") {
|
85 |
+
return;
|
86 |
+
}
|
87 |
+
|
88 |
var timeout = plugin.settings.effect_speed + parseInt(megamenu.timeout, 10);
|
89 |
|
90 |
element.addClass("mega-animating");
|
92 |
setTimeout(function() {
|
93 |
element.removeClass("mega-animating");
|
94 |
}, timeout );
|
95 |
+
};
|
96 |
|
97 |
|
98 |
+
/**
|
99 |
+
* Hide all open sub menus
|
100 |
+
*/
|
101 |
plugin.hideAllPanels = function() {
|
102 |
+
$(".mega-toggle-on > a.mega-menu-link", $menu).each(function() {
|
103 |
plugin.hidePanel($(this), false);
|
104 |
});
|
105 |
};
|
106 |
|
107 |
|
108 |
+
/**
|
109 |
+
* For flyout menus: Hide open sub menus at the same level as the sub menu that"s being opened
|
110 |
+
*/
|
111 |
plugin.hideSiblingPanels = function(anchor, immediate) {
|
112 |
// jQuery 1.7.2 compatibility for themes/plugins that load old versions of jQuery
|
113 |
if ( $.fn.addBack !== undefined ) {
|
114 |
// all open children of open siblings
|
115 |
+
anchor.parent().siblings().find(".mega-toggle-on").addBack().children("a").each(function() {
|
116 |
plugin.hidePanel($(this), immediate);
|
117 |
});
|
118 |
} else {
|
119 |
// all open children of open siblings
|
120 |
+
anchor.parent().siblings().find(".mega-toggle-on").andSelf().children("a").each(function() {
|
121 |
plugin.hidePanel($(this), immediate);
|
122 |
});
|
123 |
}
|
124 |
+
};
|
125 |
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Returns true if the browser width is wider than the Responsive Breakpoint (set in Menu Theme Editor)
|
129 |
+
*
|
130 |
+
*/
|
131 |
plugin.isDesktopView = function() {
|
132 |
return $(window).width() > plugin.settings.breakpoint;
|
133 |
+
};
|
134 |
+
|
135 |
|
136 |
+
/**
|
137 |
+
* Determine whether (if at all) to hide open sibling panels, and how those panels
|
138 |
+
* should be closed.
|
139 |
+
*/
|
140 |
plugin.hideOpenSiblings = function() {
|
141 |
// desktops, horizontal
|
142 |
+
if ( plugin.isDesktopView() && ( $menu.hasClass("mega-menu-horizontal") || $menu.hasClass("mega-menu-vertical") ) ) {
|
143 |
+
return "immediately";
|
144 |
}
|
145 |
|
146 |
// mobile, keyboard navigation
|
147 |
+
if ( ! plugin.isDesktopView() && $menu.hasClass("mega-keyboard-navigation") ) {
|
148 |
+
return "animated";
|
149 |
}
|
150 |
|
151 |
+
if ( plugin.settings.vertical_behaviour === "accordion" ) {
|
152 |
+
return "animated";
|
153 |
}
|
|
|
154 |
|
155 |
+
return false;
|
156 |
+
};
|
157 |
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Display a single panel. Also handles closing of panels that are currently open and need to be closed.
|
161 |
+
*/
|
162 |
+
plugin.showPanel = function(anchor) {
|
163 |
+
if ( !plugin.isDesktopView() && anchor.parent().hasClass("mega-hide-sub-menu-on-mobile") ) {
|
164 |
return;
|
165 |
}
|
166 |
|
167 |
+
// hide open sibling panels. Never hide sibling panels on mobile view
|
168 |
switch( plugin.hideOpenSiblings() ) {
|
169 |
+
case "immediately":
|
170 |
plugin.hideSiblingPanels(anchor, true);
|
171 |
break;
|
172 |
+
case "animated":
|
173 |
plugin.hideSiblingPanels(anchor, false);
|
174 |
break;
|
175 |
}
|
176 |
|
177 |
// apply dynamic width and sub menu position
|
178 |
+
if ( anchor.parent().hasClass("mega-menu-megamenu") && $(plugin.settings.panel_width).length ) {
|
179 |
var submenu_offset = $menu.offset();
|
180 |
var target_offset = $(plugin.settings.panel_width).offset();
|
181 |
|
182 |
+
anchor.siblings(".mega-sub-menu").css({
|
183 |
width: $(plugin.settings.panel_width).outerWidth(),
|
184 |
left: (target_offset.left - submenu_offset.left) + "px"
|
185 |
});
|
186 |
}
|
187 |
|
|
|
188 |
// apply inner width to sub menu by adding padding to the left and right of the mega menu
|
189 |
+
if ( anchor.parent().hasClass("mega-menu-megamenu") && plugin.settings.panel_inner_width && plugin.settings.panel_inner_width.length > 0 ) {
|
190 |
+
var target_width = 0;
|
191 |
|
192 |
if ( $(plugin.settings.panel_inner_width).length ) {
|
193 |
// jQuery selector
|
194 |
+
target_width = parseInt($(plugin.settings.panel_inner_width).width(), 10);
|
195 |
} else {
|
196 |
+
// we"re using a pixel width
|
197 |
+
target_width = parseInt(plugin.settings.panel_inner_width, 10);
|
198 |
}
|
199 |
|
200 |
+
var submenu_width = parseInt(anchor.siblings(".mega-sub-menu").innerWidth(), 10);
|
201 |
|
202 |
if ( (target_width > 0) && (target_width < submenu_width) ) {
|
203 |
+
anchor.siblings(".mega-sub-menu").css({
|
204 |
+
"paddingLeft": (submenu_width - target_width) / 2 + "px",
|
205 |
+
"paddingRight": (submenu_width - target_width) / 2 + "px"
|
206 |
});
|
207 |
}
|
208 |
}
|
209 |
|
210 |
+
// apply jQuery transition (only if the effect is set to "slide", other transitions are CSS based)
|
211 |
if ( megamenu.effect[plugin.settings.effect] ) {
|
212 |
+
var effect = megamenu.effect[plugin.settings.effect]["in"];
|
213 |
var speed = plugin.settings.effect_speed;
|
214 |
|
215 |
if (effect.css) {
|
216 |
+
anchor.siblings(".mega-sub-menu").css(effect.css);
|
217 |
}
|
218 |
|
219 |
if (effect.animate) {
|
220 |
+
anchor.siblings(".mega-sub-menu").animate(effect.animate, speed, "swing", function() {
|
221 |
+
$(this).css("display", "");
|
222 |
});
|
223 |
}
|
224 |
}
|
225 |
|
226 |
+
anchor.parent().addClass("mega-toggle-on").triggerHandler("open_panel");
|
227 |
};
|
228 |
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Open sub menus on click
|
232 |
+
*/
|
233 |
var openOnClick = function() {
|
234 |
// hide menu when clicked away from
|
235 |
+
$(document).on("click touchstart", function(event) {
|
236 |
+
if ( ( plugin.settings.document_click === "collapse" ) && ! $(event.target).closest(".mega-menu li").length && plugin.isDesktopView() ) {
|
237 |
plugin.hideAllPanels();
|
238 |
}
|
239 |
});
|
240 |
|
241 |
+
$("li.mega-menu-megamenu.mega-menu-item-has-children > a, li.mega-menu-flyout.mega-menu-item-has-children > a, li.mega-menu-flyout li.mega-menu-item-has-children > a", menu).on({
|
242 |
click: function(e) {
|
|
|
243 |
// all clicks on parent items when sub menu is hidden on mobile
|
244 |
+
if ( ! plugin.isDesktopView() && $(this).parent().hasClass("mega-hide-sub-menu-on-mobile") ) {
|
245 |
return;
|
246 |
}
|
247 |
|
248 |
// check for second click
|
249 |
+
if ( plugin.settings.second_click === "go" || $(this).parent().hasClass("mega-click-click-go") ) {
|
250 |
if ( ! $(this).parent().hasClass("mega-toggle-on") ) {
|
251 |
e.preventDefault();
|
252 |
plugin.showPanel($(this));
|
264 |
});
|
265 |
};
|
266 |
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Open sub menus on hover
|
270 |
+
*/
|
271 |
var openOnHover = function() {
|
272 |
+
$("li.mega-menu-item-has-children", menu).not("li.mega-menu-megamenu li.mega-menu-item-has-children", menu).hover(
|
273 |
+
function() {
|
274 |
+
plugin.showPanel($(this).children("a"));
|
275 |
+
}, function() {
|
276 |
+
if ($(this).hasClass("mega-toggle-on")) {
|
277 |
+
plugin.hidePanel($(this).children("a"), false);
|
278 |
+
}
|
279 |
+
}
|
280 |
+
);
|
281 |
+
};
|
282 |
|
283 |
+
/**
|
284 |
+
* Open sub menus on hoverIntent
|
285 |
+
*/
|
286 |
+
var openOnHoverIntent = function() {
|
287 |
+
$("li.mega-menu-item-has-children", menu).not("li.mega-menu-megamenu li.mega-menu-item-has-children", menu).hoverIntent({
|
288 |
over: function () {
|
289 |
+
plugin.showPanel($(this).children("a"));
|
290 |
},
|
291 |
out: function () {
|
292 |
if ($(this).hasClass("mega-toggle-on")) {
|
293 |
+
plugin.hidePanel($(this).children("a"), false);
|
294 |
}
|
295 |
},
|
296 |
timeout: megamenu.timeout,
|
297 |
interval: megamenu.interval
|
298 |
});
|
|
|
299 |
};
|
300 |
|
301 |
+
/**
|
302 |
+
* Handle keyboard navigation of the menu. Highlight focused items.
|
303 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
plugin.keyboard_navigation = function() {
|
305 |
var tab_key = 9;
|
306 |
var escape_key = 27;
|
307 |
|
308 |
+
$("body").on("keyup", function(e) {
|
309 |
var keyCode = e.keyCode || e.which;
|
310 |
|
311 |
+
if (keyCode === escape_key) {
|
312 |
+
$menu.removeClass("mega-keyboard-navigation");
|
313 |
plugin.hideAllPanels();
|
314 |
}
|
315 |
|
316 |
+
if ( $menu.hasClass("mega-keyboard-navigation") && ! $(event.target).closest(".mega-menu li").length ) {
|
317 |
+
$menu.removeClass("mega-keyboard-navigation");
|
318 |
plugin.hideAllPanels();
|
319 |
}
|
320 |
});
|
321 |
|
322 |
+
$menu.parent().on("keyup", function(e) {
|
323 |
var keyCode = e.keyCode || e.which;
|
324 |
var active_link = $(e.target);
|
325 |
|
326 |
+
if (keyCode === tab_key) {
|
327 |
+
$menu.addClass("mega-keyboard-navigation");
|
328 |
|
329 |
+
if ( active_link.parent().hasClass("mega-menu-item-has-children") ) {
|
330 |
// menu item with sub menu
|
331 |
plugin.showPanel(active_link);
|
332 |
+
} else if ( active_link.parent().parent().hasClass("mega-menu") ) {
|
333 |
// top level item with no children
|
334 |
plugin.hideAllPanels();
|
335 |
}
|
336 |
|
337 |
+
if ( active_link.hasClass("mega-menu-toggle") ) {
|
338 |
+
active_link.toggleClass("mega-menu-open");
|
339 |
}
|
340 |
}
|
341 |
});
|
342 |
+
};
|
|
|
|
|
|
|
343 |
|
|
|
344 |
|
345 |
+
/**
|
346 |
+
* Remove all events from mega menu
|
347 |
+
*/
|
348 |
+
plugin.unbindEvents = function() {
|
349 |
+
$("ul.mega-sub-menu, li.mega-menu-item, a.mega-menu-link", menu).unbind();
|
350 |
+
};
|
351 |
|
|
|
352 |
|
353 |
+
/**
|
354 |
+
* Bind events to the menu items to allow it to be opened on click, hover or hover intent.
|
355 |
+
* The event will always be "click" when a touch screen is detected, or the current view is "mobile"
|
356 |
+
*/
|
357 |
+
plugin.bindEvents = function() {
|
358 |
+
if (isTouchDevice() || plugin.settings.event === "click" || ! plugin.isDesktopView() ) {
|
359 |
openOnClick();
|
360 |
+
} else if (plugin.settings.event === "hover_intent") {
|
361 |
+
openOnHoverIntent();
|
362 |
} else {
|
363 |
openOnHover();
|
364 |
}
|
365 |
+
};
|
366 |
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Monitor the width of the browser so we can tell when the browser has been resized to the point
|
370 |
+
* where the mobile menu is displayed, and vice versa
|
371 |
+
*/
|
372 |
+
plugin.monitorView = function() {
|
373 |
+
if (plugin.isDesktopView()) {
|
374 |
+
$menu.data("view", "desktop");
|
375 |
} else {
|
376 |
+
$menu.data("view", "mobile");
|
377 |
+
plugin.switchToMobile();
|
378 |
}
|
379 |
|
380 |
+
plugin.checkWidth();
|
381 |
|
382 |
$(window).resize(function() {
|
383 |
+
plugin.checkWidth();
|
384 |
});
|
385 |
+
};
|
386 |
+
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Monitor the width of the browser and call functions when menu switches between desktop and mobile view
|
390 |
+
*/
|
391 |
+
plugin.checkWidth = function() {
|
392 |
+
if ( $(window).width() <= plugin.settings.breakpoint && $menu.data("view") === "desktop" ) {
|
393 |
+
$menu.data("view", "mobile");
|
394 |
+
plugin.switchToMobile();
|
395 |
+
}
|
396 |
+
|
397 |
+
if ( $(window).width() >= plugin.settings.breakpoint && $menu.data("view") === "mobile" ) {
|
398 |
+
$menu.data("view", "desktop");
|
399 |
+
plugin.switchToDesktop();
|
400 |
+
}
|
401 |
+
};
|
402 |
+
|
403 |
+
/**
|
404 |
+
* Reverse right aligned menu items so that they appear in the same order on mobile as they do on desktop
|
405 |
+
*/
|
406 |
+
plugin.reverseRightAlignedItems = function() {
|
407 |
+
$menu.append($menu.children("li.mega-item-align-right").get().reverse());
|
408 |
+
};
|
409 |
+
|
410 |
|
411 |
+
/**
|
412 |
+
* Called when the menu view loads in mobile, or switches from desktop to mobile
|
413 |
+
*/
|
414 |
+
plugin.switchToMobile = function() {
|
415 |
+
plugin.unbindEvents();
|
416 |
+
plugin.bindEvents();
|
417 |
+
plugin.reverseRightAlignedItems();
|
418 |
+
};
|
419 |
+
|
420 |
+
|
421 |
+
/**
|
422 |
+
* Called when the menu view switches from mobile to desktop
|
423 |
+
*/
|
424 |
+
plugin.switchToDesktop = function() {
|
425 |
+
plugin.unbindEvents();
|
426 |
+
plugin.bindEvents();
|
427 |
+
plugin.reverseRightAlignedItems();
|
428 |
+
};
|
429 |
+
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Initialise the mega menu
|
433 |
+
*/
|
434 |
+
plugin.init = function() {
|
435 |
+
|
436 |
+
$menu.triggerHandler("before_mega_menu_init");
|
437 |
+
|
438 |
+
plugin.settings = $.extend({}, defaults, options);
|
439 |
+
|
440 |
+
$menu.removeClass("mega-no-js");
|
441 |
+
|
442 |
+
// mobile menu
|
443 |
+
$menu.siblings(".mega-menu-toggle").on("click", function(e) {
|
444 |
+
if ( $(e.target).is(".mega-menu-toggle-block, .mega-menu-toggle") ) {
|
445 |
+
$(this).toggleClass("mega-menu-open");
|
446 |
+
}
|
447 |
+
});
|
448 |
+
|
449 |
+
plugin.unbindEvents();
|
450 |
+
plugin.bindEvents();
|
451 |
+
plugin.monitorView();
|
452 |
plugin.keyboard_navigation();
|
453 |
|
454 |
+
$menu.triggerHandler("after_mega_menu_init");
|
455 |
+
|
456 |
};
|
457 |
|
458 |
plugin.init();
|
461 |
|
462 |
$.fn.maxmegamenu = function(options) {
|
463 |
return this.each(function() {
|
464 |
+
if (undefined === $(this).data("maxmegamenu")) {
|
465 |
var plugin = new $.maxmegamenu(this, options);
|
466 |
+
$(this).data("maxmegamenu", plugin);
|
467 |
}
|
468 |
});
|
469 |
};
|
473 |
$(".mega-menu").maxmegamenu();
|
474 |
});
|
475 |
|
|
|
476 |
})(jQuery);
|
js/settings.js
CHANGED
@@ -90,6 +90,11 @@ jQuery(function ($) {
|
|
90 |
select.next().children('.' + selected).show();
|
91 |
});
|
92 |
|
|
|
|
|
|
|
|
|
|
|
93 |
$('form.theme_editor label[data-validation]').each(function() {
|
94 |
var label = $(this);
|
95 |
var validation = label.attr('data-validation');
|
90 |
select.next().children('.' + selected).show();
|
91 |
});
|
92 |
|
93 |
+
// validate inputs once the user moves to the next setting
|
94 |
+
$( window ).scroll(function() {
|
95 |
+
$('.theme_editor input:focus').blur();
|
96 |
+
});
|
97 |
+
|
98 |
$('form.theme_editor label[data-validation]').each(function() {
|
99 |
var label = $(this);
|
100 |
var validation = label.attr('data-validation');
|
megamenu.php
CHANGED
@@ -67,6 +67,7 @@ final class Mega_Menu {
|
|
67 |
add_filter( 'megamenu_nav_menu_objects_before', array( $this, 'setup_menu_items' ), 5, 2 );
|
68 |
add_filter( 'megamenu_nav_menu_objects_after', array( $this, 'reorder_menu_items_within_megamenus' ), 6, 2 );
|
69 |
add_filter( 'megamenu_nav_menu_objects_after', array( $this, 'apply_classes_to_menu_items' ), 7, 2 );
|
|
|
70 |
|
71 |
add_filter( 'megamenu_nav_menu_css_class', array( $this, 'prefix_menu_classes' ) );
|
72 |
|
@@ -101,6 +102,28 @@ final class Mega_Menu {
|
|
101 |
}
|
102 |
|
103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
/**
|
105 |
* Add custom actions to allow enqueuing scripts on specific pages
|
106 |
*
|
@@ -278,7 +301,7 @@ final class Mega_Menu {
|
|
278 |
*/
|
279 |
private function plugin_classes() {
|
280 |
|
281 |
-
|
282 |
'mega_menu_walker' => MEGAMENU_PATH . 'classes/walker.class.php',
|
283 |
'mega_menu_widget_manager' => MEGAMENU_PATH . 'classes/widget-manager.class.php',
|
284 |
'mega_menu_menu_item_manager' => MEGAMENU_PATH . 'classes/menu-item-manager.class.php',
|
@@ -290,6 +313,7 @@ final class Mega_Menu {
|
|
290 |
'scssc' => MEGAMENU_PATH . 'classes/scssc.inc.php'
|
291 |
);
|
292 |
|
|
|
293 |
}
|
294 |
|
295 |
|
@@ -359,6 +383,22 @@ final class Mega_Menu {
|
|
359 |
$return[] = 'mega-' . $class;
|
360 |
}
|
361 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
return $return;
|
363 |
}
|
364 |
|
@@ -733,17 +773,28 @@ final class Mega_Menu {
|
|
733 |
$second_click = $menu_settings['second_click'];
|
734 |
}
|
735 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
736 |
$wrap_attributes = apply_filters("megamenu_wrap_attributes", array(
|
737 |
"id" => '%1$s',
|
738 |
"class" => '%2$s mega-no-js',
|
739 |
-
"data-event" =>
|
740 |
"data-effect" => $effect,
|
741 |
"data-effect-speed" => isset( $menu_settings['effect_speed'] ) ? $menu_settings['effect_speed'] : '200',
|
742 |
"data-panel-width" => preg_match('/^\d/', $menu_theme['panel_width']) !== 1 ? $menu_theme['panel_width'] : '',
|
743 |
"data-panel-inner-width" => substr( $menu_theme['panel_inner_width'], -1 ) !== '%' ? $menu_theme['panel_inner_width'] : '',
|
744 |
"data-second-click" => $second_click,
|
745 |
"data-document-click" => 'collapse',
|
746 |
-
"data-reverse-mobile-items" => 'true',
|
747 |
"data-vertical-behaviour" => $vertical_behaviour,
|
748 |
"data-breakpoint" => absint( $menu_theme['responsive_breakpoint'] )
|
749 |
), $menu_id, $menu_settings, $settings, $current_theme_location );
|
67 |
add_filter( 'megamenu_nav_menu_objects_before', array( $this, 'setup_menu_items' ), 5, 2 );
|
68 |
add_filter( 'megamenu_nav_menu_objects_after', array( $this, 'reorder_menu_items_within_megamenus' ), 6, 2 );
|
69 |
add_filter( 'megamenu_nav_menu_objects_after', array( $this, 'apply_classes_to_menu_items' ), 7, 2 );
|
70 |
+
add_filter( 'body_class', array($this, 'add_megamenu_body_classes'), 10, 1);
|
71 |
|
72 |
add_filter( 'megamenu_nav_menu_css_class', array( $this, 'prefix_menu_classes' ) );
|
73 |
|
102 |
}
|
103 |
|
104 |
|
105 |
+
/**
|
106 |
+
* Add a body class for each active mega menu location.
|
107 |
+
*
|
108 |
+
* @since 2.2.3
|
109 |
+
* @param array $classes
|
110 |
+
* @return array
|
111 |
+
*/
|
112 |
+
public function add_megamenu_body_classes( $classes ) {
|
113 |
+
$locations = get_nav_menu_locations();
|
114 |
+
|
115 |
+
if ( count( $locations ) ) {
|
116 |
+
foreach ( $locations as $location => $id ) {
|
117 |
+
if ( has_nav_menu( $location ) && max_mega_menu_is_enabled( $location ) ) {
|
118 |
+
$classes[] = 'mega-menu-' . str_replace( "_", "-", $location );
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
return $classes;
|
124 |
+
}
|
125 |
+
|
126 |
+
|
127 |
/**
|
128 |
* Add custom actions to allow enqueuing scripts on specific pages
|
129 |
*
|
301 |
*/
|
302 |
private function plugin_classes() {
|
303 |
|
304 |
+
$classes = array(
|
305 |
'mega_menu_walker' => MEGAMENU_PATH . 'classes/walker.class.php',
|
306 |
'mega_menu_widget_manager' => MEGAMENU_PATH . 'classes/widget-manager.class.php',
|
307 |
'mega_menu_menu_item_manager' => MEGAMENU_PATH . 'classes/menu-item-manager.class.php',
|
313 |
'scssc' => MEGAMENU_PATH . 'classes/scssc.inc.php'
|
314 |
);
|
315 |
|
316 |
+
return $classes;
|
317 |
}
|
318 |
|
319 |
|
383 |
$return[] = 'mega-' . $class;
|
384 |
}
|
385 |
|
386 |
+
|
387 |
+
/*
|
388 |
+
* @todo: Add a setting to enable/disable this.
|
389 |
+
* Suddendly adding 'new' classes to menu items could screw up menu styling for some users
|
390 |
+
// add in custom classes, sans 'mega-' prefix
|
391 |
+
foreach ( $classes as $class ) {
|
392 |
+
|
393 |
+
// custom classes are added before the 'menu-item' class
|
394 |
+
if ( $class == 'menu-item' ) {
|
395 |
+
break;
|
396 |
+
}
|
397 |
+
|
398 |
+
$return[] = $class;
|
399 |
+
}
|
400 |
+
*/
|
401 |
+
|
402 |
return $return;
|
403 |
}
|
404 |
|
773 |
$second_click = $menu_settings['second_click'];
|
774 |
}
|
775 |
|
776 |
+
$event = 'hover_intent';
|
777 |
+
|
778 |
+
if ( isset( $menu_settings['event'] ) ) {
|
779 |
+
if ( $menu_settings['event'] == 'hover' ) {
|
780 |
+
$event = 'hover_intent';
|
781 |
+
} elseif ( $menu_settings['event'] == 'hover_' ) {
|
782 |
+
$event = 'hover';
|
783 |
+
} else {
|
784 |
+
$event = $menu_settings['event'];
|
785 |
+
}
|
786 |
+
}
|
787 |
+
|
788 |
$wrap_attributes = apply_filters("megamenu_wrap_attributes", array(
|
789 |
"id" => '%1$s',
|
790 |
"class" => '%2$s mega-no-js',
|
791 |
+
"data-event" => $event,
|
792 |
"data-effect" => $effect,
|
793 |
"data-effect-speed" => isset( $menu_settings['effect_speed'] ) ? $menu_settings['effect_speed'] : '200',
|
794 |
"data-panel-width" => preg_match('/^\d/', $menu_theme['panel_width']) !== 1 ? $menu_theme['panel_width'] : '',
|
795 |
"data-panel-inner-width" => substr( $menu_theme['panel_inner_width'], -1 ) !== '%' ? $menu_theme['panel_inner_width'] : '',
|
796 |
"data-second-click" => $second_click,
|
797 |
"data-document-click" => 'collapse',
|
|
|
798 |
"data-vertical-behaviour" => $vertical_behaviour,
|
799 |
"data-breakpoint" => absint( $menu_theme['responsive_breakpoint'] )
|
800 |
), $menu_id, $menu_settings, $settings, $current_theme_location );
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: megamenu
|
|
3 |
Tags: menu, megamenu, mega menu, navigation, widget, dropdown menu, drag and drop, mobile, responsive, retina, theme editor, widget, shortcode, sidebar, icons, dashicons
|
4 |
Requires at least: 3.8
|
5 |
Tested up to: 4.6
|
6 |
-
Stable tag: 2.2.3
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -65,17 +65,17 @@ Translations:
|
|
65 |
|
66 |
Troubleshooting:
|
67 |
|
68 |
-
https://www.maxmegamenu.com/
|
69 |
|
70 |
Getting started:
|
71 |
|
72 |
-
https://www.maxmegamenu.com/documentation/
|
73 |
|
74 |
Not working with your theme?
|
75 |
Mobile menu not working?
|
76 |
Multiple mobile menu toggle icons?
|
77 |
|
78 |
-
https://www.maxmegamenu.com/documentation/
|
79 |
|
80 |
== Installation ==
|
81 |
|
@@ -83,7 +83,7 @@ https://www.maxmegamenu.com/documentation/faqs/removing-residual-styling/
|
|
83 |
1. Search for "Max Mega Menu"
|
84 |
1. Click "Install"
|
85 |
|
86 |
-
https://www.maxmegamenu.com/documentation/
|
87 |
|
88 |
== Screenshots ==
|
89 |
|
3 |
Tags: menu, megamenu, mega menu, navigation, widget, dropdown menu, drag and drop, mobile, responsive, retina, theme editor, widget, shortcode, sidebar, icons, dashicons
|
4 |
Requires at least: 3.8
|
5 |
Tested up to: 4.6
|
6 |
+
Stable tag: 2.2.3.1
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
65 |
|
66 |
Troubleshooting:
|
67 |
|
68 |
+
https://www.maxmegamenu.com/articles/troubleshooting/
|
69 |
|
70 |
Getting started:
|
71 |
|
72 |
+
https://www.maxmegamenu.com/documentation/installation/
|
73 |
|
74 |
Not working with your theme?
|
75 |
Mobile menu not working?
|
76 |
Multiple mobile menu toggle icons?
|
77 |
|
78 |
+
https://www.maxmegamenu.com/documentation/removing-residual-styling/
|
79 |
|
80 |
== Installation ==
|
81 |
|
83 |
1. Search for "Max Mega Menu"
|
84 |
1. Click "Install"
|
85 |
|
86 |
+
https://www.maxmegamenu.com/documentation/installation/
|
87 |
|
88 |
== Screenshots ==
|
89 |
|