Commit 232c10dc authored by alexpott's avatar alexpott

Issue #1850164 by Tom Verhaeghe: Default state of toolbar should show menu...

Issue #1850164 by Tom Verhaeghe: Default state of toolbar should show menu tray in non-narrow viewports
parent 8a9a3b76
......@@ -29,8 +29,8 @@
/**
* Registers tabs with the toolbar.
*
* The Drupal toolbar allows modules to register top-level tabs. These may point
* directly to a resource or toggle the visibility of a tray.
* The Drupal toolbar allows modules to register top-level tabs. These may
* point directly to a resource or toggle the visibility of a tray.
*
* Modules register tabs with hook_toolbar().
*/
......@@ -88,8 +88,8 @@
if (options.breakpoints.hasOwnProperty(label)) {
var mq = options.breakpoints[label];
var mql = Drupal.toolbar.mql[label] = window.matchMedia(mq);
// Curry the model and the label of the media query breakpoint to the
// mediaQueryChangeHandler function.
// Curry the model and the label of the media query breakpoint to
// the mediaQueryChangeHandler function.
mql.addListener(Drupal.toolbar.mediaQueryChangeHandler.bind(null, model, label));
// Fire the mediaQueryChangeHandler for each configured breakpoint
// so that they process once.
......@@ -102,8 +102,8 @@
// process. The toolbar starts in the vertical orientation by default,
// unless the viewport is wide enough to accommodate a horizontal
// orientation. Thus we give the Toolbar a chance to determine if it
// should be set to horizontal orientation before attempting to load menu
// subtrees.
// should be set to horizontal orientation before attempting to load
// menu subtrees.
Drupal.toolbar.views.toolbarVisualView.loadSubtrees();
$(document)
......@@ -123,6 +123,15 @@
.on('change:activeTray', function (model, tray) {
$(document).trigger('drupalToolbarTrayChange', tray);
});
// If the toolbar's orientation is horizontal and no active tab is
// defined then show the tray of the first toolbar tab by default (but
// not the first 'Home' toolbar tab).
if (Drupal.toolbar.models.toolbarModel.get('orientation') === 'horizontal' && Drupal.toolbar.models.toolbarModel.get('activeTab') === null){
Drupal.toolbar.models.toolbarModel.set({
'activeTab': $('.toolbar-bar .toolbar-tab:not(.home-toolbar-tab) a').get(0)
});
}
});
}
};
......@@ -177,7 +186,8 @@
model.set({
'orientation': ((mql.matches) ? 'horizontal' : 'vertical')
}, {validate: true});
// The tray orientation toggle visibility does not need to be validated.
// The tray orientation toggle visibility does not need to be
// validated.
model.set({
'isTrayToggleVisible': mql.matches
});
......
......@@ -133,7 +133,7 @@ function toolbar_toolbar() {
),
),
'#wrapper_attributes' => array(
'class' => array('hidden'),
'class' => array('hidden', 'home-toolbar-tab'),
),
'#attached' => array(
'library' => array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment