* Attributes include title, alt, src, href, width, style, etc.\r
*/\r
public String attr(String name) {\r
- return size() == 0 ? "" : get(0).getAttribute(name);\r
+ return isEmpty() ? "" : get(0).getAttribute(name);\r
}\r
\r
/**\r
* parameter force=true.\r
*/\r
public String css(String name, boolean force) {\r
- return size() == 0 ? "" : styleImpl.curCSS(get(0), name, force);\r
+ return isEmpty() ? "" : styleImpl.curCSS(get(0), name, force);\r
}\r
\r
/**\r
* When true returns the real computed value.\r
*/\r
public double cur(String prop, boolean force) {\r
- return size() == 0 ? 0 : styleImpl.cur(get(0), prop, force);\r
+ return isEmpty() ? 0 : styleImpl.cur(get(0), prop, force);\r
}\r
\r
/**\r
* value).\r
*/\r
public Object data(String name) {\r
- return size() == 0 ? null : data(get(0), name, null);\r
+ return isEmpty() ? null : data(get(0), name, null);\r
}\r
\r
/**\r
*/\r
@SuppressWarnings("unchecked")\r
public <T> T data(String name, Class<T> clz) {\r
- return size() == 0 ? null : (T) data(get(0), name, null);\r
+ return isEmpty() ? null : (T) data(get(0), name, null);\r
}\r
\r
/**\r
* Get the innerHTML of the first matched element.\r
*/\r
public String html() {\r
- return size() == 0 ? "" : get(0).getInnerHTML();\r
+ return isEmpty() ? "" : get(0).getInnerHTML();\r
}\r
\r
/**\r
* but not the vertical scrollbar height, border, or margin.\r
*/\r
public int innerHeight() {\r
- return size() == 0 ? 0 : get(0).getClientHeight();\r
+ return isEmpty() ? 0 : get(0).getClientHeight();\r
}\r
\r
/**\r
* not the vertical scrollbar width, border, or margin.\r
*/\r
public int innerWidth() {\r
- return size() == 0 ? 0 : get(0).getClientWidth();\r
+ return isEmpty() ? 0 : get(0).getClientWidth();\r
}\r
\r
/**\r
* false, if no element fits or the expression is not valid.\r
*/\r
public boolean is(String... filters) {\r
- return filter(filters).size() > 0;\r
+ return !filter(filters).isEmpty();\r
+ }\r
+ \r
+ /**\r
+ * Returns true if the number of matched elements is 0. \r
+ */\r
+ public boolean isEmpty() {\r
+ return size() == 0;\r
}\r
\r
/**\r
* relative or absolute). This method only works with visible elements.\r
*/\r
public GQuery offsetParent() {\r
- if (size() == 0) {\r
+ if (isEmpty()) {\r
return $();\r
}\r
Element offParent = JsUtils.or(elements.getItem(0).getOffsetParent(), body);\r
* elements, including padding, border, and optionally margin.\r
*/\r
public int outerHeight(boolean includeMargin) {\r
- if (size() == 0) {\r
+ if (isEmpty()) {\r
return 0;\r
}\r
// height including padding and border\r
* elements, including padding and border and optionally margin.\r
*/\r
public int outerWidth(boolean includeMargin) {\r
- if (size() == 0) {\r
+ if (isEmpty()) {\r
return 0;\r
}\r
// width including padding and border\r
* and padding. This method only works with visible elements.\r
*/\r
public com.google.gwt.query.client.GQuery.Offset position() {\r
- if (size() == 0) {\r
+ if (isEmpty()) {\r
return new Offset(0, 0);\r
}\r
Element element = get(0);\r
* Scrolls the first matched element into view.\r
*/\r
public GQuery scrollIntoView() {\r
- if (size() > 0)\r
+ if (!isEmpty())\r
scrollIntoViewImpl(get(0));\r
return this;\r
}\r
* the minimum amount necessary.\r
*/\r
public GQuery scrollIntoView(boolean ensure) {\r
- if (size() > 0 && ensure) {\r
+ if (!isEmpty() && ensure) {\r
DOM.scrollIntoView((com.google.gwt.user.client.Element) get(0));\r
} else {\r
scrollIntoView();\r
* the array will be empty, otherwise it will contain one or more values.\r
*/\r
public String[] vals() {\r
- if (size() > 0) {\r
+ if (!isEmpty()) {\r
Element e = get(0);\r
if (e.getNodeName().equalsIgnoreCase("select")) {\r
SelectElement se = SelectElement.as(e);\r
* Return true if the first element is visible.\r
*/\r
public boolean visible() {\r
- return size() == 0 ? false : styleImpl.isVisible(get(0));\r
+ return isEmpty() ? false : styleImpl.isVisible(get(0));\r
}\r
\r
/**\r
* everything else.\r
*/\r
public GQuery wrapAll(GQuery query) {\r
- if (size() > 0) {\r
+ if (!isEmpty()) {\r
GQuery wrap = query.clone();\r
if (elements.getItem(0).getParentNode() != null) {\r
wrap.insertBefore(elements.getItem(0));\r