public class JavaScriptUtil extends Object
getInstance()
Modifier and Type | Field and Description |
---|---|
private String[] |
fonts |
private static JavaScriptUtil |
INSTANCE |
Constructor and Description |
---|
JavaScriptUtil()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone(Object template)
This method creates a
clone of the given template . |
com.google.gwt.dom.client.InputElement |
createInputElement(String type)
Creates an
InputElement of a custom type . |
List<String> |
getAvailableFonts() |
String |
getBlobUrl(JsBlob blob)
This method creates the URL pointing to a
JsBlob . |
int |
getBrowserHeight()
This method gets the height of the browser window in pixel (vertical size).
|
int |
getBrowserPositionX()
This method gets the pixel position of the browser window's left border on the x-axis (horizontal).
|
int |
getBrowserPositionY()
This method gets the pixel position of the browser window's top border on the y-axis (vertical).
|
int |
getBrowserWidth()
This method gets the width of the browser window in pixel (horizontal size).
|
JsCssStyleDeclaration |
getComputedStyle(com.google.gwt.dom.client.Element element)
This method gets the
computed style of the given Element . |
JsFileList |
getFileList(com.google.gwt.user.client.Event event)
This method gets the
JsFileList for a given Event . |
com.google.gwt.dom.client.Element |
getFocusable(com.google.gwt.dom.client.Element element,
boolean tabable,
boolean last)
Get the first/last focusable or tab-able (child)
Element . |
com.google.gwt.dom.client.Element |
getFocusedElement() |
private com.google.gwt.core.client.JsArrayString |
getFonts() |
com.google.gwt.dom.client.Document |
getFrameDocument(com.google.gwt.dom.client.Element iframe)
This method gets the
Document of a given <iframe> Element . |
static JavaScriptUtil |
getInstance() |
JsBlob |
getResponseAsBlob(com.google.gwt.xhr.client.XMLHttpRequest xhr)
This method gets the response of the given
XMLHttpRequest as JsBlob . |
int |
getScreenHeight()
This method gets the height of the current screen/display also called the vertical resolution.
|
int |
getScreenWidth()
This method gets the width of the current screen/display also called the horizontal resolution.
|
JsSelection |
getSelection()
This method gets the
JsSelection of the browser Window . |
JsSelection |
getSelection(com.google.gwt.dom.client.Element iframe)
|
boolean |
isFocusable(com.google.gwt.dom.client.Element element,
boolean tabable)
Determines if the given
Element is focusable or tab-able. |
Object |
newInstance(Object template)
This method creates a
new instance of the given template . |
void |
onLoadFrame(com.google.gwt.dom.client.Element iframe,
Runnable callback)
|
void |
openBlob(JsBlob blob)
This method opens a given
JsBlob . |
boolean |
setCustomValidity(com.google.gwt.dom.client.Element inputElement,
String message)
This method sets the custom validation message of the given input
Element . |
private void |
setInputElementType(com.google.gwt.dom.client.InputElement inputElement,
String type)
This method sets the
type of an InputElement . |
private static final JavaScriptUtil INSTANCE
private String[] fonts
public static JavaScriptUtil getInstance()
JavaScriptUtil
.Cdi.GET_INSTANCE
public List<String> getAvailableFonts()
List
of fonts available in the browser.public int getScreenWidth()
public int getScreenHeight()
public int getBrowserPositionX()
public int getBrowserPositionY()
public int getBrowserWidth()
public int getBrowserHeight()
public boolean setCustomValidity(com.google.gwt.dom.client.Element inputElement, String message)
Element
. The Browser needs to support
HTML5 for this feature.inputElement
- is the input Element
that has been validated.message
- - the empty string to mark as valid, the validation failure message otherwise.true
if the browser supports custom validity and it has been set, false
otherwise.public com.google.gwt.dom.client.InputElement createInputElement(String type)
InputElement
of a custom type
. Only used while GWT does NOT
directly provide a way to create HTML5 input elements.type
- is the requested type
(e.g. "range", "date", etc.).InputElement
of the given type
.private void setInputElementType(com.google.gwt.dom.client.InputElement inputElement, String type)
type
of an InputElement
.inputElement
- is the input InputElement
.type
- is the new type
to set.public Object clone(Object template)
clone
of the given template
.template
- is the object to clone.public Object newInstance(Object template)
new instance
of the given template
.template
- is the object create a new instance of.public JsBlob getResponseAsBlob(com.google.gwt.xhr.client.XMLHttpRequest xhr)
XMLHttpRequest
as JsBlob
.xhr
- is the XMLHttpRequest
that has already been
loaded.JsBlob
.public JsFileList getFileList(com.google.gwt.user.client.Event event)
JsFileList
for a given Event
. E.g. if files are dragged onto some element in
the browser or in case of an Event
(e.g. of ) of a file input you can receive the
JsFileList
here.event
- is the Event
.JsFileList
or null
if no files are available.public String getBlobUrl(JsBlob blob)
JsBlob
. Such URL is starting with the "blob:" scheme and is only
valid within the current JS context.blob
- is the JsBlob
.public void openBlob(JsBlob blob)
JsBlob
. The browser will show a regular popup to open the file or save it to the
local disc. Depending on its mimetype the browser might already open the file immediately in a new window.blob
- is the JsBlob
.public JsCssStyleDeclaration getComputedStyle(com.google.gwt.dom.client.Element element)
computed style
of the given Element
. Element
in
pixels (rather than something like "50%") just use Element.getOffsetWidth()
or
Element.getOffsetHeight()
instead.element
- is the Element
to compute the style of.public JsSelection getSelection()
JsSelection
of the browser Window
.JsSelection
.public JsSelection getSelection(com.google.gwt.dom.client.Element iframe)
JsSelection
of the given <iframe>
Element
. The given iframe
needs to be loaded when calling this method. Use onLoadFrame(Element, Runnable)
to ensure.iframe
- is the <iframe>
Element
.JsSelection
.public boolean isFocusable(com.google.gwt.dom.client.Element element, boolean tabable)
Element
is focusable or tab-able.element
- is the Element
to check.tabable
- - true
if the check should only consider tab-able Element
s (so if tabindex is
negative, the result is false
), false
otherwise.true
if focusable/tab-able, false
otherwise.public com.google.gwt.dom.client.Element getFocusedElement()
Element
that is currently focused or null
if focus is outside the current document.public com.google.gwt.dom.client.Element getFocusable(com.google.gwt.dom.client.Element element, boolean tabable, boolean last)
Element
.element
- is the Element
to scan recursively.tabable
- - true
if the check should only consider tab-able Element
s (so if tabindex is
negative, the result is false
), false
otherwise.last
- - true
if the last focusable/tab-able element shall be returned, false
for the last
focusable/tab-able element.Element
or null
if none exists.public com.google.gwt.dom.client.Document getFrameDocument(com.google.gwt.dom.client.Element iframe)
Document
of a given <iframe>
Element
. The given iframe
needs
to be loaded when calling this method. Use onLoadFrame(Element, Runnable)
to ensure.iframe
- is the <iframe>
Element
.Document
.public void onLoadFrame(com.google.gwt.dom.client.Element iframe, Runnable callback)
iframe
- is the <iframe>
Element
.callback
- is the callback to execute
.private com.google.gwt.core.client.JsArrayString getFonts()
Copyright © 2001–2016 mmm-Team. All rights reserved.