Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.605
diff -u -p -r1.605 theme.inc
--- includes/theme.inc 8 Aug 2010 19:35:48 -0000 1.605
+++ includes/theme.inc 20 Aug 2010 18:09:23 -0000
@@ -1626,6 +1626,8 @@ function theme_table($variables) {
// Add sticky headers, if applicable.
if (count($header) && $sticky) {
+ // Make sure the sticky tableheader won't overlap any focused elements.
+ drupal_add_js('misc/displace.js', array('weight' => JS_LIBRARY + 1));
drupal_add_js('misc/tableheader.js');
// Add 'sticky-enabled' class to the table to identify it for JS.
// This is needed to target tables constructed by this function.
@@ -1999,7 +2001,7 @@ function theme_indentation($variables) {
/**
* Returns HTML output for a single table cell for theme_table().
- *
+ *
* @param $cell
* Array of cell information, or string to display in cell.
* @param bool $header
Index: misc/displace.js
===================================================================
RCS file: misc/displace.js
diff -N misc/displace.js
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ misc/displace.js 20 Aug 2010 18:09:23 -0000
@@ -0,0 +1,380 @@
+// $Id$
+(function ($) {
+
+/**
+ * Attaches the displace behavior.
+ */
+Drupal.behaviors.displace = {
+
+ attach: function (context, settings) {
+ $(document.documentElement).once('displace', function () {
+ Drupal.displace.init();
+ Drupal.displaceFocus.init();
+ });
+
+ Drupal.displace.refresh();
+ Drupal.displaceFocus.refresh();
+ },
+
+ detach: function (context, settings, trigger) {
+ if (trigger == 'unload' || trigger == 'move') {
+ Drupal.displace.refresh();
+ }
+ }
+};
+
+/**
+ * Provides a generic method to detect and act on focus movement.
+ *
+ * When a focus movement is being detect a "drupalDisplaceFocus" event is
+ * triggered. Scripts involving elements that are positioned absolute or fixed
+ * can use this event to adjust the window's scroll position so the element
+ * being focused does not hide beneath them.
+ *
+ * The event object passed to the eventhandlers already contains some useful
+ * info about the position of the target element.
+ *
+ * @see Drupal.displaceFocus.createEvent
+ * @see Drupal.displace.eventhandlerDisplaceFocus
+ * @see Drupal.tableHeader
+ */
+Drupal.displaceFocus = Drupal.displaceFocus || {};
+Drupal.displaceFocus.prototype = {};
+
+/**
+ * Initializes the displaceFocus behavior.
+ */
+Drupal.displaceFocus.init = function () {
+ // Detect when an anchor is being scrolled into view.
+ $(window).bind('scroll.drupal-displace-anchor', Drupal.displaceFocus.eventhandlerDetectAnchorScrolling);
+ // Detect when the focus is being set to an element.
+ $(document).bind('focusin.drupal-displace-focus', Drupal.displaceFocus.eventhandlerDetectFocusMovement);
+};
+
+/**
+ * Refreshes displaceFocus behavior.
+ */
+Drupal.displaceFocus.refresh = function () {
+ $(window).triggerHandler('scroll.drupal-displace-anchor');
+};
+
+/**
+ * Creates an event object containing position data.
+ *
+ * @param type
+ * Describes the nature of the event.
+ * @param target
+ * The DOM element that initiated the event.
+ */
+Drupal.displaceFocus.createEvent = function (type, target) {
+ var event = jQuery.Event(type),
+ $target = $(target),
+ targetOffset = $target.offset(),
+ $window = $(window);
+
+ event.target = target;
+ event.$target = $target;
+ // The amount of pixels the entire document has been scrolled.
+ event.pageXOffset = $window.scrollLeft();
+ event.pageYOffset = $window.scrollTop();
+ // The position of the target element relative to the document.
+ event.pageX = Math.round(targetOffset.left);
+ event.pageY = Math.round(targetOffset.top);
+ // The position of the target element relative to the viewport.
+ event.clientX = event.pageX - event.pageXOffset;
+ event.clientY = event.pageY - event.pageYOffset;
+
+ return event;
+};
+
+/**
+ * Event handler: detects when an anchor is being scrolled into view and
+ * triggers the custom event "drupalDisplaceFocus".
+ *
+ * @param event
+ * Event being triggered, with the following restrictions:
+ * - event.type: scroll
+ * - event.currentTarget: window
+ */
+Drupal.displaceFocus.eventhandlerDetectAnchorScrolling = function (event) {
+ if (location.hash && location.hash != '#') {
+ // Delay the timeout as long as events are triggered.
+ clearTimeout(Drupal.displaceFocus.displaceAnchorTimeout);
+ Drupal.displaceFocus.displaceAnchorTimeout = setTimeout(function () {
+ var $anchor = $(location.hash), $window = $(window);
+ if ($anchor.length && Math.round($anchor.offset().top) == $window.scrollTop()) {
+ $window.trigger(Drupal.displaceFocus.createEvent('drupalDisplaceFocus', $anchor[0]));
+ }
+ }, 100);
+ }
+};
+
+/**
+ * Event handler: detects when the focus is being set to an element and
+ * triggers the custom event "drupalDisplaceFocus".
+ *
+ * @param event
+ * Event being triggered, with the following restrictions:
+ * - event.type: focusin
+ * - event.currentTarget: document
+ */
+Drupal.displaceFocus.eventhandlerDetectFocusMovement = function (event) {
+ if (event.target.nodeType === 1) {
+ // Make sure target element is not fixed positioned.
+ var offsetParent = $(event.target).offsetParent();
+ while (offsetParent.length && offsetParent[0] !== document.body) {
+ if (offsetParent.css('position') == 'fixed') {
+ return;
+ }
+ offsetParent = $(offsetParent[0]).offsetParent();
+ }
+
+ $(window).trigger(Drupal.displaceFocus.createEvent('drupalDisplaceFocus', event.target));
+ }
+};
+
+/**
+ * Provides a generic method to position elements fixed to the viewport.
+ *
+ * Fixed positioning (CSS declaration position:fixed) is done relative to the
+ * viewport. This makes it hard to position multiple fixed positioned element
+ * relative to each other (e.g. multiple toolbars should come after each other,
+ * not on top of each other).
+ *
+ * To position an element fixed at the top of the viewport add the class
+ * "displace-top" to that element, and to position it to the bottom of the view-
+ * port add the class "displace-bottom".
+ *
+ * To position an element absolute at the top of the viewport also add the
+ * class "displace-absolute".
+ *
+ * When a displacement region contains both absolute and fixed positioned
+ * elements, the absolute positioned elements will be positioned fixed too, but
+ * will only be visible when they would be visible if they were positioned
+ * absolute. This is done to improve the look & feel.
+ *
+ * When a browser does not support position:fixed (like IE6) the displaced
+ * elements automaticly receive the class "displace-unsupported" and are
+ * positioned absolute.
+ */
+Drupal.displace = Drupal.displace || {};
+Drupal.displace.prototype = {};
+
+Drupal.displace._elements = [];
+Drupal.displace._mixedDisplacement = [];
+Drupal.displace._displacement = [];
+
+/**
+ * Initializes the displace behavior.
+ */
+Drupal.displace.init = function () {
+ if (!$.support.positionFixed) {
+ $(document.documentElement).addClass('displace-unsupported');
+ }
+};
+
+/**
+ * Refreshes displace behavior.
+ */
+Drupal.displace.refresh = function () {
+ var $window = $(window);
+
+ Drupal.displace.clearCache(true);
+
+ if (Drupal.displace.forceHandlers || Drupal.displace.getDisplacedElements('top').length || Drupal.displace.getDisplacedElements('bottom').length) {
+ var events = 'resize.drupal-displace';
+ // If there are both absolute and fixed displaced elements also bind the
+ // handler to scroll events.
+ if (Drupal.displace.mixedDisplacement('top') || Drupal.displace.mixedDisplacement('bottom')) {
+ events += ' scroll.drupal-displace';
+ }
+ $window
+ .bind(events, Drupal.displace.eventhandlerDisplaceDocument)
+ .bind('drupalDisplaceFocus.drupal-displace', Drupal.displace.eventhandlerDisplaceFocus);
+ }
+ // Unbind any previously bound event handlers as there are no displaced
+ // elements to be taken into account.
+ else {
+ $window.unbind('.drupal-displace');
+ }
+
+ $window.triggerHandler('resize.drupal-displace');
+};
+
+/**
+ * Get all displaced elements of given region.
+ *
+ * @param region
+ * (optional) Region name. Either "top" or "bottom". If not provided an object
+ * containing both will be returned.
+ * @param copy
+ * (optional) Boolean whether to return a copy of the jQuery object.
+ * Defaults to FALSE.
+ *
+ * @return
+ * jQuery object containing all displaced elements of given region.
+ */
+Drupal.displace.getDisplacedElements = function (region, copy) {
+ if (!this._elements.length) {
+ this._elements.top = $('.displace-top');
+ this._elements.bottom = $('.displace-bottom');
+ }
+
+ return region
+ ? copy ? $(this._elements[region]) : this._elements[region]
+ : $(this._elements.top).add(this._elements.bottom);
+};
+
+/**
+ * Checks whether there are both absolute and fixed displaced elements.
+ *
+ * @param region
+ * Region name. Either "top" or "bottom".
+ *
+ * @return
+ * TRUE if there are both absolute and fixed displaced elements in given
+ * region, FALSE otherwise.
+ */
+Drupal.displace.mixedDisplacement = function (region) {
+ if (!this._mixedDisplacement[region]) {
+ this._mixedDisplacement[region] = Drupal.displace.getDisplacedElements(region).is('.displace-absolute') && Drupal.displace.getDisplacedElements(region).is(':not(.displace-absolute)');
+ }
+ return this._mixedDisplacement[region];
+};
+
+/**
+ * Get the total displacement of given region.
+ *
+ * @param region
+ * Region name. Either "top" or "bottom".
+ *
+ * @return
+ * The total displacement of given region in pixels.
+ *
+ * @see modules/overlay/overlay-child.js
+ */
+Drupal.displace.getDisplacement = function (region) {
+ if (!this._displacement[region]) {
+ var offset = Drupal.displace.initialOffset || 0;
+ var height = 0;
+ var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
+ this.getDisplacedElements(region).each(function () {
+ offset = offset + height;
+ height = $(this).css(region, offset).outerHeight();
+
+ // Make sure absolute and fixed displaced elements work together.
+ if (Drupal.displace.mixedDisplacement(region) && $(this).hasClass('displace-absolute')) {
+ if ((region == 'top' && scrollTop < offset + height) || (region == 'bottom' && scrollTop + $(window).height() > document.body.scrollHeight - offset + height)) {
+ $(this).addClass('displace-absolute-fixed');
+ }
+ // Skip this absolute displaced element as it is outside the viewport.
+ else {
+ $(this).removeClass('displace-absolute-fixed');
+ height = 0;
+ }
+ }
+
+ // In IE, Shadow filter adds some extra height, so we need to remove it
+ // from the returned height.
+ if (this.filters && this.filters.length && this.filters.item('DXImageTransform.Microsoft.Shadow')) {
+ height -= this.filters.item('DXImageTransform.Microsoft.Shadow').strength;
+ height = Math.max(0, height);
+ }
+ });
+
+ // Use offset of latest displaced element as the total displacement.
+ this._displacement[region] = offset + height;
+ }
+
+ return this._displacement[region];
+};
+
+/**
+ * Clear cache.
+ *
+ * @param selectorCache
+ * Boolean whether to also clear the selector cache.
+ */
+Drupal.displace.clearCache = function (selectorCache) {
+ if (selectorCache) {
+ this._elements = [];
+ this._mixedDisplacement = [];
+ }
+ this._displacement = [];
+};
+
+/**
+ * Event handler: makes sure there is enough space for displaced elements at the
+ * top and bottom of the document.
+ *
+ * @param event
+ * Event being triggered, with the following restrictions:
+ * - event.type: resize, scroll
+ * - event.currentTarget: window
+ */
+Drupal.displace.eventhandlerDisplaceDocument = function (event) {
+ Drupal.displace.clearCache();
+
+ // Adjust paddingTop and paddingBottom of document root element to make sure
+ // nothing is hidden beneath any displaced elements.
+ var adjustment = {
+ marginTop: Drupal.displace.getDisplacement('top') || null,
+ marginBottom: Drupal.displace.getDisplacement('bottom') || null
+ };
+
+ // Apply adjustments to the document.
+ $(document.body).css(adjustment)
+ // IE7 isn't reflowing the document immediately.
+ // @todo This might be fixed in a cleaner way.
+ .addClass('displace-trigger-reflow').removeClass('displace-trigger-reflow');
+};
+
+/**
+ * Event handler: makes sure the element being focused is not hidden beneath any
+ * displaced elements. Adjusts the scrollTop if it does.
+ *
+ * @param event
+ * Event being triggered, with the following restrictions:
+ * - event.type: drupalDisplaceFocus
+ * - event.currentTarget: window
+ *
+ * @see Drupal.displaceFocus
+ */
+Drupal.displace.eventhandlerDisplaceFocus = function (event) {
+ var displacement = Drupal.displace.getDisplacement('top');
+ if (event.clientY < displacement) {
+ window.scrollBy(0, -(displacement - event.clientY));
+ }
+};
+
+// Override jQuery UI so it adjusts positions when beneath a displaced element.
+var _position = $.fn.position;
+$.fn.position = function(options) {
+ var ret = _position.apply(this, arguments);
+ if (ret.each) {
+ ret.each(function() {
+ var elem = $(this), offset = elem.offset();
+
+ if (offset.top < Drupal.displace.getDisplacement('top')) {
+ offset.top = Drupal.displace.getDisplacement('top');
+ elem.offset(offset);
+ }
+ });
+ }
+ return ret;
+};
+
+// Override jQuery UI: If an draggable's containment option is set to document
+// or window, make sure displacement is taken into account.
+if ($.ui && $.ui.draggable) {
+ var _setContainment= $.ui.draggable.prototype._setContainment;
+ $.ui.draggable.prototype._setContainment = function() {
+ _setContainment.apply(this, arguments);
+ if (this.options.containment == 'document' || this.options.containment == 'window') {
+ this.containment[1] += Drupal.displace.getDisplacement('top');
+ this.containment[3] += Drupal.displace.getDisplacement('bottom');
+ }
+ };
+}
+
+})(jQuery);
Index: misc/tableheader.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/tableheader.js,v
retrieving revision 1.32
diff -u -p -r1.32 tableheader.js
--- misc/tableheader.js 28 Jul 2010 01:38:28 -0000 1.32
+++ misc/tableheader.js 20 Aug 2010 18:09:23 -0000
@@ -33,9 +33,9 @@ Drupal.tableHeader = function (table) {
// the table to avoid a flash of the header clone upon page load.
this.stickyTable = $('
')
.insertBefore(this.originalTable)
- .css({ position: 'fixed', top: '0px' });
+ .css({ position: 'fixed', top: '0px', zIndex: 1 + (parseInt(this.originalTable.css('zIndex')) || 0) });
this.stickyHeader = this.originalHeader.clone(true)
- .hide()
+ .css('visibility', 'hidden')
.appendTo(this.stickyTable);
this.stickyHeaderCells = this.stickyHeader.find('> tr > th');
@@ -43,11 +43,6 @@ Drupal.tableHeader = function (table) {
$(window)
.bind('scroll.drupal-tableheader', $.proxy(this, 'eventhandlerRecalculateStickyHeader'))
.bind('resize.drupal-tableheader', { calculateWidth: true }, $.proxy(this, 'eventhandlerRecalculateStickyHeader'))
- // Make sure the anchor being scrolled into view is not hidden beneath the
- // sticky table header. Adjust the scrollTop if it does.
- .bind('drupalDisplaceAnchor.drupal-tableheader', function () {
- window.scrollBy(0, -self.stickyTable.outerHeight());
- })
// Make sure the element being focused is not hidden beneath the sticky
// table header. Adjust the scrollTop if it does.
.bind('drupalDisplaceFocus.drupal-tableheader', function (event) {
@@ -59,7 +54,7 @@ Drupal.tableHeader = function (table) {
// We hid the header to avoid it showing up erroneously on page load;
// we need to unhide it now so that it will show up when expected.
- this.stickyHeader.show();
+ this.stickyHeader.css('visibility', '');
};
/**
@@ -73,14 +68,14 @@ Drupal.tableHeader.prototype.eventhandle
var calculateWidth = event.data && event.data.calculateWidth;
// Reset top position of sticky table headers to the current top offset.
- this.stickyOffsetTop = Drupal.settings.tableHeaderOffset ? eval(Drupal.settings.tableHeaderOffset + '()') : 0;
+ this.stickyOffsetTop = Drupal.displace ? Drupal.displace.getDisplacement('top') : 0;
this.stickyTable.css('top', this.stickyOffsetTop + 'px');
// Save positioning data.
var viewHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
if (calculateWidth || this.viewHeight !== viewHeight) {
this.viewHeight = viewHeight;
- this.vPosition = this.originalTable.offset().top - 4 - this.stickyOffsetTop;
+ this.vPosition = this.originalTable.offset().top - this.stickyOffsetTop;
this.hPosition = this.originalTable.offset().left;
this.vLength = this.originalTable[0].clientHeight - 100;
calculateWidth = true;
@@ -90,22 +85,15 @@ Drupal.tableHeader.prototype.eventhandle
var hScroll = document.documentElement.scrollLeft || document.body.scrollLeft;
var vOffset = (document.documentElement.scrollTop || document.body.scrollTop) - this.vPosition;
this.stickyVisible = vOffset > 0 && vOffset < this.vLength;
- this.stickyTable.css({ left: (-hScroll + this.hPosition) + 'px', visibility: this.stickyVisible ? 'visible' : 'hidden' });
+ this.stickyTable.css({ left: parseInt(-hScroll + this.hPosition) + 'px', visibility: this.stickyVisible ? 'visible' : 'hidden' });
// Only perform expensive calculations if the sticky header is actually
// visible or when forced.
if (this.stickyVisible && (calculateWidth || !this.widthCalculated)) {
this.widthCalculated = true;
// Resize header and its cell widths.
- this.stickyHeaderCells.each(function (index) {
- var cellWidth = self.originalHeaderCells.eq(index).css('width');
- // Exception for IE7.
- if (cellWidth == 'auto') {
- cellWidth = self.originalHeaderCells.get(index).clientWidth + 'px';
- }
- $(this).css('width', cellWidth);
- });
- this.stickyTable.css('width', this.originalTable.css('width'));
+ this.stickyHeaderCells.width(function (index) { return self.originalHeaderCells.eq(index).width(); });
+ this.stickyTable.width(this.originalTable.css('width'));
}
};
Index: modules/overlay/overlay-child.js
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay-child.js,v
retrieving revision 1.10
diff -u -p -r1.10 overlay-child.js
--- modules/overlay/overlay-child.js 8 Jul 2010 12:20:23 -0000 1.10
+++ modules/overlay/overlay-child.js 20 Aug 2010 18:09:23 -0000
@@ -159,22 +159,23 @@ Drupal.overlayChild.behaviors.shortcutAd
};
/**
- * Use displacement from parent window.
+ * Allow resize event handlers to recalculate sizes/positions when parent window
+ * is being resized.
*/
-Drupal.overlayChild.behaviors.alterTableHeaderOffset = function (context, settings) {
- if (Drupal.settings.tableHeaderOffset) {
- Drupal.overlayChild.prevTableHeaderOffset = Drupal.settings.tableHeaderOffset;
- }
- Drupal.settings.tableHeaderOffset = 'Drupal.overlayChild.tableHeaderOffset';
+Drupal.overlayChild.behaviors.parentResize = function (context, settings) {
+ $(document).bind('drupalOverlayResize.drupal-overlay', function () {
+ $(window).triggerHandler('resize');
+ });
};
-/**
- * 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'));
+// Override Drupal.displace so it includes displacement of parent document.
+Drupal.displace.forceHandlers = true;
+var _getDisplacement = Drupal.displace.getDisplacement;
+Drupal.displace.getDisplacement = function (region) {
+ if (parent && parent.Drupal && parent.Drupal.displace) {
+ Drupal.displace.initialOffset = parent.Drupal.displace.getDisplacement(region);
+ }
+ return _getDisplacement.apply(Drupal.displace, arguments);
};
})(jQuery);
Index: modules/overlay/overlay-parent.js
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay-parent.js,v
retrieving revision 1.54
diff -u -p -r1.54 overlay-parent.js
--- modules/overlay/overlay-parent.js 18 Aug 2010 02:25:50 -0000 1.54
+++ modules/overlay/overlay-parent.js 20 Aug 2010 18:09:23 -0000
@@ -124,7 +124,7 @@ Drupal.overlay.create = function () {
' drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerDispatchEvent'))
.bind('keydown' + eventClass, $.proxy(this, 'eventhandlerRestrictKeyboardNavigation'));
- if ($('.overlay-displace-top, .overlay-displace-bottom').length) {
+ if (Drupal.displace) {
$(document)
.bind('drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerAlterDisplacedElements'))
.bind('drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerRestoreDisplacedElements'));
@@ -364,14 +364,6 @@ Drupal.overlay.eventhandlerAlterDisplace
return;
}
- $(this.iframeWindow.document.body).css({
- marginTop: Drupal.overlay.getDisplacement('top'),
- marginBottom: Drupal.overlay.getDisplacement('bottom')
- })
- // IE7 isn't reflowing the document immediately.
- // @todo This might be fixed in a cleaner way.
- .addClass('overlay-trigger-reflow').removeClass('overlay-trigger-reflow');
-
var documentHeight = this.iframeWindow.document.body.clientHeight;
var documentWidth = this.iframeWindow.document.body.clientWidth;
// IE6 doesn't support maxWidth, use width instead.
@@ -379,7 +371,7 @@ Drupal.overlay.eventhandlerAlterDisplace
// Consider any element that should be visible above the overlay (such as
// a toolbar).
- $('.overlay-displace-top, .overlay-displace-bottom').each(function () {
+ Drupal.displace.getDisplacedElements().each(function () {
var data = $(this).data();
var maxWidth = documentWidth;
// In IE, Shadow filter makes element to overlap the scrollbar with 1px.
@@ -415,7 +407,7 @@ Drupal.overlay.eventhandlerAlterDisplace
* - event.currentTarget: any
*/
Drupal.overlay.eventhandlerRestoreDisplacedElements = function (event) {
- var $displacedElements = $('.overlay-displace-top, .overlay-displace-bottom');
+ var $displacedElements = Drupal.displace.getDisplacedElements();
try {
$displacedElements.css({ maxWidth: null, clip: null });
}
@@ -644,7 +636,7 @@ Drupal.overlay.eventhandlerRestrictKeybo
// move the focus along until it is.
var direction = event.shiftKey ? -1 : 1;
var current = this.$tabbables.index(event.target);
- var $allowedParent = '#overlay-container, .overlay-displace-top, .overlay-displace-bottom';
+ var $allowedParent = '#overlay-container, .displace-top, .displace-bottom';
if (current != -1 && this.$tabbables[current + direction] && !this.$tabbables.eq(current + direction).closest($allowedParent).length) {
while (this.$tabbables[current + direction] && !this.$tabbables.eq(current + direction).closest($allowedParent).length) {
current = current + direction;
@@ -664,8 +656,13 @@ Drupal.overlay.eventhandlerRestrictKeybo
* - event.currentTarget: any
*/
Drupal.overlay.eventhandlerDispatchEvent = function (event) {
+ var self = this;
if (this.iframeWindow && this.iframeWindow.document) {
- this.iframeWindow.jQuery(this.iframeWindow.document).trigger(event);
+ window.setTimeout(function() {
+ if (self.iframeWindow && self.iframeWindow.document) {
+ self.iframeWindow.jQuery(self.iframeWindow.document).trigger(event);
+ }
+ }, 1);
}
};
@@ -733,10 +730,14 @@ Drupal.overlay.refreshRegions = function
* Path to match links against.
*/
Drupal.overlay.resetActiveClass = function(activePath) {
+ if (!Drupal.displace) {
+ return;
+ }
+
var self = this;
var windowDomain = window.location.protocol + window.location.hostname;
- $('.overlay-displace-top, .overlay-displace-bottom')
+ Drupal.displace.getDisplacedElements()
.find('a[href]')
// Remove active class from all links in displaced elements.
.removeClass('active')
@@ -789,30 +790,6 @@ Drupal.overlay.getPath = function (link,
};
/**
- * Get the total displacement of given region.
- *
- * @param region
- * Region name. Either "top" or "bottom".
- *
- * @return
- * The total displacement of given region in pixels.
- */
-Drupal.overlay.getDisplacement = function (region) {
- var displacement = 0;
- var lastDisplaced = $('.overlay-displace-' + region + ':last');
- if (lastDisplaced.length) {
- displacement = lastDisplaced.offset().top + lastDisplaced.outerHeight();
-
- // Remove height added by IE Shadow filter.
- if (lastDisplaced[0].filters && lastDisplaced[0].filters.length && lastDisplaced[0].filters.item('DXImageTransform.Microsoft.Shadow')) {
- displacement -= lastDisplaced[0].filters.item('DXImageTransform.Microsoft.Shadow').strength;
- displacement = Math.max(0, displacement);
- }
- }
- return displacement;
-};
-
-/**
* Theme function to create the overlay iframe element.
*/
Drupal.theme.prototype.overlayContainer = function () {
Index: modules/overlay/overlay.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay.module,v
retrieving revision 1.30
diff -u -p -r1.30 overlay.module
--- modules/overlay/overlay.module 11 Aug 2010 02:08:09 -0000 1.30
+++ modules/overlay/overlay.module 20 Aug 2010 18:09:23 -0000
@@ -193,7 +193,10 @@ function overlay_library() {
'website' => 'http://drupal.org/handbook/modules/overlay',
'version' => '1.0',
'js' => array(
- $module_path . '/overlay-child.js' => array(),
+ // Always include displace.js as any displacement inside the parent window
+ // has to be taken into account.
+ 'misc/displace.js' => array('weight' => JS_LIBRARY + 1),
+ $module_path . '/overlay-child.js' => array('weight' => JS_LIBRARY + 2),
),
'css' => array(
$module_path . '/overlay-child.css' => array(),
Index: modules/system/system-behavior.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system-behavior.css,v
retrieving revision 1.13
diff -u -p -r1.13 system-behavior.css
--- modules/system/system-behavior.css 9 Aug 2010 16:58:15 -0000 1.13
+++ modules/system/system-behavior.css 20 Aug 2010 18:09:23 -0000
@@ -263,6 +263,33 @@ div.password-confirm {
}
/**
+ * Displace position: fixed elements.
+ */
+.displace-top,
+.displace-bottom {
+ position: relative;
+ width: 100%;
+}
+.displace-processed .displace-top,
+.displace-processed .displace-bottom,
+.displace-processed .displace-absolute.displace-absolute-fixed {
+ position: fixed;
+ width: auto;
+ left: 0;
+ right: 0;
+ z-index: 600;
+}
+.displace-processed .displace-absolute {
+ position: absolute;
+ z-index: 500;
+}
+.displace-unsupported .displace-top,
+.displace-unsupported .displace-bottom {
+ position: absolute;
+ width: 100%;
+}
+
+/**
* Inline items (need to override above)
*/
.container-inline div,
Index: modules/system/system.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.css,v
retrieving revision 1.78
diff -u -p -r1.78 system.css
--- modules/system/system.css 2 Aug 2010 11:22:22 -0000 1.78
+++ modules/system/system.css 20 Aug 2010 18:09:23 -0000
@@ -255,46 +255,6 @@ tr.selected td {
}
/*
-** To be used with displace.js
-*/
-.displace-top,
-.displace-bottom {
- position: relative;
- width: 100%;
-}
-.displace-processed .displace-top,
-.displace-processed .displace-bottom {
- position: fixed;
- width: auto;
- left: 0;
- right: 0;
-}
-.displace-unsupported .displace-top,
-.displace-unsupported .displace-bottom {
- position: absolute;
-}
-
-/*
-** To be used with displace.js
-*/
-.displace-top,
-.displace-bottom {
- position: relative;
- width: 100%;
-}
-.displace-processed .displace-top,
-.displace-processed .displace-bottom {
- position: fixed;
- width: auto;
- left: 0;
- right: 0;
-}
-.displace-unsupported .displace-top,
-.displace-unsupported .displace-bottom {
- position: absolute;
-}
-
-/*
** Floating header for tableheader.js
*/
table.sticky-header {
Index: modules/toolbar/toolbar.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/toolbar/toolbar.css,v
retrieving revision 1.25
diff -u -p -r1.25 toolbar.css
--- modules/toolbar/toolbar.css 21 Jul 2010 00:26:21 -0000 1.25
+++ modules/toolbar/toolbar.css 20 Aug 2010 18:09:23 -0000
@@ -1,13 +1,5 @@
/* $Id: toolbar.css,v 1.25 2010/07/21 00:26:21 dries Exp $ */
-body.toolbar {
- padding-top: 2.2em;
-}
-
-body.toolbar-drawer {
- padding-top: 5.3em;
-}
-
/**
* Aggressive resets so we can achieve a consistent look in hostile CSS
* environments.
@@ -35,19 +27,23 @@ body.toolbar-drawer {
font: normal small "Lucida Grande", Verdana, sans-serif;
background: #666;
color: #ccc;
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
+}
+.displace-processed #toolbar {
margin: 0 -20px;
padding: 0 20px;
- z-index: 600;
box-shadow: 0 3px 20px #000;
-moz-box-shadow: 0 3px 20px #000;
-webkit-box-shadow: 0 3px 20px #000;
filter: progid:DXImageTransform.Microsoft.Shadow(color=#000000, direction='180', strength='10');
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(color=#000000, direction='180', strength='10')";
}
+.displace-unsupported #toolbar {
+ margin: 0;
+ padding-right: 0;
+ left: -20px;
+ right: 0;
+ width: 100%;
+}
#toolbar div.collapsed {
display: none;
Index: modules/toolbar/toolbar.js
===================================================================
RCS file: /cvs/drupal/drupal/modules/toolbar/toolbar.js,v
retrieving revision 1.19
diff -u -p -r1.19 toolbar.js
--- modules/toolbar/toolbar.js 8 Jun 2010 05:16:29 -0000 1.19
+++ modules/toolbar/toolbar.js 20 Aug 2010 18:09:23 -0000
@@ -48,7 +48,6 @@ Drupal.toolbar.collapse = function() {
.removeClass('toggle-active')
.attr('title', toggle_text)
.html(toggle_text);
- $('body').removeClass('toolbar-drawer').css('paddingTop', Drupal.toolbar.height());
$.cookie(
'Drupal.toolbar.collapsed',
1,
@@ -70,7 +69,6 @@ Drupal.toolbar.expand = function() {
.addClass('toggle-active')
.attr('title', toggle_text)
.html(toggle_text);
- $('body').addClass('toolbar-drawer').css('paddingTop', Drupal.toolbar.height());
$.cookie(
'Drupal.toolbar.collapsed',
0,
@@ -94,14 +92,4 @@ Drupal.toolbar.toggle = function() {
}
};
-Drupal.toolbar.height = function() {
- var height = $('#toolbar').outerHeight();
- // In IE, Shadow filter adds some extra height, so we need to remove it from
- // the returned height.
- if ($('#toolbar').css('filter').match(/DXImageTransform\.Microsoft\.Shadow/)) {
- height -= $('#toolbar').get(0).filters.item("DXImageTransform.Microsoft.Shadow").strength;
- }
- return height;
-};
-
})(jQuery);
Index: modules/toolbar/toolbar.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/toolbar/toolbar.module,v
retrieving revision 1.43
diff -u -p -r1.43 toolbar.module
--- modules/toolbar/toolbar.module 2 Jul 2010 02:22:26 -0000 1.43
+++ modules/toolbar/toolbar.module 20 Aug 2010 18:09:23 -0000
@@ -155,9 +155,11 @@ function toolbar_preprocess_html(&$vars)
*
* Adding the 'overlay-displace-top' class to the toolbar pushes the overlay
* down, so it appears below the toolbar.
+ *
+ * @see misc/displace.js
*/
function toolbar_preprocess_toolbar(&$variables) {
- $variables['classes_array'][] = "overlay-displace-top";
+ $variables['classes_array'][] = "displace-top";
}
/**
@@ -187,12 +189,10 @@ function toolbar_view() {
'#theme' => 'toolbar',
'#attached'=> array(
'js' => array(
- $module_path . '/toolbar.js',
+ // Make sure the toolbar won't overlap any focused elements.
+ array('data' => 'misc/displace.js', 'weight' => JS_LIBRARY + 1),
array('data' => 'misc/jquery.cookie.js', 'weight' => JS_LIBRARY + 2),
- array(
- 'data' => array('tableHeaderOffset' => 'Drupal.toolbar.height'),
- 'type' => 'setting'
- ),
+ $module_path . '/toolbar.js',
),
'css' => array(
$module_path . '/toolbar.css',