### Eclipse Workspace Patch 1.0 #P drupal 7 Index: modules/toolbar/toolbar.tpl.php =================================================================== RCS file: /cvs/drupal/drupal/modules/toolbar/toolbar.tpl.php,v retrieving revision 1.9 diff -u -r1.9 toolbar.tpl.php --- modules/toolbar/toolbar.tpl.php 10 Feb 2010 10:54:12 -0000 1.9 +++ modules/toolbar/toolbar.tpl.php 9 May 2010 12:52:07 -0000 @@ -22,7 +22,7 @@ * @see template_preprocess_toolbar() */ ?> -
+
Index: modules/toolbar/toolbar.js =================================================================== RCS file: /cvs/drupal/drupal/modules/toolbar/toolbar.js,v retrieving revision 1.16 diff -u -r1.16 toolbar.js --- modules/toolbar/toolbar.js 4 Apr 2010 20:27:08 -0000 1.16 +++ modules/toolbar/toolbar.js 9 May 2010 12:52:07 -0000 @@ -17,7 +17,7 @@ Drupal.toolbar.toggle(); // As the toolbar is an overlay displaced region, overlay should be // notified of it's height change to adapt its position. - $(window).triggerHandler('resize.overlay-event'); + $(window).triggerHandler('resize'); return false; }); } @@ -49,7 +49,6 @@ .removeClass('toggle-active') .attr('title', toggle_text) .html(toggle_text); - $('body').removeClass('toolbar-drawer').css('paddingTop', Drupal.toolbar.height()); $.cookie( 'Drupal.toolbar.collapsed', 1, @@ -71,7 +70,6 @@ .addClass('toggle-active') .attr('title', toggle_text) .html(toggle_text); - $('body').addClass('toolbar-drawer').css('paddingTop', Drupal.toolbar.height()); $.cookie( 'Drupal.toolbar.collapsed', 0, @@ -95,14 +93,4 @@ } }; -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.37 diff -u -r1.37 toolbar.module --- modules/toolbar/toolbar.module 29 Apr 2010 05:19:50 -0000 1.37 +++ modules/toolbar/toolbar.module 9 May 2010 12:52:07 -0000 @@ -177,12 +177,9 @@ '#theme' => 'toolbar', '#attached'=> array( 'js' => array( - $module_path . '/toolbar.js', + '/misc/displace.js', 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', Index: modules/toolbar/toolbar.css =================================================================== RCS file: /cvs/drupal/drupal/modules/toolbar/toolbar.css,v retrieving revision 1.20 diff -u -r1.20 toolbar.css --- modules/toolbar/toolbar.css 4 Apr 2010 17:11:20 -0000 1.20 +++ modules/toolbar/toolbar.css 9 May 2010 12:52:07 -0000 @@ -1,12 +1,6 @@ /* $Id: toolbar.css,v 1.20 2010/04/04 17:11:20 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 @@ -32,10 +26,8 @@ font: normal 0.9em "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; @@ -132,18 +124,3 @@ position: relative; padding: 0 10px; } - -/** - * IE 6 Fix. - * - * IE 6 shows elements with position:fixed as position:static so we replace - * it with position:absolute; toolbar needs it's z-index to stay above overlay. - */ -* html #toolbar { - position: absolute; - margin: 0; - padding-right: 0; - left: -20px; - right: 0; - width: 100%; -} Index: misc/tableheader.js =================================================================== RCS file: /cvs/drupal/drupal/misc/tableheader.js,v retrieving revision 1.29 diff -u -r1.29 tableheader.js --- misc/tableheader.js 18 Dec 2009 08:17:26 -0000 1.29 +++ misc/tableheader.js 9 May 2010 12:52:06 -0000 @@ -42,7 +42,7 @@ // Track positioning and visibility. function tracker(e) { // Reset top position of sticky table headers to the current top offset. - var topOffset = Drupal.settings.tableHeaderOffset ? eval(Drupal.settings.tableHeaderOffset + '()') : 0; + var topOffset = Drupal.displace ? Drupal.displace.getDisplacement('top') : 0; $('.sticky-header').css('top', topOffset + 'px'); // Save positioning data. var viewHeight = document.documentElement.scrollHeight || document.body.scrollHeight; Index: modules/overlay/overlay.module =================================================================== RCS file: /cvs/drupal/drupal/modules/overlay/overlay.module,v retrieving revision 1.17 diff -u -r1.17 overlay.module --- modules/overlay/overlay.module 24 Apr 2010 07:14:29 -0000 1.17 +++ modules/overlay/overlay.module 9 May 2010 12:52:07 -0000 @@ -300,16 +300,6 @@ } /** - * Preprocess template variables for toolbar.tpl.php. - * - * Adding the 'overlay-displace-top' class to the toolbar pushes the overlay - * down, so it appears below the toolbar. - */ -function overlay_preprocess_toolbar(&$variables) { - $variables['classes_array'][] = "overlay-displace-top"; -} - -/** * Form after_build callback. * * After all hook_form_alter() implementations have been processed, we look at Index: modules/overlay/overlay-parent.js =================================================================== RCS file: /cvs/drupal/drupal/modules/overlay/overlay-parent.js,v retrieving revision 1.40 diff -u -r1.40 overlay-parent.js --- modules/overlay/overlay-parent.js 30 Apr 2010 05:25:19 -0000 1.40 +++ modules/overlay/overlay-parent.js 9 May 2010 12:52:07 -0000 @@ -650,15 +650,9 @@ return; } - // Consider any region that should be visible above the overlay (such as - // an admin toolbar). - var $displaceTop = $('.overlay-displace-top'); - var displaceTopHeight = 0; - $displaceTop.each(function () { - displaceTopHeight += $(this).height(); - }); + var displaceTop = Drupal.displace ? Drupal.displace.getDisplacement('top') : 0; - self.$wrapper.css('top', displaceTopHeight); + self.$wrapper.css('top', displaceTop); // When the overlay has no height yet, make it fit exactly in the window, // or the configured height when autoFit is disabled. @@ -666,7 +660,7 @@ var titleBarHeight = self.$dialogTitlebar.outerHeight(true); if (self.options.autoFit || self.options.height == undefined ||!isNan(self.options.height)) { - self.lastHeight = parseInt($(window).height() - displaceTopHeight - titleBarHeight - 45); + self.lastHeight = parseInt($(window).height() - displaceTop - titleBarHeight - 45); } else { self.lastHeight = self.options.height; @@ -703,11 +697,11 @@ var $target = $(event.target); - if (self.isOpen && $target.closest('.overlay-displace-top, .overlay-displace-bottom').length) { + if (self.isOpen && $target.closest('.displace-top, .displace-bottom').length) { // Click events in displaced regions could potentionally change the size of // that region (e.g. the toggle button of the toolbar module). Trigger the // resize event to force a recalculation of overlay's size/position. - $(window).triggerHandler('resize.overlay-event'); + $(window).triggerHandler('resize'); } // Only continue by left-click or right-click. @@ -929,7 +923,7 @@ var self = this; var windowDomain = window.location.protocol + window.location.hostname; - $('.overlay-displace-top, .overlay-displace-bottom') + $('.displace-top, .displace-bottom') .find('a[href]') // Remove active class from all links in displaced regions. .removeClass('active') Index: modules/system/system.css =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.css,v retrieving revision 1.75 diff -u -r1.75 system.css --- modules/system/system.css 28 Apr 2010 20:08:39 -0000 1.75 +++ modules/system/system.css 9 May 2010 12:52:07 -0000 @@ -255,6 +255,45 @@ } /* +** 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; +} + +/* +** To be used with displace.js +*/ +.displace-top, +.displace-bottom { + position: relative; + width: 100%; +} +html.js .displace-top, +html.js .displace-bottom { + position: fixed; + width: auto; + left: 0; + right: 0; +} +/** + * IE6 shows elements with position:fixed as position:static so replace + * it with position:absolute. + */ +* html.js .displace-top { + position: absolute; +} + +/* ** Floating header for tableheader.js */ table.sticky-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 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,118 @@ +// $Id$ +(function ($) { + +/** + * Provides a generic method to position elements fixed to the viewport. + * + * Fixed positioning (CSS declaration position:fixed) is done relatively 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". + * + * When a browser doesn't support position:fixed (like IE6) the element gets + * positioned relatively to its DOM position. + */ + +/** + * Attaches the displace behavior. + */ +Drupal.behaviors.displace = { + attach: function (context, settings) { + // Test for position:fixed support as IE6 does not. + // http://yura.thinkweb2.com/cft/#IS_POSITION_FIXED_SUPPORTED + if (this.supported === undefined) { + var el = $('
').appendTo(document.body); + this.supported = el[0].offsetTop === 10; + el.remove(); + } + if (!this.supported) { + return; + } + + Drupal.displace.clearCache(); + + $(document.body).once('displace', function () { + $(window).bind('resize.drupal-displace', function () { + $(document.body).css({ + paddingTop: Drupal.displace.getDisplacement('top', true), + paddingBottom: Drupal.displace.getDisplacement('bottom', true) + }); + }); + }); + + $(window).triggerHandler('resize'); + } +}; + +/** + * The displace object. + */ +Drupal.displace = Drupal.displace || {}; + +Drupal.displace.elements = []; +Drupal.displace.displacement = []; + +/** + * Get all displaced elements of given region. + * + * @param region + * Region name. Either "top" or "bottom". + * @param update + * Boolean whether to update the list of displaced elements. + * + * @return + * jQuery object containing all displaced elements of given region. + */ +Drupal.displace.getDisplacedElements = function (region, update) { + if (!this.elements[region] || update) { + this.elements[region] = $('.displace-' + region); + } + return this.elements[region]; +}; + +/** + * Get the total displacement of given region. + * + * @param region + * Region name. Either "top" or "bottom". + * @param update + * Boolean whether to recalculate the displacement. + * + * @return + * The total displacement of given region in pixels. + */ +Drupal.displace.getDisplacement = function (region, update) { + if (!this.displacement[region] || update) { + var offset = 0; + var height = 0; + this.getDisplacedElements(region).each(function () { + offset = offset + height; + height = $(this).css(region, offset).outerHeight(); + + // In IE, Shadow filter adds some extra height, so we need to remove it + // from the returned height. + if (this.filters && this.filters.item('DXImageTransform.Microsoft.Shadow')) { + height -= this.filters.item('DXImageTransform.Microsoft.Shadow').strength; + } + }); + + // Use offset of latest displaced element as the total displacement. + this.displacement[region] = offset + height; + } + + return this.displacement[region]; +}; + +/** + * Clear cache. + */ +Drupal.displace.clearCache = function () { + this.elements = []; + this.displacement = []; +}; + +})(jQuery);