From 88e565bdf56c2d29a940289a453e9a0ac93b1d9c Mon Sep 17 00:00:00 2001 From: "Kenneth G. Franqueiro" Date: Mon, 10 Dec 2012 10:14:41 -0500 Subject: [PATCH] ColumnSet: fix clicking in scrollbar "gap" in IE and fix bodyNode adjustment --- ColumnSet.js | 18 ++++++++++++++---- List.js | 41 ++++++++++++++++++++++++++++++++--------- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/ColumnSet.js b/ColumnSet.js index 36fa68083..eeb3ab334 100644 --- a/ColumnSet.js +++ b/ColumnSet.js @@ -24,8 +24,11 @@ function(kernel, declare, Deferred, listen, aspect, query, has, put, hasClass, G scrollers = grid._columnSetScrollers, scrollerContents = grid._columnSetScrollerContents, columnSets = grid.columnSets, - left = 0, scrollerWidth = 0, + left = 0, + scrollerWidth = 0, + numScrollers = 0, // tracks number of visible scrollers (sets w/ overflow) i, l, columnSetElement, contentWidth; + for(i = 0, l = columnSets.length; i < l; i++){ // iterate through the columnSets left += scrollerWidth; @@ -34,9 +37,17 @@ function(kernel, declare, Deferred, listen, aspect, query, has, put, hasClass, G contentWidth = columnSetElement.firstChild.offsetWidth; scrollerContents[i].style.width = contentWidth + "px"; scrollers[i].style.width = scrollerWidth + "px"; - scrollers[i].style.overflowX = contentWidth > scrollerWidth ? "scroll" : "auto"; // IE seems to need it be set explicitly + // IE seems to need scroll to be set explicitly + scrollers[i].style.overflowX = contentWidth > scrollerWidth ? "scroll" : "auto"; scrollers[i].style.left = left + "px"; - } + // Keep track of how many scrollbars we're showing + if(contentWidth > scrollerWidth){ numScrollers++; } + } + + // Align bottom of body node depending on whether there are scrollbars + grid.bodyNode.style.bottom = numScrollers ? + (has("dom-scrollbar-height") + (has("ie") ? 1 : 0) + "px") : + "0"; } function adjustScrollLeft(grid, row){ var scrollLefts = grid._columnSetScrollLefts; @@ -146,7 +157,6 @@ function(kernel, declare, Deferred, listen, aspect, query, has, put, hasClass, G // summary: // Setup the headers for the grid this.inherited(arguments); - this.bodyNode.style.bottom = "17px"; var columnSets = this.columnSets, domNode = this.domNode, diff --git a/List.js b/List.js index 89d6c6a19..8fa782b89 100644 --- a/List.js +++ b/List.js @@ -5,12 +5,32 @@ function(arrayUtil, kernel, declare, listen, has, miscUtil, TouchScroll, hasClas var oddClass = "dgrid-row-odd", evenClass = "dgrid-row-even", - scrollbarWidth; - + scrollbarWidth, scrollbarHeight; + function byId(id){ return document.getElementById(id); } - + + function getScrollbarSize(node, dimension){ + // Used by has tests for scrollbar width/height + var body = document.body, + size; + + put(body, node, ".dgrid-scrollbar-measure"); + size = node["offset" + dimension] - node["client" + dimension]; + + put(node, "!dgrid-scrollbar-measure"); + body.removeChild(node); + + return size; + } + has.add("dom-scrollbar-width", function(global, doc, element){ + return getScrollbarSize(element, "Width"); + }); + has.add("dom-scrollbar-height", function(global, doc, element){ + return getScrollbarSize(element, "Height"); + }); + // var and function for autogenerating ID when one isn't provided var autogen = 0; function generateId(){ @@ -245,16 +265,19 @@ function(arrayUtil, kernel, declare, listen, has, miscUtil, TouchScroll, hasClas if(!scrollbarWidth){ // Measure the browser's scrollbar width using a DIV we'll delete right away - var scrollDiv = put(document.body, "div.dgrid-scrollbar-measure"); - scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; - put(scrollDiv, "!"); + scrollbarWidth = has("dom-scrollbar-width"); + scrollbarHeight = has("dom-scrollbar-height"); - // avoid crazy issues in IE7 only, with certain widgets inside - if(has("ie") === 7){ scrollbarWidth++; } + // Avoid issues with certain widgets inside in IE7, and + // ColumnSet scroll issues with all supported IE versions + if(has("ie")){ + scrollbarWidth++; + scrollbarHeight++; + } // add rules that can be used where scrollbar width/height is needed miscUtil.addCssRule(".dgrid-scrollbar-width", "width: " + scrollbarWidth + "px"); - miscUtil.addCssRule(".dgrid-scrollbar-height", "height: " + scrollbarWidth + "px"); + miscUtil.addCssRule(".dgrid-scrollbar-height", "height: " + scrollbarHeight + "px"); if(scrollbarWidth != 17 && !quirks){ // for modern browsers, we can perform a one-time operation which adds