You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2014/11/05 17:11:39 UTC
svn commit: r1636911 - in
/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main:
java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/
resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/
Author: weber
Date: Wed Nov 5 16:11:38 2014
New Revision: 1636911
URL: http://svn.apache.org/r1636911
Log:
TOBAGO-1423 - Sheet: forceVerticalScrollbar="true" breaks column alignment
Modified:
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java?rev=1636911&r1=1636910&r2=1636911&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java Wed Nov 5 16:11:38 2014
@@ -259,23 +259,32 @@ public class SheetRenderer extends Layou
/*
bodyStyle.setPaddingTop(ie6SelectOneFix ? Measure.ZERO : headerHeight);
*/
- final boolean needVerticalScrollbar = needVerticalScrollbar(facesContext, sheet);
-
writer.writeStyleAttribute(bodyStyle);
- bodyStyle.setHeight(null);
- bodyStyle.setTop(null);
+
final Style sheetBodyStyle = new Style(bodyStyle);
+ sheetBodyStyle.setHeight(null);
+ sheetBodyStyle.setTop(null);
+ final boolean needVerticalScrollbar = needVerticalScrollbar(facesContext, sheet);
+ if (needVerticalScrollbar) {
+ tableBodyWidth = tableBodyWidth.subtractNotNegative(getVerticalScrollbarWeight(facesContext, sheet));
+ }
+ List<Integer> dataWidths = null;
if (columnWidths != null) {
- int tmp = 0;
- for (Integer columnWidth : columnWidths) {
- tmp += columnWidth;
+ dataWidths = new ArrayList<Integer>(columnWidths);
+ int usedWidth = 0;
+ for (int i = 0, dataWidthsSize = dataWidths.size(); i < dataWidthsSize - 1; i++) {
+ usedWidth += dataWidths.get(i);
+ }
+ if (usedWidth < tableBodyWidth.getPixel()) {
+ dataWidths.set(dataWidths.size() - 1, tableBodyWidth.getPixel() - usedWidth);
+ sheetBodyStyle.setWidth(tableBodyWidth);
+ } else {
+ dataWidths.set(dataWidths.size() - 1, 0);
+ sheetBodyStyle.setWidth(Measure.valueOf(usedWidth));
}
- sheetBodyStyle.setWidth(Measure.valueOf(tmp));
+
} else {
- // is null, in AJAX case.
- if (needVerticalScrollbar) {
- tableBodyWidth = tableBodyWidth.subtractNotNegative(getVerticalScrollbarWeight(facesContext, sheet));
- }
+ // is null, in AJAX case. // XXX ? how to reproduce ?
sheetBodyStyle.setWidth(tableBodyWidth);
}
@@ -286,9 +295,9 @@ public class SheetRenderer extends Layou
writer.writeClassAttribute(Classes.create(sheet, "bodyTable"));
writer.writeStyleAttribute(sheetBodyStyle);
- if (columnWidths != null) {
+ if (dataWidths != null) {
writer.startElement(HtmlElements.COLGROUP, null);
- for (final Integer columnWidth : columnWidths) {
+ for (final Integer columnWidth : dataWidths) {
writer.startElement(HtmlElements.COL, null);
writer.writeAttribute(HtmlAttributes.WIDTH, columnWidth);
writer.endElement(HtmlElements.COL);
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js?rev=1636911&r1=1636910&r2=1636911&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js Wed Nov 5 16:11:38 2014
@@ -286,26 +286,7 @@ Tobago.Sheet.setup2 = function (sheets)
var verticalScrollbarWidth = table.data("tobago-sheet-verticalscrollbarwidth");
if (verticalScrollbarWidth !== undefined) {
var bodyDiv = table.parent().next();
- var bodyHeight = bodyDiv.css("height").replace("px", "");
- var scrollHeight = bodyDiv.prop("scrollHeight");
- console.log("bodyHeight : " + bodyHeight); // @DEV_ONLY
- console.log("scrollHeight : " + scrollHeight); // @DEV_ONLY
- if (bodyHeight >= scrollHeight) {
- table = bodyDiv.find("table");
- var bodyDivWidth = bodyDiv.css("width").replace("px", "") * 1;
- console.log("bodyDivWidth : " + bodyDivWidth); // @DEV_ONLY
- var tableWidth = table.css("width").replace("px", "") * 1;
- console.log("tableWidth : " + tableWidth); // @DEV_ONLY
- if (tableWidth < bodyDivWidth) {
-
- var fillerWidth = bodyDiv.prev().find("col").last().attr("width").replace("px", "") * 1;
- console.log("set filler col width : " + fillerWidth); // @DEV_ONLY
- table.find("col").last().attr("width", fillerWidth);
-
- console.log("set table width : " + bodyDivWidth); // @DEV_ONLY
- table.css("width", bodyDivWidth);
- }
- }
+ Tobago.Sheet.adjustTableWidth(bodyDiv);
}
});
@@ -354,26 +335,26 @@ Tobago.Sheet.setup2 = function (sheets)
var sheet = event.data.sheet;
var headerTable = sheet.find(".tobago-sheet-headerTable");
var bodyTable = sheet.find(".tobago-sheet-bodyTable");
- var headerList = headerTable.find("col");
- var bodyList = bodyTable.find("col");
+ var headerCols = headerTable.find("col");
+ var bodyCols = bodyTable.find("col");
var widths = ",";
var oldWidthList = [];
var i;
- for (i = 0; i < bodyList.length; i++) {
- oldWidthList[i] = bodyList.eq(i).width();
+ for (i = 0; i < bodyCols.length; i++) {
+ oldWidthList[i] = bodyCols.eq(i).width();
}
var usedWidth = 0;
- for (i = 0; i < headerList.length -1; i++) {
+ for (i = 0; i < headerCols.length -1; i++) {
// last column is the filler column
- var newWidth = headerList.eq(i).width();
+ var newWidth = headerCols.eq(i).width();
// for the hidden field
widths = widths + newWidth + ",";
usedWidth += newWidth;
- var oldWidth = bodyList.eq(i).width();
+ var oldWidth = bodyCols.eq(i).width();
if (oldWidth != newWidth) {
// set to the body
- bodyList.eq(i).attr("width", newWidth);
+ bodyCols.eq(i).attr("width", newWidth);
// reset the width inside of the cells (TD) if the value was changed.
var tds = jQuery("td:nth-child(" + (i + 1) + ")", bodyTable);
if (tds.size() > 0) {
@@ -385,22 +366,39 @@ Tobago.Sheet.setup2 = function (sheets)
}
}
// adjust filler space
- var sheetHeaderWidth = headerTable.parent().width();
+ var bodyDiv = bodyTable.parent();
+ var bodyDivWidth = bodyDiv.css("width").replace("px", "") * 1;
console.log("usedWidth : " + usedWidth); // @DEV_ONLY
- console.log("sheetHeaderWidth : " + sheetHeaderWidth); // @DEV_ONLY
+ console.log("bodyDivWidth : " + bodyDivWidth); // @DEV_ONLY
+ var bodyHeight = bodyDiv.css("height").replace("px", "");
+ var scrollHeight = bodyDiv.prop("scrollHeight");
+ console.log("bodyHeight : " + bodyHeight); // @DEV_ONLY
+ console.log("scrollHeight : " + scrollHeight); // @DEV_ONLY
+ var verticalScrollbarWidth = 0;
+ if (bodyHeight < scrollHeight) {
+ verticalScrollbarWidth = headerTable.data("tobago-sheet-verticalscrollbarwidth");
+ if (verticalScrollbarWidth) {
+ bodyDivWidth -= verticalScrollbarWidth;
+ }
+ }
- if (usedWidth <= sheetHeaderWidth) {
- var fillerWidth = sheetHeaderWidth - usedWidth;
+ if (usedWidth <= bodyDivWidth) {
+ var fillerWidth = bodyDivWidth - usedWidth;
console.log("SET fillerWidth : " + fillerWidth); // @DEV_ONLY
widths = widths + fillerWidth + ",";
- headerList.last().attr("width", fillerWidth);
- bodyList.last().attr("width", fillerWidth); // TODO ? verticalScrollbarWidth
- bodyTable.css("width", sheetHeaderWidth); // TODO ? verticalScrollbarWidth
+ headerCols.last().attr("width", fillerWidth + verticalScrollbarWidth);
+ bodyCols.last().attr("width", fillerWidth);
+ bodyTable.css("width", bodyDivWidth);
} else {
console.log("SET fillerWidth : 0"); // @DEV_ONLY
- widths = widths + "0,";
- headerList.last().attr("width", 0);
- bodyList.last().attr("width", 0); // TODO ? verticalScrollbarWidth
+ bodyCols.last().attr("width", 0);
+ bodyTable.css("width", usedWidth);
+ var headerFiller = 0;
+ if (usedWidth <= (bodyDivWidth + verticalScrollbarWidth)) {
+ headerFiller = (bodyDivWidth + verticalScrollbarWidth) - usedWidth;
+ }
+ widths = widths + headerFiller + ",";
+ headerCols.last().attr("width", headerFiller);
}
// store the width values in a hidden field
Tobago.Sheet.hidden(sheet, "widths").val(widths);
@@ -478,6 +476,29 @@ Tobago.Sheet.setup2 = function (sheets)
};
+Tobago.Sheet.adjustTableWidth = function(bodyDiv) {
+ var bodyHeight = bodyDiv.css("height").replace("px", "");
+ var scrollHeight = bodyDiv.prop("scrollHeight");
+ console.log("bodyHeight : " + bodyHeight); // @DEV_ONLY
+ console.log("scrollHeight : " + scrollHeight); // @DEV_ONLY
+ if (bodyHeight >= scrollHeight) {
+ var table = bodyDiv.find("table");
+ var bodyDivWidth = bodyDiv.css("width").replace("px", "") * 1;
+ console.log("bodyDivWidth : " + bodyDivWidth); // @DEV_ONLY
+ var tableWidth = table.css("width").replace("px", "") * 1;
+ console.log("tableWidth : " + tableWidth); // @DEV_ONLY
+ if (tableWidth < bodyDivWidth) {
+
+ var fillerWidth = bodyDiv.prev().find("col").last().attr("width").replace("px", "") * 1;
+ console.log("set filler col width : " + fillerWidth); // @DEV_ONLY
+ table.find("col").last().attr("width", fillerWidth);
+
+ console.log("set table width : " + bodyDivWidth); // @DEV_ONLY
+ table.css("width", bodyDivWidth);
+ }
+ }
+};
+
/** Returns the specific hidden field of a sheet
* @param sheet The sheet as jQuery Object
* @param idSuffix The if suffix of the hidden field