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 2012/03/13 11:17:28 UTC

svn commit: r1300052 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/ tobago-example/tobago-example-test/src/main/webapp/tc/reload/ tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/to...

Author: lofwyr
Date: Tue Mar 13 10:17:28 2012
New Revision: 1300052

URL: http://svn.apache.org/viewvc?rev=1300052&view=rev
Log:
TOBAGO-1004: Using custom attributes for HTML in a HTML5 compliant way
- reduce JavaScript blocks in the HTML page

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/reload/tip.xhtml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java?rev=1300052&r1=1300051&r2=1300052&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java Tue Mar 13 10:17:28 2012
@@ -30,6 +30,11 @@ public final class DataAttributes {
   public static final String DISABLED = "data-tobago-disabled";
 
   /**
+   * Custom reload attribute. Used to reload a panel.
+   */
+  public static final String RELOAD = "data-tobago-reload";
+
+  /**
    * Alternate to the src attribute, to implement a hover effect.
    */
   public static final String SRCHOVER = "data-tobago-srchover";

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/reload/tip.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/reload/tip.xhtml?rev=1300052&r1=1300051&r2=1300052&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/reload/tip.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/reload/tip.xhtml Tue Mar 13 10:17:28 2012
@@ -29,12 +29,14 @@
     <tc:separator label="Reload test for tips."/>
     <tc:panel>
       <f:facet name="layout">
-        <tc:gridLayout margin="10px" rows="auto;20px;auto;" columns="300px"/>
+        <tc:gridLayout margin="10px" rows="20px;auto;20px;auto;" columns="300px"/>
       </f:facet>
       <f:facet name="reload">
         <tc:reload frequency="5000" update="#{reload.reload}"/>
       </f:facet>
 
+      <tc:out value="This panel will be reloaded every 5 seconds."/>
+
       <tc:in value="#{reload.counter}" readonly="true" tip="Test of &quot; (quotation mark)"/>
 
       <tc:label value="Label" tip="Test of &quot; (quotation mark)"/>

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.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/PageRenderer.java?rev=1300052&r1=1300051&r2=1300052&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java Tue Mar 13 10:17:28 2012
@@ -373,6 +373,7 @@ public class PageRenderer extends PageRe
 
     String defaultActionId = page.getDefaultActionId() != null ? page.getDefaultActionId() : "";
     writer.startElement(HtmlElements.BODY, page);
+// TODO:INIT
     writer.writeAttribute(HtmlAttributes.ONLOAD, "Tobago.init('" + clientId + "');", false);
 //    writer.writeAttribute("onunload", "Tobago.onexit();", null);
     writer.writeIdAttribute(clientId);
@@ -663,6 +664,7 @@ public class PageRenderer extends PageRe
       writer.writeJavascript("TbgTimer.endBody = new Date();");
     }
 
+//TODO:INIT
     writer.writeJavascript("setTimeout(\"Tobago.init('" + clientId + "')\", 1000)");
 
     writer.endElement(HtmlElements.BODY);

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.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/PanelRenderer.java?rev=1300052&r1=1300051&r2=1300052&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java Tue Mar 13 10:17:28 2012
@@ -27,6 +27,7 @@ import org.apache.myfaces.tobago.renderk
 import org.apache.myfaces.tobago.renderkit.css.Classes;
 import org.apache.myfaces.tobago.renderkit.css.Position;
 import org.apache.myfaces.tobago.renderkit.css.Style;
+import org.apache.myfaces.tobago.renderkit.html.DataAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
@@ -86,24 +87,17 @@ public class PanelRenderer extends Layou
       writer.writeAttribute(HtmlAttributes.TITLE, ((UIPanel) panel).getTip(), true);
     }
 
-    HtmlRendererUtils.encodeContextMenu(facesContext, writer, panel);
-
-    // TODO check ajax id
+    // TODO check ajax id?
     if (!FacesContextUtils.isAjax(facesContext)) {
-      Integer frequency = null;
       UIComponent facetReload = panel.getFacet(Facets.RELOAD);
       if (facetReload != null && facetReload instanceof UIReload && facetReload.isRendered()) {
         UIReload update = (UIReload) facetReload;
-        frequency = update.getFrequency();
-      }
-      if (frequency == null) {
-        frequency = 0;
+        writer.writeAttribute(DataAttributes.RELOAD, Integer.toString(update.getFrequency()), false);
       }
-      final String[] cmds = {
-          "new Tobago.Panel(\"" + clientId + "\", " + true + ", " + frequency + ");"
-      };
-      HtmlRendererUtils.writeScriptLoader(facesContext, null, cmds);
     }
+
+    HtmlRendererUtils.encodeContextMenu(facesContext, writer, panel);
+
     HtmlRendererUtils.checkForCommandFacet(panel, facesContext, writer);
 
     final Measure borderLeft = panel.getBorderLeft();

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.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.js?rev=1300052&r1=1300051&r2=1300052&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Tue Mar 13 10:17:28 2012
@@ -248,6 +248,12 @@ var Tobago = {
     }
     this.initMarker = true;
 
+/* TODO:INIT
+    if (pageId == undefined) {
+      pageId = jQuery("body").attr("id");
+    }
+*/
+
 //    new LOG.LogArea({hide: false});
 //    LOG.show();
     if (TbgTimer.endBody) { // @DEV_ONLY
@@ -1481,10 +1487,20 @@ var Tobago = {
   }
 };
 
+/* TODO:INIT
+jQuery(document).ready(function() {
+  Tobago.init();
+});
+
+// this is for TOBAGO-694: Unresponsive image url blocks
+setTimeout("Tobago.init()", 1000);
+*/
+
 // internal initializer will be called in two cases:
 // 1. full load: elements: undefined
 // 2. ajax load: elements: list of the loaded dom elements
 Tobago.init0 = function(elements) {
+  Tobago.Panel.init(elements);
   Tobago.Menu.init(elements);
   Tobago.TabGroup.init(elements);
   Tobago.Tree.init(elements);
@@ -1635,18 +1651,24 @@ Tobago.In.prototype.leaveRequired = func
 
 // XXX: 2nd parameter enableAjax is deprecated
 Tobago.Panel = function(panelId, enableAjax, autoReload) {
-  this.startTime = new Date();
   this.id = panelId;
   this.autoReload = autoReload;
-
   this.options = {
   };
 
-  //LOG.debug("Panel setup  " + this.id);
   this.setup();
   Tobago.addAjaxComponent(this.id, this);
 };
 
+Tobago.Panel.init = function(elements) {
+  var reloads = Tobago.Utils.selectWidthJQuery(elements, ".tobago-panel[data-tobago-reload]");
+  reloads.each(function(){
+    var id = jQuery(this).attr("id");
+    var frequency = parseInt(jQuery(this).attr("data-tobago-reload"));
+    new Tobago.Panel(id, true, frequency);
+  });
+};
+
 Tobago.Panel.prototype.setup = function() {
   this.initReload();
 };