Skip to content
This repository has been archived by the owner on Feb 22, 2019. It is now read-only.

Commit

Permalink
Tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
pvlasov committed May 27, 2014
1 parent 91dbdfe commit 80c32d9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,13 @@ public Action execute(WebContext context) throws Exception {
//
// body.content(inputGroup);

body.content(htmlFactory.label(Style.SUCCESS, "Life is good!"));
body.content(
htmlFactory.tooltip(
htmlFactory.label(Style.SUCCESS, "Life is good!").id("life_is_good"),
HTMLFactory.Placement.BOTTOM,
"A <B>good</B> life is even <U>better</U>!!!"));
body.content(htmlFactory.tag("script", "$('#life_is_good').tooltip({html:true});"));


body.content("<p/>");

Expand Down
11 changes: 11 additions & 0 deletions org.nasdanika.html/src/org/nasdanika/html/HTMLFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ enum Placement { LEFT, TOP, RIGHT, BOTTOM }
*/
<T extends UIElement<?>> T popover(T element, Placement placement, String title, String text);

/**
* Adds tooltip to the element.
* This method does not initialize the tooltip, it shall be done through JavaScript <code>$(selector).tooltip();</code> e.g.
* <code>$('#my_button').tooltip();</code>
* @param element Element
* @param placement tooltip placement.
* @param text tooltip text
* @return
*/
<T extends UIElement<?>> T tooltip(T element, Placement placement, String text);

enum Glyphicon {
asterisk,
plus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,16 @@ public <T extends UIElement<?>> T popover(T element, Placement placement, String

return element;
}

@Override
public <T extends UIElement<?>> T tooltip(T element, Placement placement, String text) {
element
.attribute("data-toggle", "tooltip")
.attribute("title", text)
.attribute("data-placement", placement.name().toLowerCase());

return element;
}

@Override
public Tag input(InputType type, String name, String value, String id, String placeholder) {
Expand Down

0 comments on commit 80c32d9

Please sign in to comment.