Mercurial > hg > cmmr2012-drupal-site
diff core/modules/toolbar/js/toolbar.menu.js @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children |
line wrap: on
line diff
--- a/core/modules/toolbar/js/toolbar.menu.js Thu Feb 28 11:14:44 2019 +0000 +++ b/core/modules/toolbar/js/toolbar.menu.js Thu Feb 28 13:11:55 2019 +0000 @@ -14,6 +14,17 @@ handleClose: Drupal.t('Collapse') }; + function toggleList($item, switcher) { + var $toggle = $item.children('.toolbar-box').children('.toolbar-handle'); + switcher = typeof switcher !== 'undefined' ? switcher : !$item.hasClass('open'); + + $item.toggleClass('open', switcher); + + $toggle.toggleClass('open', switcher); + + $toggle.find('.action').text(switcher ? ui.handleClose : ui.handleOpen); + } + function toggleClickHandler(event) { var $toggle = $(event.target); var $item = $toggle.closest('li'); @@ -32,17 +43,6 @@ event.stopPropagation(); } - function toggleList($item, switcher) { - var $toggle = $item.children('.toolbar-box').children('.toolbar-handle'); - switcher = typeof switcher !== 'undefined' ? switcher : !$item.hasClass('open'); - - $item.toggleClass('open', switcher); - - $toggle.toggleClass('open', switcher); - - $toggle.find('.action').text(switcher ? ui.handleClose : ui.handleOpen); - } - function initItems($menu) { var options = { class: 'toolbar-icon toolbar-handle', @@ -56,7 +56,9 @@ var $item = $(element); if ($item.children('ul.toolbar-menu').length) { var $box = $item.children('.toolbar-box'); - options.text = Drupal.t('@label', { '@label': $box.find('a').text() }); + options.text = Drupal.t('@label', { + '@label': $box.find('a').text() + }); $item.children('.toolbar-box').append(Drupal.theme('toolbarMenuItemToggle', options)); } }); @@ -72,9 +74,9 @@ } function openActiveItem($menu) { - var pathItem = $menu.find('a[href="' + location.pathname + '"]'); + var pathItem = $menu.find('a[href="' + window.location.pathname + '"]'); if (pathItem.length && !activeItem) { - activeItem = location.pathname; + activeItem = window.location.pathname; } if (activeItem) { var $activeItem = $menu.find('a[href="' + activeItem + '"]').addClass('menu-item--active'); @@ -98,6 +100,6 @@ }; Drupal.theme.toolbarMenuItemToggle = function (options) { - return '<button class="' + options.class + '"><span class="action">' + options.action + '</span><span class="label">' + options.text + '</span></button>'; + return '<button class="' + options.class + '"><span class="action">' + options.action + '</span> <span class="label">' + options.text + '</span></button>'; }; })(jQuery, Drupal, drupalSettings); \ No newline at end of file