|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.spiffyui.client.JSUtil
public final class JSUtil
A set of static JavaScript utilities that provide access to functions from JQuery and some other JavaScript libraries.
Method Summary | |
---|---|
static void |
addHistoryItem(HistoryCallback callback,
java.lang.String id)
Adds an item to the browser's history. |
static void |
addHistoryItem(HistoryCallback callback,
java.lang.String id,
boolean bookmarkable)
Adds an item to the browser's history. |
static void |
addHistoryItem(HistoryCallback callback,
java.lang.String id,
boolean bookmarkable,
java.lang.String title)
Adds an item to the browser's history. |
static void |
back()
Move back one item in the browser history. |
static java.lang.String |
base64Decode(java.lang.String s)
Base64 decode a string |
static java.lang.String |
base64Encode(java.lang.String s)
Base64 encode a string |
static void |
bounce(java.lang.String id,
int times,
int speed,
int distance)
Causes the specified element to bounce the specified number of times at the specified speed. |
static void |
bounce(java.lang.String id,
int times,
int speed,
int distance,
JSEffectCallback callback)
Causes the specified element to bounce the specified number of times at the specified speed. |
static void |
collapseSection(HTMLPanel panel,
java.lang.String targetId,
java.lang.String sectionId,
boolean animate)
Collapses a section |
static void |
expandSection(HTMLPanel panel,
java.lang.String targetId,
java.lang.String sectionId,
boolean animate)
Expands a section |
static void |
forward()
Move forward one item in the browser history. |
static java.lang.String |
generateUniqueId()
Generate a probably unique ID. |
static java.lang.String |
getCurrentHistoryStateId()
Get the current Spiffy UI history id if it is available. |
static int |
getHeight(java.lang.String id)
Get the height of the element with the specified ID. |
static int |
getWidth(java.lang.String id)
Get the width of the element with the specified ID. |
static void |
go(int steps)
Move a variable number of items in the browser history. |
static void |
hide(java.lang.String id)
Hides the specified element. |
static void |
hide(java.lang.String id,
java.lang.String speed)
Hides an element with a fade effect. |
static void |
hide(java.lang.String id,
java.lang.String speed,
JSEffectCallback callback)
Hides an element with a fade effect. |
static void |
horizontalToggleSlide(java.lang.String id)
Toggles the visibility of the specified element with a horizontal slide effect sliding from the left side. |
static void |
horizontalToggleSlide(java.lang.String id,
JSEffectCallback callback)
Toggles the visibility of the specified element with a horizontal slide effect sliding from the left side. |
static boolean |
isHistoryEnabled()
Determines if browser history integration is enabled. |
static boolean |
isVisible(java.lang.String selector)
Determines if the element(s) defined by the specified selector is visible. |
static void |
logObjForDebug(java.lang.Object o)
logs an object to the Firebug console for debugging purposes. |
static JavaScriptObject |
parseJSON(java.lang.String jsonString)
Parse the specified JSON string into a JavaScript object. |
static void |
printError(java.lang.String msg)
Prints an error message to the Firebug console. |
static void |
println(java.lang.String msg)
Prints an info message to the Firebug console, Chrome developer console, or Internet Explorer dev mode console. |
static void |
replaceHistoryItem(HistoryCallback callback,
java.lang.String id,
boolean bookmarkable)
Replace the current item in the browser's history. |
static void |
replaceHistoryItem(HistoryCallback callback,
java.lang.String id,
boolean bookmarkable,
java.lang.String title)
Replace the current item in the browser's history. |
static void |
setHistoryEnabled(boolean enabled)
Sets history integration as enabled or disabled. |
static void |
setText(java.lang.String id,
java.lang.String txt)
Set the text for an element |
static void |
show(java.lang.String id)
Shows the specified element. |
static void |
show(java.lang.String id,
java.lang.String speed)
Shows an element with a fade effect. |
static void |
show(java.lang.String id,
java.lang.String speed,
JSEffectCallback callback)
Shows an element with a fade effect. |
static void |
slideDown(java.lang.String id,
java.lang.String speed)
Shows an element with a slide down effect. |
static void |
slideDown(java.lang.String id,
java.lang.String speed,
JSEffectCallback callback)
Shows an element with a slide down effect. |
static void |
slideUp(java.lang.String id,
java.lang.String speed)
Hides an element with a slide up effect. |
static void |
slideUp(java.lang.String id,
java.lang.String speed,
JSEffectCallback callback)
Hides an element with a slide up effect. |
static boolean |
toggleSection(Element target,
HTMLPanel panel,
java.lang.String targetId,
java.lang.String sectionId)
Toggle hiding or showing a section |
static void |
toggleSlide(java.lang.String id,
java.lang.String speed)
Toggles the visibility of the specified element with a vertical slide effect |
static void |
toggleSlide(java.lang.String id,
java.lang.String speed,
JSEffectCallback callback)
Toggles the visibility of the specified element with a vertical slide effect |
static java.lang.String |
trimLastDelimiter(java.lang.String s,
java.lang.String delim)
Returns a String without the last delimiter |
static boolean |
validateEmail(java.lang.String s)
Validate an email address entry such that both the following will pass: Allison Blake |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.String getCurrentHistoryStateId()
public static void addHistoryItem(HistoryCallback callback, java.lang.String id)
Adds an item to the browser's history.
History items can be added at any item with any unique ID. When the user navigates the browser's history there will be a collection of items added programmatically and items representing traditional page changes. When the item added with this method is reached the callback will be called with the specified ID.
Spiffy UI uses this method to page changes in the main navigation bar to the browser's history so the user can use the browser forward and back buttons to move between pages in the application. This method is called by the MainNavBar to add page changes.
callback
- the history callback for this itemid
- the id of the item that was selectedpublic static void addHistoryItem(HistoryCallback callback, java.lang.String id, boolean bookmarkable)
Adds an item to the browser's history.
History items can be added at any item with any unique ID. When the user navigates the browser's history there will be a collection of items added programmatically and items representing traditional page changes. When the item added with this method is reached the callback will be called with the specified ID.
Spiffy UI uses this method to page changes in the main navigation bar to the browser's history so the user can use the browser forward and back buttons to move between pages in the application. This method is called by the MainNavBar to add page changes.
This method support bookmarking. When a history item is bookmarkable it will cause a change in the URL which can then be bookmarked by the user to return to that specific history state.
callback
- the history callback for this itemid
- the id of the item that was selectedbookmarkable
- true if this history item should be bookmarkable and false otherwisepublic static void addHistoryItem(HistoryCallback callback, java.lang.String id, boolean bookmarkable, java.lang.String title)
Adds an item to the browser's history.
History items can be added at any item with any unique ID. When the user navigates the browser's history there will be a collection of items added programmatically and items representing traditional page changes. When the item added with this method is reached the callback will be called with the specified ID.
Spiffy UI uses this method to page changes in the main navigation bar to the browser's history so the user can use the browser forward and back buttons to move between pages in the application. This method is called by the MainNavBar to add page changes.
This method support bookmarking. When a history item is bookmarkable it will cause a change in the URL which can then be bookmarked by the user to return to that specific history state.
callback
- the history callback for this itemid
- the id of the item that was selectedbookmarkable
- true if this history item should be bookmarkable and false otherwisetitle
- the browser window title for this history itempublic static void replaceHistoryItem(HistoryCallback callback, java.lang.String id, boolean bookmarkable)
Replace the current item in the browser's history.
History items can be added at any item with any unique ID. When the user navigates the browser's history there will be a collection of items added programmatically and items representing traditional page changes. When the item added with this method is reached the callback will be called with the specified ID.
Spiffy UI uses this method to page changes in the main navigation bar to the browser's history so the user can use the browser forward and back buttons to move between pages in the application. This method is called by the MainNavBar to add page changes.
This method support bookmarking. When a history item is bookmarkable it will cause a change in the URL which can then be bookmarked by the user to return to that specific history state.
callback
- the history callback for this itemid
- the id of the item that was selectedbookmarkable
- true if this history item should be bookmarkable and false otherwisepublic static void replaceHistoryItem(HistoryCallback callback, java.lang.String id, boolean bookmarkable, java.lang.String title)
Replace the current item in the browser's history.
History items can be added at any item with any unique ID. When the user navigates the browser's history there will be a collection of items added programmatically and items representing traditional page changes. When the item added with this method is reached the callback will be called with the specified ID.
Spiffy UI uses this method to page changes in the main navigation bar to the browser's history so the user can use the browser forward and back buttons to move between pages in the application. This method is called by the MainNavBar to add page changes.
This method support bookmarking. When a history item is bookmarkable it will cause a change in the URL which can then be bookmarked by the user to return to that specific history state.
callback
- the history callback for this itemid
- the id of the item that was selectedbookmarkable
- true if this history item should be bookmarkable and false otherwisetitle
- the browser window title for this history itempublic static boolean isHistoryEnabled()
Determines if browser history integration is enabled.
If history integration is enabled various part of the Spiffy UI framework and calling code will add items to the browser history. If not then no part of the framework will maniplate browser history in any way.
History support is enabled by default.
public static void setHistoryEnabled(boolean enabled)
Sets history integration as enabled or disabled.
If history integration is enabled various part of the Spiffy UI framework and calling code will add items to the browser history. If not then no part of the framework will maniplate browser history in any way.
History support is enabled by default.
enabled
- true if history support should be enabled and false otherwisepublic static void forward()
public static void back()
public static void go(int steps)
steps
- If steps is negative go back through history that number of times, otherwise
step forward in the history that number of timespublic static java.lang.String generateUniqueId()
public static void slideDown(java.lang.String id, java.lang.String speed)
id
- the id for the element to showspeed
- the speed to fade in. options are slow, normal, fast or a numberpublic static void slideDown(java.lang.String id, java.lang.String speed, JSEffectCallback callback)
id
- the id for the element to showspeed
- the speed to fade in. options are slow, normal, fast or a numbercallback
- the callback called when the animation is completepublic static void slideUp(java.lang.String id, java.lang.String speed)
id
- the id for the element to showspeed
- the speed to fade in. options are slow, normal, fast or a numberpublic static void slideUp(java.lang.String id, java.lang.String speed, JSEffectCallback callback)
id
- the id for the element to showspeed
- the speed to fade in. options are slow, normal, fast or a numbercallback
- the callback called when the animation is completepublic static void toggleSlide(java.lang.String id, java.lang.String speed)
id
- the id for the element to showspeed
- the speed to fade in. options are slow, normal, fast or a numberpublic static void toggleSlide(java.lang.String id, java.lang.String speed, JSEffectCallback callback)
id
- the id for the element to showspeed
- the speed to fade in. options are slow, normal, fast or a numbercallback
- the callback called when the animation is completepublic static void horizontalToggleSlide(java.lang.String id, JSEffectCallback callback)
id
- the id for the element to showcallback
- the callback called when the animation is completepublic static void horizontalToggleSlide(java.lang.String id)
id
- the id for the element to showpublic static void bounce(java.lang.String id, int times, int speed, int distance)
id
- the ID of the element to bouncetimes
- the number of times to bounce the elementspeed
- the speed of the bounce animation in millisecondsdistance
- the distance in pixels to bounds the element - default is 20public static void bounce(java.lang.String id, int times, int speed, int distance, JSEffectCallback callback)
id
- the ID of the element to bouncetimes
- the number of times to bounce the elementspeed
- the speed of the bounce animation in millisecondsdistance
- the distance in pixels to bounds the element - default is 20callback
- the callback called when the animation is completepublic static void hide(java.lang.String id, java.lang.String speed)
id
- the id for the element to showspeed
- the speed to fade in. options are slow, normal, fast or a numberpublic static void hide(java.lang.String id, java.lang.String speed, JSEffectCallback callback)
id
- the id for the element to showspeed
- the speed to fade in. options are slow, normal, fast or a numbercallback
- the callback called when the animation is completepublic static void hide(java.lang.String id)
id
- the id for the element to showpublic static void setText(java.lang.String id, java.lang.String txt)
id
- the id for the elementtxt
- text to set for the elementpublic static void show(java.lang.String id, java.lang.String speed)
id
- the id for the element to showspeed
- the speed to fade in. options are slow, normal, fast or a numberpublic static void show(java.lang.String id, java.lang.String speed, JSEffectCallback callback)
id
- the id for the element to showspeed
- the speed to fade in. options are slow, normal, fast or a numbercallback
- the callback called when the animation is completepublic static void show(java.lang.String id)
id
- the id for the element to showpublic static void println(java.lang.String msg)
Prints an info message to the Firebug console, Chrome developer console, or Internet Explorer dev mode console.
This method is very useful for debugging when you aren't using GWT hosted mode. The message print out to the console one item at a time and don't do anything if the console isn't available.
msg
- the message to printpublic static void logObjForDebug(java.lang.Object o)
o
- the object to log to firebug consolepublic static void printError(java.lang.String msg)
msg
- the message to printpublic static boolean isVisible(java.lang.String selector)
selector
- the elements to inspect
public static boolean toggleSection(Element target, HTMLPanel panel, java.lang.String targetId, java.lang.String sectionId)
target
- - the event's onclick targetpanel
- - the parent HTMLPanel of the targettargetId
- - the ID of the targetsectionId
- - the ID of the section to toggle
public static void expandSection(HTMLPanel panel, java.lang.String targetId, java.lang.String sectionId, boolean animate)
panel
- - HTMLPanel holding the targettargetId
- - the ID of the targetsectionId
- - the ID of the section to toggleanimate
- - boolean true to use slide down effect, false to just display:nonepublic static void collapseSection(HTMLPanel panel, java.lang.String targetId, java.lang.String sectionId, boolean animate)
panel
- - HTMLPanel holding the targettargetId
- - the ID of the targetsectionId
- - the ID of the section to toggleanimate
- - boolean true to use slide down effect, false to just display:nonepublic static java.lang.String base64Encode(java.lang.String s)
s
- the string to encode
public static java.lang.String base64Decode(java.lang.String s)
s
- the string to decode
public static boolean validateEmail(java.lang.String s)
s
- - the String to test
public static java.lang.String trimLastDelimiter(java.lang.String s, java.lang.String delim)
s
- - String to trimdelim
- - the delimiter
public static int getHeight(java.lang.String id)
Get the height of the element with the specified ID.
This method gets the height of the specified element on the screen including padding and margins. The element must be visible and attached to the page.
id
- the id of the element example: myElement
public static int getWidth(java.lang.String id)
Get the width of the element with the specified ID.
This method gets the width of the specified element on the screen including padding and margins. The element must be visible and attached to the page.
id
- the id of the element example: myElement
public static JavaScriptObject parseJSON(java.lang.String jsonString)
Parse the specified JSON string into a JavaScript object.
This method parses the specified string of well-formed JSON and returns a JavaScript object. It calls JSON.parse when it is available and calls eval only on older browsers which don't support JSON.parse.
jsonString
- the json string to parse
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |