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 2011/06/21 17:17:10 UTC

svn commit: r1138042 - in /myfaces/tobago/trunk/tobago-theme: tobago-theme-scarborough/ tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ tobago-theme-scarborough/src/main/resources/org/apache/myf...

Author: lofwyr
Date: Tue Jun 21 15:17:08 2011
New Revision: 1138042

URL: http://svn.apache.org/viewvc?rev=1138042&view=rev
Log:
TOBAGO-1003: Clean up javascript for sheet

Removed:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-sheet.js
Modified:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.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-scarborough/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml?rev=1138042&r1=1138041&r2=1138042&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml Tue Jun 21 15:17:08 2011
@@ -52,7 +52,7 @@
             <configuration>
               <target>
                 <concat destfile="${project.build.directory}/javascript-min/scarborough/script/tobago.min.js">
-                  <filelist dir="${basedir}/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script" files="tobago-sheet.js" />
+                  <filelist dir="${basedir}/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script" files="tobago.js" />
                 </concat>
                 <replaceregexp match="^.*//.*@DEV_ONLY.*$" replace="" byline="true">
                   <fileset dir="${project.build.directory}/javascript-min">

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java?rev=1138042&r1=1138041&r2=1138042&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Tue Jun 21 15:17:08 2011
@@ -434,12 +434,9 @@ public class SheetRenderer extends Layou
           pagerCommand = createPagingCommand(application, PageAction.TO_ROW, false);
           sheet.getFacets().put(Facets.PAGER_ROW, pagerCommand);
         }
-        String pagingOnClick = new CommandRendererHelper(facesContext, pagerCommand).getOnclickDoubleQuoted();
         final String pagerCommandId = pagerCommand.getClientId(facesContext);
 
         writer.startElement(HtmlElements.SPAN, null);
-        writer.writeAttribute(HtmlAttributes.ONCLICK,
-            "tobagoSheetEditPagingRow(this, '" + pagerCommandId + "', '" + pagingOnClick + "')", true);
         writer.writeClassAttribute(Classes.create(sheet, "pagingOuter", showRowRange));
         writer.writeAttribute(HtmlAttributes.TITLE,
             ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", "sheetPagingInfoRowPagingTip"), true);
@@ -466,7 +463,6 @@ public class SheetRenderer extends Layou
           pagerCommand = createPagingCommand(application, PageAction.TO_PAGE, false);
           sheet.getFacets().put(Facets.PAGER_PAGE, pagerCommand);
         }
-        String pagingOnClick = new CommandRendererHelper(facesContext, pagerCommand).getOnclickDoubleQuoted();
         final String pagerCommandId = pagerCommand.getClientId(facesContext);
 
         writer.startElement(HtmlElements.SPAN, null);
@@ -479,8 +475,6 @@ public class SheetRenderer extends Layou
         link(facesContext, application, atBeginning, PageAction.PREV, sheet);
         writer.startElement(HtmlElements.SPAN, null);
         writer.writeClassAttribute(Classes.create(sheet, "pagingText"));
-        writer.writeAttribute(HtmlAttributes.ONCLICK,
-            "tobagoSheetEditPagingRow(this, '" + pagerCommandId + "', '" + pagingOnClick + "')", true);
         writer.writeAttribute(HtmlAttributes.TITLE,
             ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", "sheetPagingInfoPagePagingTip"), true);
         writer.writeText("");
@@ -775,8 +769,7 @@ public class SheetRenderer extends Layou
         column.getFacets().put(Facets.SORTER, sortCommand);
       }
 
-      String onclick = "Tobago.submitAction(this, '" + sortCommand.getClientId(facesContext) + "')";
-      writer.writeAttribute(HtmlAttributes.ONCLICK, onclick, false);
+      writer.writeAttribute("sorterId", sortCommand.getClientId(facesContext), false);
 
       if (org.apache.commons.lang.StringUtils.isNotEmpty(tip)) {
         tip += " - ";
@@ -887,14 +880,10 @@ public class SheetRenderer extends Layou
       throws IOException {
     UICommand pagerCommand = (UICommand) sheet.getFacet(Facets.PAGER_PAGE);
     if (pagerCommand == null) {
-      pagerCommand = createPagingCommand(
-          application, PageAction.TO_PAGE, false);
+      pagerCommand = createPagingCommand(application, PageAction.TO_PAGE, false);
       sheet.getFacets().put(Facets.PAGER_PAGE, pagerCommand);
     }
     String pagerCommandId = pagerCommand.getClientId(facesContext);
-    String onclick = new CommandRendererHelper(facesContext, pagerCommand).getOnclickDoubleQuoted();
-    String hrefPostfix = "', '" + onclick + "');";
-
     int linkCount = ComponentUtils.getIntAttribute(sheet, Attributes.DIRECT_LINK_COUNT);
     linkCount--;  // current page needs no link
     ArrayList<Integer> prevs = new ArrayList<Integer>(linkCount);
@@ -945,19 +934,18 @@ public class SheetRenderer extends Layou
           name = "1";
         }
       }
-      writeLinkElement(writer, sheet, name, Integer.toString(skip),
-          pagerCommandId, hrefPostfix, true);
+      writeLinkElement(writer, sheet, name, Integer.toString(skip), pagerCommandId, true);
     }
     for (Integer prev : prevs) {
       name = prev.toString();
-      writeLinkElement(writer, sheet, name, name, pagerCommandId, hrefPostfix, true);
+      writeLinkElement(writer, sheet, name, name, pagerCommandId, true);
     }
     name = Integer.toString(sheet.getPage());
-    writeLinkElement(writer, sheet, name, name, pagerCommandId, hrefPostfix, false);
+    writeLinkElement(writer, sheet, name, name, pagerCommandId, false);
 
     for (Integer next : nexts) {
       name = next.toString();
-      writeLinkElement(writer, sheet, name, name, pagerCommandId, hrefPostfix, true);
+      writeLinkElement(writer, sheet, name, name, pagerCommandId, true);
     }
 
     skip = nexts.size() > 0 ? nexts.get(nexts.size() - 1) : sheet.getPages();
@@ -971,7 +959,7 @@ public class SheetRenderer extends Layou
           name = Integer.toString(skip);
         }
       }
-      writeLinkElement(writer, sheet, name, Integer.toString(skip), pagerCommandId, hrefPostfix, true);
+      writeLinkElement(writer, sheet, name, Integer.toString(skip), pagerCommandId, true);
     }
   }
 
@@ -987,16 +975,14 @@ public class SheetRenderer extends Layou
   }
 
   private void writeLinkElement(
-      TobagoResponseWriter writer, UISheet sheet, String str, String skip, String id, String hrefPostfix,
-      boolean makeLink)
+      TobagoResponseWriter writer, UISheet sheet, String str, String skip, String id, boolean makeLink)
       throws IOException {
     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(
-          HtmlAttributes.HREF, "javascript: tobagoSheetSetPagerPage('" + id + "', '" + skip + hrefPostfix, true);
+      writer.writeAttribute(HtmlAttributes.HREF, "#", true);
     }
     writer.flush();
     writer.write(str);

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java?rev=1138042&r1=1138041&r2=1138042&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java Tue Jun 21 15:17:08 2011
@@ -217,11 +217,6 @@ public class CommandRendererHelper {
     return onclick;
   }
 
-  public String getOnclickDoubleQuoted() {
-    return onclick.replace('\'', '\"');
-    
-  }
-
   public boolean isDisabled() {
     return disabled;
   }

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=1138042&r1=1138041&r2=1138042&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 Tue Jun 21 15:17:08 2011
@@ -85,33 +85,19 @@ Tobago.Sheet = function(sheetId, firstRo
   LOG.debug("Sheet-total time = " + (this.endTime.getTime() - this.startTime.getTime())); // @DEV_ONLY
 };
 
-Tobago.Sheet.prototype.sortOnclickRegExp
-      = new RegExp("Tobago.submitAction\\(this, ('|\")(.*?)('|\")\\)");
-
 Tobago.Sheet.prototype.setupSortHeaders = function() {
-    var i = 0;
-    var idPrefix = this.id + Tobago.SUB_COMPONENT_SEP + "header_box_";
-    var headerBox = Tobago.element(idPrefix + i++);
-    while (headerBox) {
-      if (headerBox.onclick) {
-        var match = this.sortOnclickRegExp.exec(headerBox.onclick.valueOf());
-//        LOG.debug("match[0] = " + match[0]);
-//        LOG.debug("match[1] = " + match[1]);
-//        LOG.debug("*match[2] = " + match[2]);
-//        LOG.debug("match[3] = " + match[3]);
-//        LOG.debug("match[4] = " + match[4]);
-//        LOG.debug("match[5] = " + match[5]);
-//        LOG.debug("match[6] = " + match[6]);
-//        headerBox.formId = match[2];
-        headerBox.sorterId = match[2];
-//        delete headerBox.onclick;
-        headerBox.onclick = null;
-//        LOG.debug("headerBox.id = " + headerBox.id);
-        Tobago.addBindEventListener(headerBox, "click", this, "doSort");
-      }
-      headerBox = Tobago.element(idPrefix + i++);
+  var sheet = this;
+  jQuery(Tobago.escapeClientId(sheet.id)).find(".tobago-sheet-header").each(function() {
+    var sorterId = jQuery(this).attr("sorterId");
+    // old style (not with jQuery), is todo
+    if (sorterId) {
+      var headerBox = jQuery(this).get(0);
+      LOG.warn("sorterId=" + sorterId + " element-id=" + headerBox.id);
+      headerBox.sorterId = sorterId;
+      Tobago.addBindEventListener(headerBox, "click", sheet, "doSort");
     }
-  };
+  });
+};
 
 Tobago.Sheet.prototype.setupPagingLinks = function() {
     idPrefix = this.id + Tobago.SUB_COMPONENT_SEP;
@@ -120,7 +106,6 @@ Tobago.Sheet.prototype.setupPagingLinks 
       for (i = 0 ; i < linkBox.childNodes.length ; i++) {
         var child = linkBox.childNodes[i];
         if (child.nodeType == 1 && child.tagName.toUpperCase() == "A") {
-          child.href = "#";
           Tobago.addBindEventListener(child, "click", this, "doPagingDirect");
         }
       }
@@ -134,21 +119,10 @@ Tobago.Sheet.prototype.setupPagePaging =
         var child = linkBox.childNodes[i];
         if (child.nodeType == 1 && child.tagName.toUpperCase() == "IMG") {
           // first, prev, next and last commands
-          if (child.onclick) {
-//            delete child.onclick;
-            child.onclick = null;
-            Tobago.addBindEventListener(child, "click", this, "doPaging");
-          }
+          Tobago.addBindEventListener(child, "click", this, "doPaging");
         } else if (child.nodeType == 1 && child.tagName.toUpperCase() == "SPAN") {
-//          LOG.debug("Page : onclick =" + child.onclick);
-          if (child.onclick) {
-//            delete child.onclick;
-            child.onclick = null;
-            var toPageId = this.id + Tobago.COMPONENT_SEP + "ToPage";
-            Tobago.addEventListener(child, "click",
-                Tobago.bind(this, "insertTarget", toPageId));
-          }
-
+          var toPageId = this.id + Tobago.COMPONENT_SEP + "ToPage";
+          Tobago.addEventListener(child, "click", Tobago.bind(this, "insertTarget", toPageId));
         }
       }
     }
@@ -159,12 +133,7 @@ Tobago.Sheet.prototype.setupRowPaging = 
     var rowText = Tobago.element(toRowId + Tobago.SUB_COMPONENT_SEP + "text");
     if (rowText) {
       var parent = rowText.parentNode;
-//      LOG.debug("row : onclick =" + parent.onclick);
-      if (parent.onclick) {
-//        delete parent.onclick;
-        parent.onclick = null;
-        Tobago.addEventListener(parent, "click", Tobago.bind(this, "insertTarget", toRowId));
-      }
+      Tobago.addEventListener(parent, "click", Tobago.bind(this, "insertTarget", toRowId));
     }
   };