Commit 34e4ef48 authored by Dries's avatar Dries

- Patch #1574738 by nod_: rewrite tableheader.js.

parent 316fe064
This diff is collapsed.
......@@ -174,23 +174,11 @@ Drupal.overlayChild.behaviors.shortcutAddLink = function (context, settings) {
});
};
/**
* Use displacement from parent window.
*/
Drupal.overlayChild.behaviors.alterTableHeaderOffset = function (context, settings) {
if (Drupal.settings.tableHeaderOffset) {
Drupal.overlayChild.prevTableHeaderOffset = Drupal.settings.tableHeaderOffset;
}
Drupal.settings.tableHeaderOffset = 'Drupal.overlayChild.tableHeaderOffset';
};
/**
* Callback for Drupal.settings.tableHeaderOffset.
*/
Drupal.overlayChild.tableHeaderOffset = function () {
var topOffset = Drupal.overlayChild.prevTableHeaderOffset ? eval(Drupal.overlayChild.prevTableHeaderOffset + '()') : 0;
return topOffset + parseInt($(document.body).css('marginTop'));
};
// Workaround because of the way jQuery events works.
// jQuery from the parent frame needs to be used to catch this event.
parent.jQuery(document).bind('offsettopchange', function () {
// Fires an event that the child iframe can listen to.
$(document).trigger('offsettopchange');
});
})(jQuery);
......@@ -433,6 +433,12 @@ Drupal.overlay.eventhandlerAlterDisplacedElements = function (event) {
$(this.iframeWindow.document.body).css({
marginTop: Drupal.overlay.getDisplacement('top'),
marginBottom: Drupal.overlay.getDisplacement('bottom')
}).attr('data-offset-top', Drupal.overlay.getDisplacement('top'));
$(document).bind('offsettopchange', function () {
var iframeDocument = Drupal.overlay.iframeWindow.document;
$(iframeDocument.body).attr('data-offset-top', Drupal.overlay.getDisplacement('top'));
$(iframeDocument).trigger('offsettopchange');
});
var documentHeight = this.iframeWindow.document.body.clientHeight;
......
......@@ -8,18 +8,23 @@ Drupal.toolbar = Drupal.toolbar || {};
* Attach toggling behavior and notify the overlay of the toolbar.
*/
Drupal.behaviors.toolbar = {
attach: function(context) {
var $context = $(context);
// Set the initial state of the toolbar.
$context.find('#toolbar').once('toolbar', Drupal.toolbar.init);
attach: function(context, settings) {
var $toolbar = $('#toolbar').once('toolbar');
if ($toolbar.length) {
// Toggling toolbar drawer.
$context.find('#toolbar a.toggle').once('toolbar-toggle').click(function(e) {
Drupal.toolbar.toggle();
// Allow resize event handlers to recalculate sizes/positions.
$(window).triggerHandler('resize');
return false;
});
// 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');
});
}
}
};
......@@ -59,6 +64,8 @@ Drupal.toolbar.collapse = function() {
expires: 36500
}
);
Drupal.toolbar.height();
$(document).trigger('offsettopchange');
};
/**
......@@ -81,6 +88,8 @@ Drupal.toolbar.expand = function() {
expires: 36500
}
);
Drupal.toolbar.height();
$(document).trigger('offsettopchange');
};
/**
......@@ -96,8 +105,10 @@ Drupal.toolbar.toggle = function() {
};
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;
};
......
......@@ -194,10 +194,6 @@ function toolbar_view() {
'#attached'=> array(
'js' => array(
$module_path . '/toolbar.js',
array(
'data' => array('tableHeaderOffset' => 'Drupal.toolbar.height'),
'type' => 'setting'
),
),
'css' => array(
$module_path . '/toolbar.css',
......
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