mirror of
https://github.com/tag1consulting/d7_to_d10_migration.git
synced 2025-09-06 00:51:22 +00:00
Initial commit
This commit is contained in:
commit
c5e731d8ae
2773 changed files with 600767 additions and 0 deletions
113
drupal7/web/modules/toolbar/toolbar.js
Normal file
113
drupal7/web/modules/toolbar/toolbar.js
Normal file
|
@ -0,0 +1,113 @@
|
|||
(function ($) {
|
||||
|
||||
Drupal.toolbar = Drupal.toolbar || {};
|
||||
|
||||
/**
|
||||
* Attach toggling behavior and notify the overlay of the toolbar.
|
||||
*/
|
||||
Drupal.behaviors.toolbar = {
|
||||
attach: function(context) {
|
||||
|
||||
// Set the initial state of the toolbar.
|
||||
$('#toolbar', context).once('toolbar', Drupal.toolbar.init);
|
||||
|
||||
// Toggling toolbar drawer.
|
||||
$('#toolbar a.toggle', context).once('toolbar-toggle').click(function(e) {
|
||||
Drupal.toolbar.toggle();
|
||||
// Allow resize event handlers to recalculate sizes/positions.
|
||||
$(window).triggerHandler('resize');
|
||||
return false;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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,
|
||||
{
|
||||
// Workaround lack of support for the SameSite attribute in jQuery Cookie.
|
||||
path: Drupal.settings.basePath + '; SameSite=Lax',
|
||||
// The cookie should "never" expire.
|
||||
expires: 36500
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* 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,
|
||||
{
|
||||
// Workaround lack of support for the SameSite attribute in jQuery Cookie.
|
||||
path: Drupal.settings.basePath + '; SameSite=Lax',
|
||||
// The cookie should "never" expire.
|
||||
expires: 36500
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggle the toolbar.
|
||||
*/
|
||||
Drupal.toolbar.toggle = function() {
|
||||
if ($('#toolbar div.toolbar-drawer').hasClass('collapsed')) {
|
||||
Drupal.toolbar.expand();
|
||||
}
|
||||
else {
|
||||
Drupal.toolbar.collapse();
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.toolbar.height = function() {
|
||||
var $toolbar = $('#toolbar');
|
||||
var height = $toolbar.outerHeight();
|
||||
// In modern browsers (including IE9), when box-shadow is defined, use the
|
||||
// normal height.
|
||||
var cssBoxShadowValue = $toolbar.css('box-shadow');
|
||||
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.css('filter'))) {
|
||||
height -= $toolbar[0].filters.item("DXImageTransform.Microsoft.Shadow").strength;
|
||||
}
|
||||
return height;
|
||||
};
|
||||
|
||||
})(jQuery);
|
Loading…
Add table
Add a link
Reference in a new issue