summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmburnz2013-03-06 21:36:30 (GMT)
committer jmburnz2013-03-06 21:36:30 (GMT)
commitee4c7724dd9595b9e117e8f36f1f87d818c25023 (patch)
tree14912eb67d107550e35d74bedfe4ee8d53705219
parent620c2e68c16c95ea432a8c707fa4ee316cb94390 (diff)
Add new features for menu toggles - allow users to chose which menus and regions
-rwxr-xr-xat_core/inc/forms/at_core.submit.menutoggle.inc6
-rwxr-xr-xat_core/inc/forms/settings.menutoggle.inc96
-rwxr-xr-xat_core/inc/preprocess.inc53
-rwxr-xr-xat_core/inc/process.inc8
-rwxr-xr-xat_core/inc/theme.inc2
-rwxr-xr-xat_core/scripts/menu-toggle.js3
-rwxr-xr-xat_subtheme/css/global.styles.css24
-rwxr-xr-xat_subtheme/sass/global.styles.scss24
8 files changed, 190 insertions, 26 deletions
diff --git a/at_core/inc/forms/at_core.submit.menutoggle.inc b/at_core/inc/forms/at_core.submit.menutoggle.inc
index 604dd91..2549a96 100755
--- a/at_core/inc/forms/at_core.submit.menutoggle.inc
+++ b/at_core/inc/forms/at_core.submit.menutoggle.inc
@@ -19,12 +19,12 @@ function at_core_submit_menu_toggle($values, $theme_name, $path) {
}
$menu_toggle_css = array();
- $menu_toggle_css_active = '.at-mt .at-menu-toggle h2{position:static;top:0}.at-mt #menu-toggle{display:none}.at-mt #menu-toggle ul li,.at-mt #menu-toggle ul li a{display:block;float:none}';
- $menu_toggle_css_inactive = '.at-mt .at-menu-toggle h2{position:absolute;top:-999999em}.at-mt #menu-toggle{display:block !important}';
+ $menu_toggle_css_active = '.at-mt .at-menu-toggle-button {position:static;top:0} .at-mt .menu-toggle{display:none} .at-mt .menu-toggle ul li,.at-mt .menu-toggle ul li a{display:block;float:none}';
+ $menu_toggle_css_inactive = '.at-mt .at-menu-toggle-button {position:absolute;top:-99999em} .at-mt .menu-toggle {display:block !important}';
// We need extra overrides for superfish if the module is active
if (module_exists('superfish')) {
- $menu_toggle_superfish_css = '.at-mt #menu-toggle .sf-menu{float:none;margin:0;height:auto}.at-mt #menu-toggle .sf-menu ul,.at-mt #menu-toggle .sf-menu li {margin:0;position:relative;top:0;display:block;float:none;clear:both;width:100%!important;left:0!important}';
+ $menu_toggle_superfish_css = '.at-mt #menu-toggle .sf-menu {float:none;margin:0;height:auto} .at-mt #menu-toggle .sf-menu ul,.at-mt #menu-toggle .sf-menu li {margin:0;position:relative;top:0;display:block;float:none;clear:both;width:100%!important;left:0!important}';
}
else {
$menu_toggle_superfish_css = '';
diff --git a/at_core/inc/forms/settings.menutoggle.inc b/at_core/inc/forms/settings.menutoggle.inc
index 2480be8..355dee5 100755
--- a/at_core/inc/forms/settings.menutoggle.inc
+++ b/at_core/inc/forms/settings.menutoggle.inc
@@ -16,7 +16,7 @@ function at_core_menu_toggle_form(&$form) {
$form['at']['menu-toggle']['breakpoints'] = array(
'#type' => 'fieldset',
'#title' => t('Breakpoints'),
- '#description' => t('<strong>Select additional devices/breakpoints you want to use the toggle menu for.</strong>'),
+ '#description' => t('<h3>Select Additional Device Breakpoints</h3>'),
);
$form['at']['menu-toggle']['breakpoints']['menu_toggle_tablet_portrait'] = array(
@@ -33,16 +33,98 @@ function at_core_menu_toggle_form(&$form) {
'#default_value' => at_get_setting('menu_toggle_tablet_landscape') ? at_get_setting('menu_toggle_tablet_landscape') : 0,
);
+
+ // Regions and Menus
+ $form['at']['menu-toggle']['menus-regions'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Menus'),
+ '#description' => t('<h3>Select Menus and/or Regions</h3>'),
+ );
+
+ // Core menus
+ $form['at']['menu-toggle']['menus-regions']['core'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Menus'),
+ '#description' => t('<strong>Drupal core standard menus (variables printed in page.tpl.php).</strong>'),
+ );
+ // Core main menu
+ $form['at']['menu-toggle']['menus-regions']['core']['menu_toggle_main_menu'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Main Menu'),
+ '#default_value' => at_get_setting('menu_toggle_main_menu'),
+ );
+ // Core secondary menu
+ $form['at']['menu-toggle']['menus-regions']['core']['menu_toggle_secondary_menu'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Secondary menu'),
+ '#default_value' => at_get_setting('menu_toggle_secondary_menu'),
+ );
+
+ // Regions
+ $form['at']['menu-toggle']['menus-regions']['regions'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Regions'),
+ '#description' => t('<strong>Regions to apply menu toggles - each menu block in these regions will get a toggle.</strong>'),
+ );
+
+ // Region - leaderboard
+ $form['at']['menu-toggle']['menus-regions']['regions']['menu_toggle_leaderboard'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Leaderboard'),
+ '#default_value' => at_get_setting('menu_toggle_leaderboard'),
+ );
+ // Region - header region
+ $form['at']['menu-toggle']['menus-regions']['regions']['menu_toggle_header'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Header'),
+ '#default_value' => at_get_setting('menu_toggle_header'),
+ );
+ // Region - menu bar
+ $form['at']['menu-toggle']['menus-regions']['regions']['menu_toggle_menu_bar'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Menu Bar'),
+ '#default_value' => at_get_setting('menu_toggle_menu_bar'),
+ );
+
// Customize toggle link text
- $form['at']['menu-toggle']['main-menu-title'] = array(
+ $form['at']['menu-toggle']['titles'] = array(
'#type' => 'fieldset',
'#title' => t('Link Text'),
- '#description' => t('<strong>Customize the text used in the menu link.</strong>'),
+ '#description' => t('<h3>Customize Menu Titles</h3><p>These apply to the Drupal core main and secondary menus (printed in page.tpl.php). If you are using a block in a region you need to change the block title for your menu block (even if it\'s the Main menu block).</p>'),
);
- $form['at']['menu-toggle']['main-menu-title']['menu_button_link_text'] = array(
+ // Main menu title
+ $form['at']['menu-toggle']['titles']['menu_toggle_main_menu_title'] = array(
'#type' => 'textfield',
- '#title' => t('Link Text'),
- '#description' => t('This applies if you are using the standard Drupal main menu. If you are using a block in the Menu Bar region you need to change the block title for your menu block (even if it\'s the Main menu block).'),
- '#default_value' => at_get_setting('menu_button_link_text') ? at_get_setting('menu_button_link_text') : t('Main menu'),
+ '#title' => t('Main menu title'),
+ '#default_value' => at_get_setting('menu_toggle_main_menu_title') ? at_get_setting('menu_toggle_main_menu_title') : t('Main menu'),
+ );
+ // Secondary menu title
+ $form['at']['menu-toggle']['titles']['menu_toggle_secondary_menu_title'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Secondary menu title'),
+ '#default_value' => at_get_setting('menu_toggle_secondary_menu_title') ? at_get_setting('menu_toggle_secondary_menu_title') : t('User menu'),
);
}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/at_core/inc/preprocess.inc b/at_core/inc/preprocess.inc
index 14c1869..cce40ab 100755
--- a/at_core/inc/preprocess.inc
+++ b/at_core/inc/preprocess.inc
@@ -406,7 +406,8 @@ function adaptivetheme_preprocess_block(&$vars) {
$vars['tag'] = 'nav';
array_unshift($vars['theme_hook_suggestions'], 'block__menu');
}
- $nav_modules = array('superfish', 'nice_menus', 'menu_block');
+
+ $nav_modules = array('superfish', 'nice_menus', 'menu_block', 'menu');
if (in_array($vars['block']->module, $nav_modules)) {
$vars['tag'] = 'nav';
array_unshift($vars['theme_hook_suggestions'], 'block__menu');
@@ -414,19 +415,29 @@ function adaptivetheme_preprocess_block(&$vars) {
// The menu bar region gets special treatment for the block template
if ($vars['block']->region === 'menu_bar') {
- // They are always menu blocks, right?
- $vars['tag'] = 'nav';
+ $vars['classes_array'][] = 'menu-wrapper';
+ $vars['classes_array'][] = 'menu-bar-wrapper';
+ $vars['classes_array'][] = 'clearfix';
+ $vars['title_attributes_array']['class'][] = 'element-invisible';
}
// The menu bar region gets special treatment for the block template
- if ($vars['block']->region === 'menu_bar') {
- // Hide title with element invisible unless the menu toggle is active
- if (at_get_setting('enable_menu_toggle', $theme_name) === 0) {
- $vars['title_attributes_array']['class'][] = 'element-invisible';
+ if (at_get_setting('enable_menu_toggle', $theme_name) === 1) {
+ if (at_get_setting('menu_toggle_menu_bar', $theme_name) === 1) {
+ if ($vars['block']->region === 'menu_bar') {
+ $vars['classes_array'][] = 'at-menu-toggle';
+ }
+ }
+
+ if (at_get_setting('menu_toggle_leaderboard', $theme_name) === 1 && $vars['block']->region === 'leaderboard') {
+ $vars['classes_array'][] = 'at-menu-toggle';
+ $vars['classes_array'][] = 'clearfix';
+ }
+
+ if (at_get_setting('menu_toggle_header', $theme_name) === 1 && $vars['block']->region === 'header') {
+ $vars['classes_array'][] = 'at-menu-toggle';
+ $vars['classes_array'][] = 'clearfix';
}
- $vars['classes_array'][] = 'menu-wrapper';
- $vars['classes_array'][] = 'menu-bar-wrapper';
- $vars['classes_array'][] = 'clearfix';
}
// Add extra classes if required
@@ -468,8 +479,7 @@ function adaptivetheme_preprocess_block(&$vars) {
// Give our block titles and content some additional class
$vars['title_attributes_array']['class'][] = 'block-title';
- $vars['content_attributes_array']['class'][] = 'block-content';
- $vars['content_attributes_array']['class'][] = 'content';
+ $vars['content_attributes_array']['class'] = array('block-content', 'content');
// Add Aria Roles via attributes
switch ($vars['block']->module) {
@@ -832,13 +842,30 @@ function adaptivetheme_preprocess_aggregator_item(&$vars) {
* Preprocess variables for adaptivtheme_menubar()
*/
function adaptivetheme_preprocess_menubar(&$vars) {
+ global $theme_key;
+ $theme_name = $theme_key;
+
$type = $vars['type'];
+
// menu bar id
$vars['menubar_id'] = $type . '-menu-bar';
// Add classes to the main wrapper
$vars['classes_array'] = array('nav', 'clearfix');
+
+ // Classes for toggle menus
+ if (at_get_setting('enable_menu_toggle', $theme_name) === 1) {
+ if (at_get_setting('menu_toggle_main_menu', $theme_name) === 1 && $type === 'primary') {
+ $vars['classes_array'][] = 'at-menu-toggle';
+ }
+ if (at_get_setting('menu_toggle_secondary_menu', $theme_name) === 1 && $type === 'secondary') {
+ $vars['classes_array'][] = 'at-menu-toggle';
+ }
+ }
+
// Add classes to the inner wrapper
- $vars['content_attributes_array']['class'] = array($type . '-menu-wrapper', 'menu-wrapper', 'clearfix');
+ $vars['content_attributes_array']['class'][] = $type . '-menu-wrapper';
+ $vars['content_attributes_array']['class'][] = 'menu-wrapper';
+ $vars['content_attributes_array']['class'][] = 'clearfix';
// Set aria role
$vars['content_attributes_array']['role'][] = 'navigation';
// Add suggstions per menu type
diff --git a/at_core/inc/process.inc b/at_core/inc/process.inc
index 4376c4d..3f1c95e 100755
--- a/at_core/inc/process.inc
+++ b/at_core/inc/process.inc
@@ -158,6 +158,12 @@ function adaptivetheme_process_block(&$vars) {
$vars['inner_suffix'] = '';
$vars['content_processed'] = $vars['content']; // remove the default wrapper
}
+ // Navigation or menu blocks get special treatment in these regions
+ if ($vars['block']->region === 'leaderboard' || $vars['block']->region === 'header') {
+ if ($vars['tag'] == 'nav') {
+ $vars['content_processed'] = $vars['content']; // remove the default wrapper
+ }
+ }
// Some blocks look bad with wrappers so we strip them
if ($vars['block']->region === 'content') {
@@ -170,6 +176,8 @@ function adaptivetheme_process_block(&$vars) {
$vars['inner_suffix'] = '';
}
+ //dsm($vars);
+
// Provide additional suggestions so the block__menu suggestion can be overridden easily
$vars['theme_hook_suggestions'][] = 'block__' . $vars['block']->region . '__' . $vars['block']->module;
$vars['theme_hook_suggestions'][] = 'block__' . $vars['block']->region . '__' . $vars['block']->delta;
diff --git a/at_core/inc/theme.inc b/at_core/inc/theme.inc
index 93f8a0b..8ccc270 100755
--- a/at_core/inc/theme.inc
+++ b/at_core/inc/theme.inc
@@ -43,7 +43,7 @@ function adaptivetheme_theme($existing, $type, $theme, $path) {
*/
function adaptivetheme_menubar($vars) {
- dsm($vars);
+ //dsm($vars);
$output = '';
$output .= '<div id="' . $vars['menubar_id'] . '" class="' . $vars['classes'] . '"' . $vars['attributes'] . '>';
diff --git a/at_core/scripts/menu-toggle.js b/at_core/scripts/menu-toggle.js
index 4f3564a..38ee53a 100755
--- a/at_core/scripts/menu-toggle.js
+++ b/at_core/scripts/menu-toggle.js
@@ -15,9 +15,8 @@
if (mtsTP == 'true') { breakpoints.push(bp3 + ':' + themeSettings[activeTheme]['media_query_settings']['tablet_portrait']); }
if (mtsTL == 'true') { breakpoints.push(bp4 + ':' + themeSettings[activeTheme]['media_query_settings']['tablet_portrait']); }
- $("#secondary-menu-bar, #primary-menu-bar, #menu-bar").addClass('at-menu-toggle');
$(".at-menu-toggle h2").removeClass('element-invisible').addClass('at-menu-toggle-button').wrapInner('<a href="#menu-toggle" class="at-menu-toggle-button-link" />');
- $(".at-menu-toggle nav > ul[class*=menu]:nth-of-type(1)").wrap('<div id="menu-toggle" />');
+ $(".at-menu-toggle ul[class*=menu]:nth-of-type(1)").wrap('<div class="menu-toggle" />');
!function(breakName, query){
diff --git a/at_subtheme/css/global.styles.css b/at_subtheme/css/global.styles.css
index 034501e..12d011a 100755
--- a/at_subtheme/css/global.styles.css
+++ b/at_subtheme/css/global.styles.css
@@ -600,6 +600,30 @@ ul.sf-menu a:active {
/* =============================================================================
+ * Menu Toggles
+ * ========================================================================== */
+
+.at-mt .at-menu-toggle,
+.at-mt .at-menu-toggle ul,
+.at-mt .at-menu-toggle ul.menu {
+ margin-top: 0;
+ margin-bottom: 0;
+ padding: 0;
+}
+
+.at-mt .at-menu-toggle-button {
+ margin: 0;
+}
+
+.at-mt .at-menu-toggle ul a {
+ padding: 0 10px;
+ white-space: nowrap;
+}
+
+
+
+
+/* =============================================================================
* Menus, usually blocks
* ========================================================================== */
diff --git a/at_subtheme/sass/global.styles.scss b/at_subtheme/sass/global.styles.scss
index 7583d8e..ab6fc04 100755
--- a/at_subtheme/sass/global.styles.scss
+++ b/at_subtheme/sass/global.styles.scss
@@ -685,6 +685,30 @@ ul.sf-menu {
/* =============================================================================
+ * Menu Toggles
+ * ========================================================================== */
+// .at-mt is a page class
+.at-mt {
+ .at-menu-toggle,
+ .at-menu-toggle ul,
+ .at-menu-toggle ul.menu {
+ margin-top: 0;
+ margin-bottom: 0;
+ padding: 0;
+ }
+
+ .at-menu-toggle-button {
+ margin: 0;
+ }
+
+ .at-menu-toggle ul a {
+ padding: 0 10px;
+ white-space: nowrap;
+ }
+}
+
+
+/* =============================================================================
* Menus, usually blocks
* ========================================================================== */