use of elemental2.dom.Document in project gwtproject by treblereel.
the class FormPanelTest method testWrappedForm.
public void testWrappedForm() {
// Create a form and frame in the document we can wrap.
final String iframeId = Document.get().createUniqueId();
final String iframeName = Document.get().createUniqueId();
final Element container = Document.get().createDivElement();
container.setInnerHTML("<form method='post' target='" + iframeName + "' action='" + "formHandler?sendHappyHtml'>" + "<input type='hidden' name='foo' value='bar'></input></form>" + "<iframe src=\"javascript:\'\'\" id='" + iframeId + "' " + "name='" + iframeName + "'></iframe>");
Document.get().getBody().appendChild(container);
// Wrap the form and make sure its target frame is intact.
FormPanel form = FormPanel.wrap(container.getFirstChildElement());
assertEquals(iframeName, form.getTarget());
// Ensure that no synthesized iframe was created.
assertNull(form.getSynthesizedIFrame());
// Submit the form and make sure the target frame comes back with the right
// stuff (give it 2.5 s to complete).
delayTestFinish(TEST_DELAY);
form.submit();
new Timer() {
@Override
public void run() {
// Get the targeted frame and make sure it contains the requested
// 'happyElem'.
Frame frame = Frame.wrap(Document.get().getElementById(iframeId));
assertTrue(isHappyDivPresent(frame.getElement()));
finishTest();
}
}.schedule(TEST_DELAY - 2000);
}
use of elemental2.dom.Document in project gwtproject by treblereel.
the class FormPanelTest method testWrappedFormWithIFrame.
public void testWrappedFormWithIFrame() {
// Create a form and frame in the document we can wrap.
final Element container = Document.get().createDivElement();
container.setInnerHTML("<form method='get' " + "encoding='application/x-www-form-urlencoded' action='" + "formHandler'>" + "<input type='text' name='tb' value='text'></input></form>");
Document.get().getBody().appendChild(container);
// Wrap the form, asking for an iframe to be created.
FormPanel form = FormPanel.wrap(container.getFirstChildElement(), true);
// Give the submit 5s to complete.
delayTestFinish(TEST_DELAY);
form.addSubmitCompleteHandler(new SubmitCompleteHandler() {
@Override
public void onSubmitComplete(SubmitCompleteEvent event) {
// Make sure we get our results back.
assertTrue(event.getResults().equals("tb=text"));
finishTest();
}
});
form.submit();
}
use of elemental2.dom.Document in project gwtproject by treblereel.
the class Element method isRTLSafari.
@JsOverlay
private boolean isRTLSafari() {
HTMLElement e = Js.uncheckedCast(this);
// TODO when Document has defaultView, clean this up
// TODO also see about not referencing a class which doesn't exist in the browser (ViewCSS)
ViewCSS defaultView = Js.uncheckedCast(Js.<JsPropertyMap<?>>uncheckedCast(e.ownerDocument).get("defaultView"));
return Objects.equals(defaultView.getComputedStyle(e, "").direction, "rtl");
}
use of elemental2.dom.Document in project gwtproject by treblereel.
the class RichTextAreaImplStandard method execCommandAssumingFocus.
void execCommandAssumingFocus(String cmd, String param) {
HTMLIFrameElement iframe = Js.uncheckedCast(elem);
Document document = Js.uncheckedCast(Js.asPropertyMap(iframe.contentWindow).get("document"));
((ExecCommand) Js.uncheckedCast(Js.asPropertyMap(document).get("execCommand"))).onInvoke(cmd, false, param);
}
use of elemental2.dom.Document in project gwtproject by treblereel.
the class RichTextAreaImplStandard method initElement.
@Override
public void initElement() {
// Most browsers don"t like setting designMode until slightly _after_
// the iframe becomes attached to the DOM. Any non-zero timeout will do
// just fine.
RichTextAreaImplStandard _this = this;
_this.onElementInitializing();
DomGlobal.setTimeout((ignore) -> {
if (_this.elem != null) {
HTMLIFrameElement iframe = Js.uncheckedCast(_this.elem);
if (iframe.contentWindow != null) {
((JsPropertyMap) ((JsPropertyMap) iframe.contentWindow).get("document")).set("designMode", "On");
_this.onElementInitialized();
}
}
}, 1.0D, new Object[0]);
}
Aggregations