From c1a3c32e4424fcb405499c3b869420840d1754de Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Mon, 25 Oct 2010 12:48:13 +0000 Subject: adding outerWidth and outerHeight methods which are in the jquery API. Patch by julien.dramaix (fixes issue56) --- .../java/com/google/gwt/query/client/GQuery.java | 41 +++++++++++++++++++++- .../com/google/gwt/query/client/LazyGQuery.java | 24 +++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) (limited to 'gwtquery-core') 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 { 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 { 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 @@ -716,6 +716,30 @@ public interface LazyGQuery extends LazyBase{ */ LazyGQuery 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. -- cgit v1.2.3