diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module
index 9bbb12a..e5ba0d1 100644
--- a/core/modules/shortcut/shortcut.module
+++ b/core/modules/shortcut/shortcut.module
@@ -728,12 +728,7 @@ function shortcut_page_alter(&$page) {
*/
function shortcut_toolbar_pre_render($toolbar) {
$links = shortcut_renderable_links();
- $links['#attached'] = array(
- 'css' => array(
- drupal_get_path('module', 'shortcut') . '/shortcut.base.css',
- drupal_get_path('module', 'shortcut') . '/shortcut.theme.css',
- ),
- );
+ $links['#attached']['library'][] = array('shortcut', 'drupal.shortcut');
$links['#prefix'] = '
';
$links['#suffix'] = '
';
$shortcut_set = shortcut_current_displayed_set();
@@ -774,7 +769,7 @@ function shortcut_set_title($shortcut_set) {
*/
function shortcut_library_info() {
$libraries['drupal.shortcut.admin'] = array(
- 'title' => 'Shortcut',
+ 'title' => 'Shortcut admin',
'version' => VERSION,
'js' => array(
drupal_get_path('module', 'shortcut') . '/shortcut.admin.js' => array(),
@@ -784,6 +779,24 @@ function shortcut_library_info() {
array('system', 'drupal'),
),
);
+ $libraries['drupal.shortcut'] = array(
+ 'title' => 'Shortcut',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'shortcut') . '/shortcut.js' => array(),
+ ),
+ 'css' => array(
+ drupal_get_path('module', 'shortcut') . '/shortcut.base.css',
+ drupal_get_path('module', 'shortcut') . '/shortcut.theme.css',
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ array('system', 'drupal.settings'),
+ array('system', 'jquery.once'),
+ array('system', 'jquery.cookie'),
+ ),
+ );
return $libraries;
}
diff --git a/core/modules/toolbar/toolbar.css b/core/modules/toolbar/toolbar.css
index bd18110..0886351 100644
--- a/core/modules/toolbar/toolbar.css
+++ b/core/modules/toolbar/toolbar.css
@@ -3,7 +3,7 @@ body.toolbar {
padding-top: 2.2em;
}
body.toolbar-drawer {
- padding-top: 5.3em;
+ padding-top: 2.3em;
}
/**
diff --git a/core/modules/toolbar/toolbar.js b/core/modules/toolbar/toolbar.js
index 2353050..c89c07e 100644
--- a/core/modules/toolbar/toolbar.js
+++ b/core/modules/toolbar/toolbar.js
@@ -1,115 +1,32 @@
-(function ($) {
+(function () {
"use strict";
-Drupal.toolbar = Drupal.toolbar || {};
-
-/**
- * Attach toggling behavior and notify the overlay of the toolbar.
- */
-Drupal.behaviors.toolbar = {
- attach: function(context, settings) {
- var $toolbar = $('#toolbar').once('toolbar');
- if ($toolbar.length) {
-
- // Set the initial state of the toolbar.
- Drupal.toolbar.init();
-
- $(window).on('resize.toolbar', Drupal.toolbar.height);
-
- // Toggling toolbar drawer.
- $toolbar.find('a.toggle').once('toolbar-toggle').click(function(e) {
- e.preventDefault();
- Drupal.toolbar.toggle();
- // Allow resize event handlers to recalculate sizes/positions.
- $(window).triggerHandler('resize');
- });
+function toolbarHeight() {
+ // This ugly condition is needed because tableheader screw things up. There is a patch waiting for review: #1417378.
+ if (toolbar) {
+ var height = toolbar.offsetHeight;
+ // In modern browsers (including IE9), when box-shadow is defined, use the
+ // normal height.
+ var cssBoxShadowValue = toolbar.style.boxShadow;
+ var boxShadow = (typeof cssBoxShadowValue !== 'undefined' && cssBoxShadowValue !== 'none');
+ // In IE8 and below, we use the shadow filter to apply box-shadow styles to
+ // the toolbar. It adds some extra height that we need to remove.
+ if (!boxShadow && /DXImageTransform\.Microsoft\.Shadow/.test(toolbar.style.filter)) {
+ height -= +toolbar.filters.item("DXImageTransform.Microsoft.Shadow").strength;
}
+ return height;
}
-};
-
-/**
- * Retrieve last saved cookie settings and set up the initial toolbar state.
- */
-Drupal.toolbar.init = function() {
- // Retrieve the collapsed status from a stored cookie.
- var collapsed = $.cookie('Drupal.toolbar.collapsed');
-
- // Expand or collapse the toolbar based on the cookie value.
- if (collapsed === '1') {
- Drupal.toolbar.collapse();
- }
- else {
- Drupal.toolbar.expand();
- }
-};
-
-/**
- * Collapse the toolbar.
- */
-Drupal.toolbar.collapse = function() {
- var toggle_text = Drupal.t('Show shortcuts');
- $('#toolbar div.toolbar-drawer').addClass('collapsed');
- $('#toolbar a.toggle')
- .removeClass('toggle-active')
- .attr('title', toggle_text)
- .html(toggle_text);
- $('body').removeClass('toolbar-drawer').css('paddingTop', Drupal.toolbar.height());
- $.cookie(
- 'Drupal.toolbar.collapsed',
- 1,
- {
- path: Drupal.settings.basePath,
- // The cookie should "never" expire.
- expires: 36500
- }
- );
- Drupal.toolbar.height();
- $(document).trigger('offsettopchange');
-};
+ return 0;
+}
-/**
- * Expand the toolbar.
- */
-Drupal.toolbar.expand = function() {
- var toggle_text = Drupal.t('Hide shortcuts');
- $('#toolbar div.toolbar-drawer').removeClass('collapsed');
- $('#toolbar a.toggle')
- .addClass('toggle-active')
- .attr('title', toggle_text)
- .html(toggle_text);
- $('body').addClass('toolbar-drawer').css('paddingTop', Drupal.toolbar.height());
- $.cookie(
- 'Drupal.toolbar.collapsed',
- 0,
- {
- path: Drupal.settings.basePath,
- // The cookie should "never" expire.
- expires: 36500
- }
- );
- Drupal.toolbar.height();
- $(document).trigger('offsettopchange');
-};
-
-/**
- * Toggle the toolbar.
- */
-Drupal.toolbar.toggle = function() {
- if ($('#toolbar div.toolbar-drawer').hasClass('collapsed')) {
- Drupal.toolbar.expand();
- }
- else {
- Drupal.toolbar.collapse();
- }
-};
+// Set the initial state of the toolbar.
+// ID, don't need to scope. We don't support broken code right?
+var toolbar = document.querySelector('#toolbar');
-Drupal.toolbar.height = function() {
- // @TODO this needs to be cached outside this function.
- var $toolbar = $('#toolbar');
- var height = $toolbar.outerHeight();
- $toolbar.attr('data-offset-top', height);
- return height;
-};
+if (!/toolbar-processed/.test(toolbar.className)) {
+ toolbar.setAttribute('data-offset-top', toolbarHeight());
+ toolbar.className += ' toolbar-processed';
+}
-})(jQuery);
+}());
diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module
index fa4dd6f..618013f 100644
--- a/core/modules/toolbar/toolbar.module
+++ b/core/modules/toolbar/toolbar.module
@@ -366,18 +366,11 @@ function toolbar_library_info() {
'title' => 'Toolbar',
'version' => VERSION,
'js' => array(
- drupal_get_path('module', 'toolbar') . '/toolbar.js' => array(),
+ drupal_get_path('module', 'toolbar') . '/toolbar.js' => array('scope' => 'footer'),
),
'css' => array(
drupal_get_path('module', 'toolbar') . '/toolbar.css',
),
- 'dependencies' => array(
- array('system', 'jquery'),
- array('system', 'drupal'),
- array('system', 'drupal.settings'),
- array('system', 'jquery.once'),
- array('system', 'jquery.cookie'),
- ),
);
return $libraries;