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/04/24 17:50:23 UTC

svn commit: r1589775 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/layout/ tobago-core/src/test/java/org/apache/myfaces/tobago/layout/ tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/ren...

Author: lofwyr
Date: Thu Apr 24 15:50:23 2014
New Revision: 1589775

URL: http://svn.apache.org/r1589775
Log:
TOBAGO-1390: "Can't parse to any measure"

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/Measure.java
    myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/layout/MeasureUnitTest.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/layout/Measure.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/Measure.java?rev=1589775&r1=1589774&r2=1589775&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/Measure.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/Measure.java Thu Apr 24 15:50:23 2014
@@ -70,6 +70,13 @@ public abstract class Measure implements
       return ZERO;
     }
     try {
+      final int dot = value.indexOf('.');
+      if (dot == 0) {
+        return Measure.ZERO;
+      }
+      if (dot > 0) {
+        return Measure.valueOf(Integer.parseInt(value.substring(0, dot)));
+      }
       if (value.endsWith("px")) {
         return Measure.valueOf(Integer.parseInt(value.substring(0, value.length() - 2)));
       }

Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/layout/MeasureUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/layout/MeasureUnitTest.java?rev=1589775&r1=1589774&r2=1589775&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/layout/MeasureUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/layout/MeasureUnitTest.java Thu Apr 24 15:50:23 2014
@@ -61,4 +61,13 @@ public class MeasureUnitTest {
     Assert.assertEquals(px(5), Measure.max(px(5), null));
     Assert.assertEquals(Measure.ZERO, Measure.max(null, null));
   }
+
+  @Test
+  public void testDecimal() {
+    Assert.assertEquals(Measure.valueOf("13.3px"), px(13));
+    Assert.assertEquals(Measure.valueOf("13.7px"), px(13));
+    Assert.assertEquals(Measure.valueOf("13.3"), px(13));
+    Assert.assertEquals(Measure.valueOf("13.7"), px(13));
+    Assert.assertEquals(Measure.valueOf(".7"), px(0));
+  }
 }

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=1589775&r1=1589774&r2=1589775&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 Thu Apr 24 15:50:23 2014
@@ -361,7 +361,7 @@ var Tobago = {
     var page = jQuery(".tobago-page");
     page.children("form").first()
         .children(Tobago.Utils.escapeClientId(this.page.id + this.SUB_COMPONENT_SEP + 'form-clientDimension'))
-        .val(page.width() + ';' + page.height());
+        .val(Math.floor(page.width()) + ';' + Math.floor(page.height()));
   },
 
   onBeforeUnload: function() {