You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2014/03/04 00:19:12 UTC
svn commit: r1573802 - in /myfaces/tobago/branches/tobago-3.0.x:
tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/
tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/
tobago...
Author: lofwyr
Date: Mon Mar 3 23:19:11 2014
New Revision: 1573802
URL: http://svn.apache.org/r1573802
Log:
cleanup
Modified:
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/property/tobago.properties.xml
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/property/tobago_de.properties.xml
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/property/tobago_es.properties.xml
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java?rev=1573802&r1=1573801&r2=1573802&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java Mon Mar 3 23:19:11 2014
@@ -221,6 +221,8 @@ public final class DataAttributes {
public static final String SUGGEST_UPDATE = "data-tobago-suggest-update";
+ public static final String TO_PAGE = "data-tobago-to-page";
+
public static final String TRANSITION = "data-tobago-transition";
/**
Modified: myfaces/tobago/branches/tobago-3.0.x/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/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java?rev=1573802&r1=1573801&r2=1573802&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java Mon Mar 3 23:19:11 2014
@@ -82,6 +82,7 @@ import javax.el.ValueExpression;
import javax.faces.application.Application;
import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
+import javax.faces.component.UINamingContainer;
import javax.faces.context.FacesContext;
import java.io.IOException;
import java.text.MessageFormat;
@@ -218,6 +219,14 @@ public class SheetRenderer extends Layou
writer.endElement(HtmlElements.INPUT);
}
+ writer.startElement(HtmlElements.INPUT, null);
+ writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN, false);
+ final String hiddenId = sheetId + UINamingContainer.getSeparatorChar(facesContext)
+ + PageAction.TO_PAGE.getToken() + ComponentUtils.SUB_SEPARATOR + "value";
+ writer.writeAttribute(HtmlAttributes.NAME, hiddenId, false);
+ writer.writeIdAttribute(hiddenId);
+ writer.endElement(HtmlElements.INPUT);
+
ExpandedState expandedState = null;
StringBuilder expandedValue = null;
if (sheet.isTreeModel()) {
@@ -444,7 +453,7 @@ public class SheetRenderer extends Layou
writer.writeAttribute(HtmlAttributes.TITLE,
ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", "sheetPagingInfoRowPagingTip"), true);
writer.flush(); // is needed in some cases, e. g. TOBAGO-1094
- writer.write(createSheetPagingInfo(sheet, facesContext, pagerCommandId, true));
+ writer.write(createSheetPagingInfoRow(sheet, facesContext, pagerCommandId));
writer.endElement(HtmlElements.SPAN);
}
@@ -452,8 +461,8 @@ public class SheetRenderer extends Layou
final Markup showDirectLinks = markupForLeftCenterRight(sheet.getShowDirectLinks());
if (showDirectLinks != Markup.NULL) {
writer.startElement(HtmlElements.SPAN, null);
- writer.writeClassAttribute(Classes.create(sheet, "pagingOuter", showDirectLinks));
- writer.writeIdAttribute(sheetId + ComponentUtils.SUB_SEPARATOR + "pagingLinks");
+ final String pagingOuter = Classes.create(sheet, "pagingOuter", showDirectLinks).getStringValue();
+ writer.writeClassAttribute(pagingOuter + " tobago-sheet-pagingLinks");
writeDirectPagingLinks(writer, facesContext, application, sheet);
writer.endElement(HtmlElements.SPAN);
}
@@ -469,7 +478,8 @@ public class SheetRenderer extends Layou
final String pagerCommandId = pagerCommand.getClientId(facesContext);
writer.startElement(HtmlElements.SPAN, null);
- writer.writeClassAttribute(Classes.create(sheet, "pagingOuter", showPageRange));
+ final Classes pagingOuter = Classes.create(sheet, "pagingOuter", showPageRange);
+ writer.writeClassAttribute(pagingOuter.getStringValue() + " tobago-sheet-pagingPages");
writer.writeIdAttribute(sheetId + ComponentUtils.SUB_SEPARATOR + "pagingPages");
writer.writeText("");
@@ -481,7 +491,51 @@ public class SheetRenderer extends Layou
writer.writeAttribute(HtmlAttributes.TITLE,
ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", "sheetPagingInfoPagePagingTip"), true);
writer.flush(); // is needed in some cases, e. g. TOBAGO-1094
- writer.write(createSheetPagingInfo(sheet, facesContext, pagerCommandId, false));
+ if (sheet.getRowCount() != 0) {
+ final Locale locale = facesContext.getViewRoot().getLocale();
+ final int first = sheet.getCurrentPage() + 1;
+ final boolean unknown = !sheet.hasRowCount();
+ final int pages = unknown ? -1 : sheet.getPages();
+ final String key;
+ if (unknown) {
+ if (first == pages) {
+ key = "sheetPagingInfoUndefinedSinglePage";
+ } else {
+ key = "sheetPagingInfoUndefinedPages";
+ }
+ } else {
+ if (first == pages) {
+ key = "sheetPagingInfoSinglePage";
+ } else {
+ key = "sheetPagingInfoPages";
+ }
+ }
+ final Object[] args = {
+ first,
+ pages == -1 ? "?" : pages,
+ unknown ? "" : sheet.getRowCount()
+ };
+ final MessageFormat detail1 = new MessageFormat(
+ ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", key + "1"), locale);
+ final MessageFormat detail2 = new MessageFormat(
+ ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", key + "2"), locale);
+ writer.write(detail1.format(args));
+ writer.startElement(HtmlElements.SPAN, null);
+ writer.writeClassAttribute("tobago-sheet-pagingOutput"); // todo
+ writer.writeText(Integer.toString(first));
+ writer.endElement(HtmlElements.SPAN);
+ writer.startElement(HtmlElements.INPUT, null);
+ writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.TEXT, false);
+ writer.writeClassAttribute("tobago-sheet-pagingInput"); // todo
+ writer.writeAttribute(HtmlAttributes.VALUE, first);
+ if (!unknown) {
+ writer.writeAttribute(HtmlAttributes.MAXLENGTH, Integer.toString(pages).length());
+ }
+ writer.endElement(HtmlElements.INPUT);
+ writer.write(detail2.format(args));
+ } else {
+ writer.write(ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", "sheetPagingInfoEmptyPage"));
+ }
writer.endElement(HtmlElements.SPAN);
final boolean atEnd = sheet.isAtEnd();
link(facesContext, application, atEnd, PageAction.NEXT, sheet);
@@ -521,21 +575,30 @@ public class SheetRenderer extends Layou
return false;
}
- private String createSheetPagingInfo(
- final UISheet sheet, final FacesContext facesContext, final String pagerCommandId, final boolean row) {
+ private String createSheetPagingInfoRow(
+ final UISheet sheet, final FacesContext facesContext, final String pagerCommandId) {
final String sheetPagingInfo;
if (sheet.getRowCount() != 0) {
final Locale locale = facesContext.getViewRoot().getLocale();
- final int first = row ? sheet.getFirst() + 1 : sheet.getCurrentPage() + 1;
+ final int first = sheet.getFirst() + 1;
final int last = sheet.hasRowCount()
- ? row ? sheet.getLastRowIndexOfCurrentPage() : sheet.getPages()
+ ? sheet.getLastRowIndexOfCurrentPage()
: -1;
final boolean unknown = !sheet.hasRowCount();
- final String key = "sheetPagingInfo"
- + (unknown ? "Undefined" : "")
- + (first == last ? "Single" : "")
- + (row ? "Row" : "Page")
- + (first == last ? "" : "s"); // plural
+ final String key; // plural
+ if (unknown) {
+ if (first == last) {
+ key = "sheetPagingInfoUndefinedSingleRow";
+ } else {
+ key = "sheetPagingInfoUndefinedRows";
+ }
+ } else {
+ if (first == last) {
+ key = "sheetPagingInfoSingleRow";
+ } else {
+ key = "sheetPagingInfoRows";
+ }
+ }
final String message = ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", key);
final MessageFormat detail = new MessageFormat(message, locale);
final Object[] args = {
@@ -546,9 +609,7 @@ public class SheetRenderer extends Layou
};
sheetPagingInfo = detail.format(args);
} else {
- sheetPagingInfo =
- ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago",
- "sheetPagingInfoEmpty" + (row ? "Row" : "Page"));
+ sheetPagingInfo = ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", "sheetPagingInfoEmptyRow");
}
return sheetPagingInfo;
}
@@ -1001,18 +1062,18 @@ public class SheetRenderer extends Layou
name = "1";
}
}
- writeLinkElement(writer, sheet, name, Integer.toString(skip), pagerCommandId, true);
+ writeLinkElement(writer, sheet, name, skip, true);
}
for (final Integer prev : prevs) {
name = prev.toString();
- writeLinkElement(writer, sheet, name, name, pagerCommandId, true);
+ writeLinkElement(writer, sheet, name, prev, true);
}
name = Integer.toString(sheet.getCurrentPage() + 1);
- writeLinkElement(writer, sheet, name, name, pagerCommandId, false);
+ writeLinkElement(writer, sheet, name, sheet.getCurrentPage() + 1, false);
for (final Integer next : nexts) {
name = next.toString();
- writeLinkElement(writer, sheet, name, name, pagerCommandId, true);
+ writeLinkElement(writer, sheet, name, next, true);
}
skip = nexts.size() > 0 ? nexts.get(nexts.size() - 1) : pages;
@@ -1026,7 +1087,7 @@ public class SheetRenderer extends Layou
name = Integer.toString(skip);
}
}
- writeLinkElement(writer, sheet, name, Integer.toString(skip), pagerCommandId, true);
+ writeLinkElement(writer, sheet, name, skip, true);
}
}
@@ -1043,18 +1104,17 @@ public class SheetRenderer extends Layou
}
private void writeLinkElement(
- final TobagoResponseWriter writer, final UISheet sheet, final String str, final String skip, final String id,
- final boolean makeLink)
+ final TobagoResponseWriter writer, final UISheet sheet, final String text, final int page, final boolean makeLink)
throws IOException {
final String type = makeLink ? HtmlElements.A : HtmlElements.SPAN;
writer.startElement(type, null);
writer.writeClassAttribute(Classes.create(sheet, "pagingLink"));
if (makeLink) {
- writer.writeIdAttribute(id + ComponentUtils.SUB_SEPARATOR + "link_" + skip);
+ writer.writeAttribute(DataAttributes.TO_PAGE, page);
writer.writeAttribute(HtmlAttributes.HREF, "#", true);
}
writer.flush();
- writer.write(str);
+ writer.write(text);
writer.endElement(type);
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/property/tobago.properties.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/property/tobago.properties.xml?rev=1573802&r1=1573801&r2=1573802&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/property/tobago.properties.xml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/property/tobago.properties.xml Mon Mar 3 23:19:11 2014
@@ -50,11 +50,15 @@
<entry key="sheetPagingInfoUndefinedSingleRow">Row <span id="{3}">{0}</span></entry>
<entry key="sheetPagingInfoEmptyRow">No rows available</entry>
<entry key="sheetPagingInfoRowPagingTip">Click here, to change the first displayed row</entry>
- <entry key="sheetPagingInfoPages">Page <span id="{3}">{0}</span> of {1}</entry>
- <entry key="sheetPagingInfoSinglePage">Page <span id="{3}">{0}</span> of {1}</entry>
- <entry key="sheetPagingInfoUndefinedPages">Page <span id="{3}">{0}</span></entry>
- <entry key="sheetPagingInfoUndefinedSinglePage">Page <span id="{3}">{0}</span></entry>
- <entry key="sheetPagingInfoEmptyPage"></entry>
+ <entry key="sheetPagingInfoPages1">Page </entry>
+ <entry key="sheetPagingInfoPages2"> of {1}</entry>
+ <entry key="sheetPagingInfoSinglePage1">Page </entry>
+ <entry key="sheetPagingInfoSinglePage2"> of {1}</entry>
+ <entry key="sheetPagingInfoUndefinedPages1">Page </entry>
+ <entry key="sheetPagingInfoUndefinedPages2"/>
+ <entry key="sheetPagingInfoUndefinedSinglePage1">Page </entry>
+ <entry key="sheetPagingInfoUndefinedSinglePage2"/>
+ <entry key="sheetPagingInfoEmptyPage"/>
<entry key="sheetPagingInfoPagePagingTip">Click here, to change the displayed page</entry>
<entry key="sheetMenuToggleselect">Invert selections</entry>
<entry key="sheetMenuUnselect">Unselect all</entry>
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/property/tobago_de.properties.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/property/tobago_de.properties.xml?rev=1573802&r1=1573801&r2=1573802&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/property/tobago_de.properties.xml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/property/tobago_de.properties.xml Mon Mar 3 23:19:11 2014
@@ -52,11 +52,15 @@
<entry key="sheetPagingInfoUndefinedSingleRow">Zeile <span id="{3}">{0}</span></entry>
<entry key="sheetPagingInfoEmptyRow">Keine Zeilen verf&uuml;gbar</entry>
<entry key="sheetPagingInfoRowPagingTip">Hier klicken, zum Eingeben der ersten anzuzeigenden Zeile.</entry>
- <entry key="sheetPagingInfoPages">Seite <span id="{3}">{0}</span> von {1}</entry>
- <entry key="sheetPagingInfoSinglePage">Seite <span id="{3}">{0}</span> von {1}</entry>
- <entry key="sheetPagingInfoUndefinedPages">Seite <span id="{3}">{0}</span></entry>
- <entry key="sheetPagingInfoUndefinedSinglePage">Seite <span id="{3}">{0}</span></entry>
- <entry key="sheetPagingInfoEmptyPage"></entry>
+ <entry key="sheetPagingInfoPages1">Seite </entry>
+ <entry key="sheetPagingInfoPages2"> von {1}</entry>
+ <entry key="sheetPagingInfoSinglePage1">Seite </entry>
+ <entry key="sheetPagingInfoSinglePage2"> von {1}</entry>
+ <entry key="sheetPagingInfoUndefinedPages1">Seite </entry>
+ <entry key="sheetPagingInfoUndefinedPages2"/>
+ <entry key="sheetPagingInfoUndefinedSinglePage1">Seite </entry>
+ <entry key="sheetPagingInfoUndefinedSinglePage2"/>
+ <entry key="sheetPagingInfoEmptyPage"/>
<entry key="sheetPagingInfoPagePagingTip">Hier klicken, zum Eingeben der anzuzeigenden Seite.</entry>
<entry key="sheetMenuToggleselect">Markierung umkehren</entry>
<entry key="sheetMenuUnselect">Markierungen löschen</entry>
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/property/tobago_es.properties.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/property/tobago_es.properties.xml?rev=1573802&r1=1573801&r2=1573802&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/property/tobago_es.properties.xml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/property/tobago_es.properties.xml Mon Mar 3 23:19:11 2014
@@ -50,11 +50,15 @@
<entry key="sheetPagingInfoUndefinedSingleRow">Registro <span id="{3}">{0}</span></entry>
<entry key="sheetPagingInfoEmptyRow">No hay registros disponibles</entry>
<entry key="sheetPagingInfoRowPagingTip">Click aqui, para cambiar el primer registro desplegado.</entry>
- <entry key="sheetPagingInfoPages">Página <span id="{3}">{0}</span> de {1}</entry>
- <entry key="sheetPagingInfoSinglePage">Página <span id="{3}">{0}</span> de {1}</entry>
- <entry key="sheetPagingInfoUndefinedPages">Página <span id="{3}">{0}</span></entry>
- <entry key="sheetPagingInfoUndefinedSinglePage">Página <span id="{3}">{0}</span></entry>
- <entry key="sheetPagingInfoEmptyPage"></entry>
+ <entry key="sheetPagingInfoPages1">Página </entry>
+ <entry key="sheetPagingInfoPages2"> de {1}</entry>
+ <entry key="sheetPagingInfoSinglePage1">Página </entry>
+ <entry key="sheetPagingInfoSinglePage2"> de {1}</entry>
+ <entry key="sheetPagingInfoUndefinedPages1">Página </entry>
+ <entry key="sheetPagingInfoUndefinedPages2"/>
+ <entry key="sheetPagingInfoUndefinedSinglePage1">Página </entry>
+ <entry key="sheetPagingInfoUndefinedSinglePage2"/>
+ <entry key="sheetPagingInfoEmptyPage"/>
<entry key="sheetPagingInfoPagePagingTip">Click aquÃ, para cambiar el nombre desplegado.</entry>
<entry key="sheetMenuToggleselect">Invertir seleccion</entry>
<entry key="sheetMenuUnselect">Deseleccionar todo</entry>
Modified: myfaces/tobago/branches/tobago-3.0.x/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/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js?rev=1573802&r1=1573801&r2=1573802&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js Mon Mar 3 23:19:11 2014
@@ -112,21 +112,9 @@ Tobago.Sheet.prototype.setupSortHeaders
});
};
-Tobago.Sheet.prototype.setupPagingLinks = function() {
- idPrefix = this.id + Tobago.SUB_COMPONENT_SEP;
- var linkBox = Tobago.element(idPrefix + "pagingLinks");
- if (linkBox) {
- for (i = 0 ; i < linkBox.childNodes.length ; i++) {
- var child = linkBox.childNodes[i];
- if (child.nodeType == 1 && child.tagName.toUpperCase() == "A") {
- Tobago.addBindEventListener(child, "click", this, "doPagingDirect");
- }
- }
- }
- };
-
Tobago.Sheet.prototype.setupPagePaging = function() {
- linkBox = Tobago.element(idPrefix + "pagingPages");
+ var idPrefix = this.id + Tobago.SUB_COMPONENT_SEP;
+ var linkBox = Tobago.element(idPrefix + "pagingPages");
if (linkBox) {
for (var i = 0 ; i < linkBox.childNodes.length ; i++) {
var child = linkBox.childNodes[i];
@@ -135,9 +123,6 @@ Tobago.Sheet.prototype.setupPagePaging =
if (undefined == jQuery(child).attr("data-tobago-disabled")) {
Tobago.addBindEventListener(child, "click", this, "doPaging");
}
- } else if (child.nodeType == 1 && child.tagName.toUpperCase() == "SPAN") {
- var toPageId = this.id + Tobago.COMPONENT_SEP + "ToPage";
- Tobago.addEventListener(child, "click", Tobago.bind(this, "insertTarget", toPageId));
}
}
}
@@ -152,22 +137,6 @@ Tobago.Sheet.prototype.setupRowPaging =
}
};
-
-Tobago.Sheet.prototype.doPagingDirect = function(event) {
- var element = Tobago.element(event);
- var action = this.id + Tobago.COMPONENT_SEP + "ToPage";
-
- var page = element.id.lastIndexOf('_');
- page = element.id.substring(page + 1);
- var hidden = document.createElement('input');
- hidden.type = 'hidden';
- hidden.value = page;
- hidden.name = action + Tobago.SUB_COMPONENT_SEP + "value";
- Tobago.element(this.id).appendChild(hidden);
-
- this.reloadWithAction(event.srcElement, action);
- };
-
Tobago.Sheet.prototype.doPaging = function(event) {
var element = Tobago.element(event);
var action = "unset";
@@ -201,7 +170,7 @@ Tobago.Sheet.prototype.afterDoUpdateErro
};
Tobago.Sheet.prototype.insertTarget = function(event, actionId) {
-// console.debug("insertTarget('" + actionId + "')")
+ console.debug("insertTarget('{1}')", actionId);
var textId = actionId + Tobago.SUB_COMPONENT_SEP + "text";
var text = Tobago.element(textId);
if (text) {
@@ -222,7 +191,7 @@ Tobago.Sheet.prototype.insertTarget = fu
span.insertBefore(input, text);
}
input.value=text.innerHTML;
- input.style.display = '';
+ input.style.display = 'inline';
text.style.display = 'none';
input.focus();
input.select();
@@ -447,6 +416,63 @@ Tobago.Sheet.setup2 = function (sheets)
Tobago.Sheets.get(sheet.attr("id")).initReload();
});
+ // init pagingLinks
+ jQuery(sheets).find(".tobago-sheet-pagingLinks").find("a").click(function() {
+ var anchor = jQuery(this);
+ var sheet = anchor.parents(".tobago-sheet:first");
+ var sheetId = sheet.attr("id");
+ var hiddenId = sheetId + ":ToPage::value";
+ var hidden = jQuery(Tobago.Utils.escapeClientId(hiddenId));
+ var toPage = anchor.data("tobago-to-page");
+ hidden.val(toPage);
+ console.info("adding direct link " + anchor.html());
+ console.info("action=" + sheetId + Tobago.COMPONENT_SEP + "ToPage");
+ console.info("page=" + toPage);
+ Tobago.Sheets.get(sheetId).reloadWithAction(anchor.get(0), sheetId + Tobago.COMPONENT_SEP + "ToPage");
+ });
+
+ // init paging by pages
+ jQuery(sheets).find(".tobago-sheet-pagingPages").each(function() {
+ var pagingPages = jQuery(this);
+ pagingPages.find(".tobago-sheet-pagingOutput").parent().click(function () {
+ console.info("click on text");
+ var parent = jQuery(this);
+ parent.children(".tobago-sheet-pagingOutput").hide();
+ parent.children(".tobago-sheet-pagingInput").show().focus().select();
+ });
+ pagingPages.find(".tobago-sheet-pagingInput")
+ .blur(function () {
+ console.info("blur");
+ Tobago.Sheet.hideInputOrSubmit(jQuery(this));
+ }).keydown(function (event) {
+ console.info("keydown");
+ console.dir(event);
+ if (event.keyCode == 13) {
+ event.stopPropagation();
+ event.preventDefault();
+ jQuery(this).blur();
+ }
+ });
+ });
+};
+
+Tobago.Sheet.hideInputOrSubmit = function(input) {
+ var output = input.siblings(".tobago-sheet-pagingOutput");
+ var changed = output.html() != input.val();
+ var sheet = input.parents(".tobago-sheet:first");
+ var sheetId = sheet.attr("id");
+ output.html(input.val());
+ var hiddenId = sheetId + ":ToPage::value";
+ var hidden = jQuery(Tobago.Utils.escapeClientId(hiddenId));
+ hidden.val(input.val());
+ if (changed) {
+ console.error("not implemented");
+ Tobago.Sheets.get(sheetId).reloadWithAction(input.get(0), sheetId + Tobago.COMPONENT_SEP + "ToPage");
+ } else {
+ console.info("no update needed");
+ input.hide();
+ output.show();
+ }
};
/** Returns the specific hidden field of a sheet
@@ -475,7 +501,6 @@ Tobago.Sheet.prototype.setup = function(
}
this.setupSortHeaders();
- this.setupPagingLinks();
this.setupPagePaging();
this.setupRowPaging();
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css?rev=1573802&r1=1573801&r2=1573802&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css Mon Mar 3 23:19:11 2014
@@ -69,3 +69,9 @@ table.tobago-gridLayout > tbody > tr > t
table.tobago-gridLayout > tbody > tr:first-child > td {
border-top: 0;
}
+
+/* sheet -------------------------------------------------------------- */
+
+.tobago-sheet-pagingInput {
+ display: none;
+}