]> source.dussan.org Git - gwtquery.git/commitdiff
add position properties
authorJulien Dramaix <julien.dramaix@gmail.com>
Thu, 27 Jan 2011 22:01:45 +0000 (22:01 +0000)
committerJulien Dramaix <julien.dramaix@gmail.com>
Thu, 27 Jan 2011 22:01:45 +0000 (22:01 +0000)
gwtquery-core/src/main/java/com/google/gwt/query/client/css/CSS.java
gwtquery-core/src/main/java/com/google/gwt/query/client/css/PositionProperty.java [new file with mode: 0644]
gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCssTest.java

index ac5ac9e3b8862eef42c764f5e97380f0d54ab509..0f67220ebdc0c9646d050d498118ee55dbaeebd4 100644 (file)
@@ -214,6 +214,11 @@ public class CSS {
 
   public static PaddingProperty PADDING_TOP;
 
+  /**
+   * The position property is used to position an element.
+   */
+  public static PositionProperty POSITION;
+
   /**
    * For absolutely positioned elements, the right property sets the right edge
    * of an element to a unit to the left/right of the right edge of its
@@ -291,6 +296,7 @@ public class CSS {
     OutlineProperty.init();
     OverflowProperty.init();
     PaddingProperty.init();
+    PositionProperty.init();
     TextAlignProperty.init();
     VerticalAlignProperty.init();
     VisibilityProperty.init();
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/PositionProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/PositionProperty.java
new file mode 100644 (file)
index 0000000..f68e99c
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, The gwtquery team.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.query.client.css;
+
+import com.google.gwt.dom.client.Style.Position;
+
+/**
+ * The position property is used to position an element.
+ */
+public class PositionProperty extends AbstractCssProperty<Position> {
+
+  private static final String CSS_PROPERTY = "position";
+
+  public static void init() {
+    CSS.POSITION = new PositionProperty();
+  }
+
+  private PositionProperty() {
+  }
+
+  public String getCssName() {
+    return CSS_PROPERTY;
+  }
+}
index b35c3ec2433e82b6d73abfddf96dcd1a01e7a610..846279bd4923dd4863d3d8486c09a6f0a0daeb5c 100644 (file)
@@ -24,6 +24,7 @@ import com.google.gwt.dom.client.Style.Float;
 import com.google.gwt.dom.client.Style.FontStyle;
 import com.google.gwt.dom.client.Style.ListStyleType;
 import com.google.gwt.dom.client.Style.Overflow;
+import com.google.gwt.dom.client.Style.Position;
 import com.google.gwt.dom.client.Style.Unit;
 import com.google.gwt.dom.client.Style.VerticalAlign;
 import com.google.gwt.dom.client.Style.Visibility;
@@ -718,6 +719,28 @@ public class GQueryCssTest extends GWTTestCase {
     assertEquals("50px", $("#test").css(CSS.PADDING_RIGHT));
   }
   
+  public void testPositionProperty() {
+
+    $(e).html("<div id='test'>Content</div>");
+
+    $("#test").css(CSS.POSITION, Position.ABSOLUTE);
+    assertEquals("absolute", $("#test").css("position"));
+    assertEquals("absolute", $("#test").css(CSS.POSITION));
+
+    $("#test").css(CSS.POSITION, Position.FIXED);
+    assertEquals("fixed", $("#test").css("position"));
+    assertEquals("fixed", $("#test").css(CSS.POSITION));
+    
+    $("#test").css(CSS.POSITION, Position.RELATIVE);
+    assertEquals("relative", $("#test").css("position"));
+    assertEquals("relative", $("#test").css(CSS.POSITION));
+    
+    $("#test").css(CSS.POSITION, Position.STATIC);
+    assertEquals("static", $("#test").css("position"));
+    assertEquals("static", $("#test").css(CSS.POSITION));
+
+  }
+  
   public void testTextAlignProperty() {
 
     $(e).html("<div id='test'>Content</div>");