From e48f18dbdccb63a2abfeae0b4c1d8afc6ebb9f1c Sun, 15 Jan 2012 12:42:18 +0100
From: Bram Goffings <bramgoffings@gmail.com>
Date: Sun, 15 Jan 2012 12:41:49 +0100
Subject: [PATCH] toolbar template

diff --git a/core/includes/common.inc b/core/includes/common.inc
index 2f14740..25fddad 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -6726,6 +6726,9 @@
     'links' => array(
       'variables' => array('links' => array(), 'attributes' => array('class' => array('links')), 'heading' => array()),
     ),
+    'nav' => array(
+      'variables' => array('links' => array(), 'attributes' => array('class' => array())),
+    ),
     'image' => array(
       // HTML 4 and XHTML 1.0 always require an alt attribute. The HTML 5 draft
       // allows the alt attribute to be omitted in some cases. Therefore,
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 0c955e8..0d517dc 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1655,6 +1655,69 @@
 }
 
 /**
+ * Returns HTML for a nav list.
+ *
+ * @param $variables
+ *   An associative array containing:
+ *   - links: An associative array of links to be themed. The key for each link
+ *     is used as its css class. Each link should be itself an array, with the
+ *     following elements:
+ *     - title: The link text.
+ *     - href: The link URL.
+ *     - html: (optional) Whether or not 'title' is HTML. If set, the title
+ *       will not be passed through check_plain().
+ *     - attributes: (optional) Attributes for the anchor. If element 'class' is
+ *       included, it must be an array of one or more class names.
+ *   - attributes: A keyed array of attributes for the nav containing the
+ *     list of links.
+ */
+function theme_nav($variables) {
+  global $language_url;
+  $links = $variables['links'];
+
+  // Add navigation role by default
+  $attributes = array('role' => 'navigation');
+  $attributes += $variables['attributes'];
+
+  $output = '';
+
+  if (count($links) > 0) {
+    $output = '<nav ' . drupal_attributes($attributes) . '>';
+
+    $i = 1;
+    foreach ($links as $key => $link) {
+      if (!isset($link['href'])) {
+        continue;
+      }
+
+      $class = array($key);
+      if ($i == 1) {
+        $class[] = 'first';
+      }
+      if ($i == count($links)) {
+        $class[] = 'last';
+      }
+
+      $link += array(
+        'html' => FALSE,
+        'attributes' => array()
+      );
+      $link['attributes'] += array('class' => array());
+      $link['attributes']['class'] = array_merge($class, $link['attributes']['class']);
+
+      // Pass in $link as $options, they share the same keys.
+      $output .= l($link['title'], $link['href'], $link);
+
+      $i++;
+    }
+    $output .= '</nav>';
+  }
+
+  return $output;
+}
+
+
+/**
  * Returns HTML for an image.
  *
  * @param $variables
diff --git a/core/modules/shortcut/shortcut-rtl.css b/core/modules/shortcut/shortcut-rtl.css
index 5dec957..166a219 100644
--- a/core/modules/shortcut/shortcut-rtl.css
+++ b/core/modules/shortcut/shortcut-rtl.css
@@ -1,35 +1,35 @@
 
-div#toolbar a#edit-shortcuts {
+#toolbar a#edit-shortcuts {
   position: absolute;
   left: 0;
   top: 0;
   padding: 5px 5px 5px 10px;
 }
-div#toolbar div.toolbar-shortcuts ul {
-  float: none;
+#toolbar .toolbar-shortcuts {
+  float: right;
   margin-right: 5px;
   margin-left: 10em;
 }
-div#toolbar div.toolbar-shortcuts ul li a {
+#toolbar .toolbar-shortcuts nav a {
   margin-left: 5px;
   margin-right: 0;
   padding: 0 5px;
 }
-div#toolbar div.toolbar-shortcuts span.icon {
+#toolbar .toolbar-shortcuts span.icon {
   float: right;
 }
-div.add-or-remove-shortcuts a span.icon {
+.add-or-remove-shortcuts a span.icon {
   float: right;
   margin-right: 8px;
   margin-left: 0;
 }
-div.add-or-remove-shortcuts a span.text {
+.add-or-remove-shortcuts a span.text {
   float: right;
   padding-right: 10px;
   padding-left: 0;
 }
-div.add-or-remove-shortcuts a:focus span.text,
-div.add-or-remove-shortcuts a:hover span.text {
+.add-or-remove-shortcuts a:focus span.text,
+.add-or-remove-shortcuts a:hover span.text {
   -moz-border-radius: 5px 0 0 5px;
   -webkit-border-top-left-radius: 5px;
   -webkit-border-bottom-left-radius: 5px;
@@ -40,9 +40,9 @@
   padding-right: 17px;
   padding-left: 0;
 }
-div.add-shortcut a:hover span.icon {
+.add-shortcut a:hover span.icon {
   background-position: 0 -24px;
 }
-div.remove-shortcut a:hover span.icon {
+.remove-shortcut a:hover span.icon {
   background-position: -12px -24px;
 }
diff --git a/core/modules/shortcut/shortcut.css b/core/modules/shortcut/shortcut.css
index 3afcb94..eb10203 100644
--- a/core/modules/shortcut/shortcut.css
+++ b/core/modules/shortcut/shortcut.css
@@ -1,17 +1,17 @@
-div#toolbar a#edit-shortcuts {
+#toolbar a#edit-shortcuts {
   float: right;
   padding: 5px 10px 5px 5px;
   line-height: 24px;
   color: #fefefe;
 }
-div#toolbar a#edit-shortcuts:focus,
-div#toolbar a#edit-shortcuts:hover,
-div#toolbar a#edit-shortcuts.active {
+#toolbar a#edit-shortcuts:focus,
+#toolbar a#edit-shortcuts:hover,
+#toolbar a#edit-shortcuts.active {
   color: #fff;
   text-decoration: underline;
 }
 
-div#toolbar div.toolbar-shortcuts ul {
+#toolbar .toolbar-shortcuts {
   padding: 5px 0 2px 0;
   height: 28px;
   line-height: 24px;
@@ -19,7 +19,7 @@
   margin-left:5px; /* LTR */
 }
 
-div#toolbar div.toolbar-shortcuts ul li a {
+#toolbar .toolbar-shortcuts a {
   padding: 0 5px 0 5px;
   margin-right: 5px; /* LTR */
   -moz-border-radius: 5px;
@@ -27,18 +27,18 @@
   border-radius: 5px;
 }
 
-div#toolbar div.toolbar-shortcuts ul li a:focus,
-div#toolbar div.toolbar-shortcuts ul li a:hover,
-div#toolbar div.toolbar-shortcuts ul li a.active:focus {
+#toolbar .toolbar-shortcuts a:focus,
+#toolbar .toolbar-shortcuts a:hover,
+#toolbar .toolbar-shortcuts a.active:focus {
   background: #555;
 }
 
-div#toolbar div.toolbar-shortcuts ul li a.active:hover,
-div#toolbar div.toolbar-shortcuts ul li a.active {
+#toolbar .toolbar-shortcuts a.active:hover,
+#toolbar .toolbar-shortcuts a.active {
   background: #000;
 }
 
-div#toolbar div.toolbar-shortcuts span.icon {
+#toolbar .toolbar-shortcuts span.icon {
   float: left; /* LTR */
   background: #444;
   width: 30px;
@@ -49,11 +49,11 @@
   border-radius: 5px;
 }
 
-div.add-or-remove-shortcuts {
+.add-or-remove-shortcuts {
   padding-top: 5px;
 }
 
-div.add-or-remove-shortcuts a span.icon {
+.add-or-remove-shortcuts a span.icon {
   display: block;
   width: 12px;
   background: transparent url(shortcut.png) no-repeat scroll 0 0;
@@ -62,26 +62,26 @@
   margin-left:8px;
 }
 
-div.add-shortcut a:focus span.icon,
-div.add-shortcut a:hover span.icon {
+.add-shortcut a:focus span.icon,
+.add-shortcut a:hover span.icon {
   background-position: 0 -12px;
 }
-div.remove-shortcut a span.icon {
+.remove-shortcut a span.icon {
   background-position: -12px 0;
 }
-div.remove-shortcut a:focus span.icon,
-div.remove-shortcut a:hover span.icon {
+.remove-shortcut a:focus span.icon,
+.remove-shortcut a:hover span.icon {
   background-position: -12px -12px;
 }
 
-div.add-or-remove-shortcuts a span.text {
+.add-or-remove-shortcuts a span.text {
   float: left;
   padding-left:10px;
   display: none;
 }
 
-div.add-or-remove-shortcuts a:focus span.text,
-div.add-or-remove-shortcuts a:hover span.text {
+.add-or-remove-shortcuts a:focus span.text,
+.add-or-remove-shortcuts a:hover span.text {
   font-size: 10px;
   line-height: 12px;
   color: #fff;
diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module
index b057e4b..2ecf824 100644
--- a/core/modules/shortcut/shortcut.module
+++ b/core/modules/shortcut/shortcut.module
@@ -720,9 +720,16 @@
  */
 function shortcut_toolbar_pre_render($toolbar) {
   $links = shortcut_renderable_links();
-  $links['#attached'] = array('css' => array(drupal_get_path('module', 'shortcut') . '/shortcut.css'));
-  $links['#prefix'] = '<div class="toolbar-shortcuts">';
-  $links['#suffix'] = '</div>';
+  // convert the menu_tree return to links usable by l()
+  foreach ($links as $mlid => $link) {
+    if (is_array($link)) {
+      foreach ($link as $key => $val) {
+        unset ($links[$mlid][$key]);
+        $links[$mlid][substr($key, 1)] = $val;
+      }
+    }
+  }
+
   $shortcut_set = shortcut_current_displayed_set();
   $configure_link = NULL;
   if (shortcut_set_edit_access($shortcut_set)) {
@@ -735,7 +742,14 @@
   }
 
   $drawer = array(
-    'shortcuts' => $links,
+    'shortcuts' => array(
+      '#theme' => 'nav',
+      '#attached' => array('css' => array(drupal_get_path('module', 'shortcut') . '/shortcut.css')),
+      '#links' => $links,
+      '#attributes' => array(
+        'class' => array('toolbar-shortcuts'),
+      ),
+    ),
     'configure' => $configure_link,
   );
 
diff --git a/core/modules/toolbar/toolbar-rtl.css b/core/modules/toolbar/toolbar-rtl.css
index e121547..e247066 100644
--- a/core/modules/toolbar/toolbar-rtl.css
+++ b/core/modules/toolbar/toolbar-rtl.css
@@ -3,35 +3,31 @@
 #toolbar * {
   text-align: right;
 }
-#toolbar ul li {
+#toolbar nav {
   float: right;
 }
-#toolbar ul li a {
+#toolbar nav a {
   display: inline-block;
   float: none;
   zoom: 1;
 }
-#toolbar div.toolbar-menu {
+#toolbar .toolbar-menu {
   padding: 5px 50px 5px 50px;
 }
-#toolbar-user {
+#toolbar #toolbar-user {
   float: left;
 }
-#toolbar ul#toolbar-user li {
-  float: none;
-  display: inline;
-}
-#toolbar-menu {
+#toolbar #toolbar-menu {
   float: none;
 }
-#toolbar-home {
+#toolbar #toolbar-home {
   float: right;
 }
-#toolbar ul li.home a {
+#toolbar a.home {
   position: absolute;
   right: 10px;
 }
-#toolbar div.toolbar-menu a.toggle {
+#toolbar .toolbar-menu a.toggle {
   left: 10px;
   right: auto;
 }
diff --git a/core/modules/toolbar/toolbar.css b/core/modules/toolbar/toolbar.css
index 4b62cde..ed6c2ad 100644
--- a/core/modules/toolbar/toolbar.css
+++ b/core/modules/toolbar/toolbar.css
@@ -46,7 +46,7 @@
   -ms-filter: "progid:DXImageTransform.Microsoft.Shadow(color=#000000, direction='180', strength='10')";
   z-index: 600;
 }
-#toolbar div.collapsed {
+#toolbar .collapsed {
   display: none;
   visibility: hidden;
 }
@@ -55,15 +55,15 @@
   font-size: .846em;
   text-decoration: none;
 }
-#toolbar ul li,
-#toolbar ul li a {
+#toolbar nav,
+#toolbar nav a {
   float: left; /* LTR */
 }
 
 /**
  * Administration menu.
  */
-#toolbar div.toolbar-menu {
+#toolbar .toolbar-menu {
   background: #000;
   line-height: 20px;
   padding: 5px 50px 5px 10px; /* LTR */
@@ -78,13 +78,13 @@
   vertical-align: text-bottom;
   width: 11px;
 }
-#toolbar-user {
+#toolbar #toolbar-user {
   float: right; /* LTR */
 }
-#toolbar-menu {
+#toolbar #toolbar-menu {
   float: left; /* LTR */
 }
-#toolbar div.toolbar-menu a.toggle {
+#toolbar .toolbar-menu a.toggle {
   background: url(toolbar.png) 0 -20px no-repeat;
   bottom: 0;
   cursor: pointer;
@@ -95,33 +95,33 @@
   text-indent: -9999px;
   width: 25px;
 }
-#toolbar div.toolbar-menu a.toggle:focus,
-#toolbar div.toolbar-menu a.toggle:hover {
+#toolbar .toolbar-menu a.toggle:focus,
+#toolbar .toolbar-menu a.toggle:hover {
   background-position:  -50px -20px;
 }
-#toolbar div.toolbar-menu a.toggle-active {
+#toolbar .toolbar-menu a.toggle-active {
   background-position:  -25px -20px;
 }
-#toolbar div.toolbar-menu a.toggle-active.toggle:focus,
-#toolbar div.toolbar-menu a.toggle-active.toggle:hover {
+#toolbar .toolbar-menu a.toggle-active.toggle:focus,
+#toolbar .toolbar-menu a.toggle-active.toggle:hover {
   background-position:  -75px -20px;
 }
-#toolbar div.toolbar-menu ul li a {
+#toolbar .toolbar-menu nav a {
   padding: 0 10px;
   -moz-border-radius: 10px;
   -webkit-border-radius: 10px;
   border-radius: 10px;
 }
-#toolbar div.toolbar-menu ul li a:focus,
-#toolbar div.toolbar-menu ul li a:hover,
-#toolbar div.toolbar-menu ul li a:active,
-#toolbar div.toolbar-menu ul li a.active:focus {
+#toolbar .toolbar-menu nav a:focus,
+#toolbar .toolbar-menu nav a:hover,
+#toolbar .toolbar-menu nav a:active,
+#toolbar .toolbar-menu nav a.active:focus {
   background: #444;
 }
-#toolbar div.toolbar-menu ul li a.active:hover,
-#toolbar div.toolbar-menu ul li a.active:active,
-#toolbar div.toolbar-menu ul li a.active,
-#toolbar div.toolbar-menu ul li.active-trail a {
+#toolbar .toolbar-menu nav a.active:hover,
+#toolbar .toolbar-menu nav a.active:active,
+#toolbar .toolbar-menu nav a.active,
+#toolbar .toolbar-menu nav a.active-trail {
   background: url(toolbar.png) 0 0 repeat-x;
   text-shadow: #333 0 1px 0;
 }
@@ -129,7 +129,7 @@
 /**
  * Collapsed drawer of additional toolbar content.
  */
-#toolbar div.toolbar-drawer {
+#toolbar .toolbar-drawer {
   position: relative;
   padding: 0 10px;
 }
diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module
index 5151966..6ee3e8d 100644
--- a/core/modules/toolbar/toolbar.module
+++ b/core/modules/toolbar/toolbar.module
@@ -211,7 +211,7 @@
   // Retrieve the admin menu from the database.
   $links = toolbar_menu_navigation_links(toolbar_get_menu_tree());
   $build['toolbar_menu'] = array(
-    '#theme' => 'links__toolbar_menu',
+    '#theme' => 'nav__toolbar_menu',
     '#links' => $links,
     '#attributes' => array('id' => 'toolbar-menu'),
     '#heading' => array('text' => t('Administrative toolbar'), 'level' => 'h2', 'class' => 'element-invisible'),
@@ -241,7 +241,7 @@
     );
   }
   $build['toolbar_user'] = array(
-    '#theme' => 'links__toolbar_user',
+    '#theme' => 'nav__toolbar_user',
     '#links' => $links,
     '#attributes' => array('id' => 'toolbar-user'),
   );
@@ -256,7 +256,7 @@
     ),
   );
   $build['toolbar_home'] = array(
-    '#theme' => 'links',
+    '#theme' => 'nav__toolbar_home',
     '#links' => $link,
     '#attributes' => array('id' => 'toolbar-home'),
   );
