[gnome-web-www: 61/68] Make Foundation submenu visible only on /foundation subpages
- From: Tom Tryfonidis <tomtryf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-web-www: 61/68] Make Foundation submenu visible only on /foundation subpages
- Date: Tue, 24 Jan 2017 15:52:20 +0000 (UTC)
commit f112da555983dfcdf5e80a1de44b44cc5676ee63
Author: Tom Tryfonidis <tomtryf gnome org>
Date: Tue Jan 24 14:49:42 2017 +0200
Make Foundation submenu visible only on /foundation subpages
theme/functions.php | 1 +
theme/js/foundation-bar.js | 12 ++++++++++++
theme/js/template.js | 26 --------------------------
3 files changed, 13 insertions(+), 26 deletions(-)
---
diff --git a/theme/functions.php b/theme/functions.php
index aa2807f..0cba2d1 100644
--- a/theme/functions.php
+++ b/theme/functions.php
@@ -78,6 +78,7 @@ function gnomegrass_resources() {
// Common scripts
wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . '/js/bootstrap.min.js',
array('jquery'), null, true);
wp_enqueue_script( 'template', get_template_directory_uri() . '/js/template.js', array('jquery'), null,
true);
+ wp_enqueue_script( 'foundation', get_template_directory_uri() . '/js/foundation-bar.js',
array('jquery'), null, true);
// Common stylesheets
wp_enqueue_style('bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css');
diff --git a/theme/js/foundation-bar.js b/theme/js/foundation-bar.js
new file mode 100644
index 0000000..3436482
--- /dev/null
+++ b/theme/js/foundation-bar.js
@@ -0,0 +1,12 @@
+jQuery(document).ready(function($) {
+
+ // Check if active page is the Foundation page
+ // or if it's a subpage (children) of the Foundation (dropdown)
+ if( $('#menu-primary li.menu-item-has-children').hasClass('active') || $('#menu-primary
ul.dropdown-menu').children().hasClass('active')) {
+ // Keep submenu open
+ $('#menu-primary .dropdown').addClass('open');
+ // Make sure we have enough spacing under the submenu
+ $('html').addClass('menu-open');
+ $('.navbar').append('<span class="nav-bg"></span>');
+ }
+});
diff --git a/theme/js/template.js b/theme/js/template.js
index e28fdb5..856adc3 100644
--- a/theme/js/template.js
+++ b/theme/js/template.js
@@ -13,32 +13,6 @@ jQuery(document).ready(function($) {
}
- /* Foundation menu
- * ====================================================================== */
-
- // Don't let Bootstrap handle the dropdown menu
- $('#menu-primary .dropdown-toggle').removeAttr('data-toggle');
-
- $('#menu-primary .dropdown-toggle').on('click', function(e) {
-
- $('#menu-primary .dropdown').toggleClass('open');
- $('html').toggleClass('menu-open');
-
- if ($('#menu-primary .dropdown-menu').is(":visible")) {
- $('.navbar').append('<span class="nav-bg"></span>');
- } else {
- $('span.nav-bg').remove();
- }
- // Don't jump at the top of the page
- e.preventDefault()
- return false;
- });
-
- // Trigger click to keep the menu open on Foundation page
- if( $('.foundation-menu-item').hasClass('current-menu-parent') ) {
- $('#menu-primary .dropdown-toggle').trigger('click');
- }
-
/* Global search placeholder
* ====================================================================== */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]