diff options
author | Manolo Carrasco <manolo@apache.org> | 2010-10-25 12:48:13 +0000 |
---|---|---|
committer | Manolo Carrasco <manolo@apache.org> | 2010-10-25 12:48:13 +0000 |
commit | c1a3c32e4424fcb405499c3b869420840d1754de (patch) | |
tree | b3491699410fe6dc8e68771d91bef34d20376cee /gwtquery-core | |
parent | e0f9f511f16bdc47b4575f351cab6ca80773a587 (diff) | |
download | gwtquery-c1a3c32e4424fcb405499c3b869420840d1754de.tar.gz gwtquery-c1a3c32e4424fcb405499c3b869420840d1754de.zip |
adding outerWidth and outerHeight methods which are in the jquery API. Patch by julien.dramaix (fixes issue56)
Diffstat (limited to 'gwtquery-core')
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java | 41 | ||||
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java | 24 |
2 files changed, 64 insertions, 1 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java index a06ad1f6..f2af2827 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java @@ -1529,6 +1529,46 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { public GQuery one(int eventbits, final Object data, final Function f) {
return as(Events).one(eventbits, data, f);
}
+
+ /**
+ * Get the current computed height for the first element in the set of matched elements,
+ * including padding, border, but not the margin.
+ */
+ public int outerHeight(){
+ return outerHeight(false);
+ }
+
+ /**
+ * Get the current computed height for the first element in the set of matched elements,
+ * including padding, border, and optionally margin.
+ */
+ public int outerHeight(boolean includeMargin){
+ int outerHeight = get(0).getOffsetHeight(); //height including padding and border
+ if (includeMargin){
+ outerHeight+=GQUtils.cur( get(0), "marginTop", true)+GQUtils.cur( get(0), "marginBottom", true);
+ }
+ return outerHeight;
+ }
+
+ /**
+ * Get the current computed width for the first element in the set of matched elements,
+ * including padding, border, but not the margin.
+ */
+ public int outerWidth(){
+ return outerWidth(false);
+ }
+
+ /**
+ * Get the current computed width for the first element in the set of matched elements,
+ * including padding and border and optionally margin.
+ */
+ public int outerWidth(boolean includeMargin){
+ int outerWidth = get(0).getOffsetWidth(); //width including padding and border
+ if (includeMargin){
+ outerWidth+=GQUtils.cur( get(0), "marginRight", true)+GQUtils.cur( get(0), "marginLeft", true);
+ }
+ return outerWidth;
+ }
/**
* Get a set of elements containing the unique parents of the matched set of
@@ -2545,5 +2585,4 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { dataCache.delete(id);
}
}
-
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java index d579e644..149969e3 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java @@ -717,6 +717,30 @@ public interface LazyGQuery<T> extends LazyBase<T>{ LazyGQuery<T> one(int eventbits, Object data, Function f); /** + * Get the current computed width for the first element in the set of matched elements, + * including padding, border, but not the margin. + */ + int outerWidth(); + + /** + * Get the current computed width for the first element in the set of matched elements, + * including padding and border and optionally margin. + */ + int outerWidth(boolean includeMargin); + + /** + * Get the current computed height for the first element in the set of matched elements, + * including padding, border, but not the margin. + */ + int outerHeight(); + + /** + * Get the current computed height for the first element in the set of matched elements, + * including padding, border, and optionally margin. + */ + int outerHeight(boolean includeMargin); + + /** * Get a set of elements containing the unique parents of the matched set of * elements. */ |