return $(JsUtils.<Element> cast(o)); | return $(JsUtils.<Element> cast(o)); | ||||
} | } | ||||
if (o instanceof JsonBuilder) { | if (o instanceof JsonBuilder) { | ||||
return new GQuery(((JsonBuilder) o).getDataImpl()); | |||||
return new GQuery(((JsonBuilder) o).<Element>getDataImpl()); | |||||
} | } | ||||
if (o instanceof JavaScriptObject) { | if (o instanceof JavaScriptObject) { | ||||
return $((JavaScriptObject) o); | return $((JavaScriptObject) o); |
} | } | ||||
public static Promise loadScript(final String url, Function success) { | public static Promise loadScript(final String url, Function success) { | ||||
GQuery script = $("script[src^='" + url + "']"); | |||||
if (script.isEmpty()) { | |||||
if (!GWT.isClient() || $("script[src^='" + url + "']").isEmpty()) { | |||||
return ajax(createSettings() | return ajax(createSettings() | ||||
.setUrl(url) | .setUrl(url) | ||||
.setType("get") | .setType("get") | ||||
return this; | return this; | ||||
} | } | ||||
public static Promise loadLink(String rel, String url) { | |||||
public static Promise loadLink(final String rel, final String url) { | |||||
GQuery link = $("link[rel='" + rel + "'][href^='" + url + "']"); | GQuery link = $("link[rel='" + rel + "'][href^='" + url + "']"); | ||||
if (link.isEmpty()) { | if (link.isEmpty()) { | ||||
return new PromiseFunction() { | return new PromiseFunction() { | ||||
public void f(Deferred dfd) { | |||||
public void f(final Deferred dfd) { | |||||
GQuery link = $("<link rel='" + rel + "' href='" + url + "'/>"); | GQuery link = $("<link rel='" + rel + "' href='" + url + "'/>"); | ||||
link.on("load", new Function() { | link.on("load", new Function() { | ||||
public void f() { | public void f() { |
public void testPropMethod(){ | public void testPropMethod(){ | ||||
$(e).html("<input id=\"checkBox1\" type=\"checkbox\" checked=\"checked\" /> <input id=\"checkBox2\" type=\"checkbox\" />"); | $(e).html("<input id=\"checkBox1\" type=\"checkbox\" checked=\"checked\" /> <input id=\"checkBox2\" type=\"checkbox\" />"); | ||||
assertEquals(true, $("#checkBox1",e).prop("checked")); | |||||
assertEquals(false, $("#checkBox2",e).prop("checked")); | |||||
assertEquals(Boolean.TRUE, $("#checkBox1",e).prop("checked")); | |||||
assertEquals(Boolean.FALSE, $("#checkBox2",e).prop("checked")); | |||||
$("#checkBox1",e).prop("checked", false); | $("#checkBox1",e).prop("checked", false); | ||||
$("#checkBox2",e).prop("checked", new Function() { | $("#checkBox2",e).prop("checked", new Function() { | ||||
return Boolean.TRUE; | return Boolean.TRUE; | ||||
} | } | ||||
}); | }); | ||||
assertEquals(true, $("#checkBox2",e).prop("checked")); | |||||
assertEquals(false, $("#checkBox1",e).prop("checked")); | |||||
assertEquals(Boolean.TRUE, $("#checkBox2",e).prop("checked")); | |||||
assertEquals(Boolean.FALSE, $("#checkBox1",e).prop("checked")); | |||||
$(window).prop("foo", 234); | $(window).prop("foo", 234); | ||||
assertEquals(234d, $(window).prop("foo")); | assertEquals(234d, $(window).prop("foo")); |