Author: pyaschenko
Date: 2010-12-29 08:07:44 -0500 (Wed, 29 Dec 2010)
New Revision: 20836
Modified:
trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml
trunk/examples/output-demo/src/main/webapp/qunit/tooltip.xhtml
trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-tooltip-qunit.js
trunk/ui/common/api/src/main/java/org/richfaces/component/Positioning.java
trunk/ui/common/ui/src/main/resources/META-INF/resources/org.richfaces/popup.js
trunk/ui/output/ui/src/main/java/org/richfaces/component/UITooltip.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/tooltip.js
Log:
Modified: trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml 2010-12-29 00:53:56
UTC (rev 20835)
+++ trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml 2010-12-29 13:07:44
UTC (rev 20836)
@@ -28,7 +28,8 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:pn="http://richfaces.org/pn"
-
xmlns:rich="http://richfaces.org/output">
+
xmlns:rich="http://richfaces.org/output"
+
xmlns:a4j="http://richfaces.org/a4j">
<body>
<ui:composition template="/templates/template.xhtml">
@@ -47,7 +48,7 @@
<p>Here you can see <b>default client-side</b>
tool-tip</p>
<pn:tooltip id="tt1" styleClass="tooltip">
<span style="white-space: nowrap"> This tool-tip
content was
- <strong>pre-rendered</strong> to the page.<br/>
+ <strong>pre-rendered</strong> to the page.\n
Also the tooltip following mouse by default </span>
</pn:tooltip>
</rich:panel>
@@ -58,7 +59,7 @@
<pn:tooltip followMouse="false" showDelay="1500"
styleClass="tooltip-custom-body">
<span style="white-space: nowrap"> This tool-tip content
also
- <strong>pre-rendered</strong> to the page.<br/>
+ <strong>pre-rendered</strong> to the page.
</span>
</pn:tooltip>
</rich:panel>
@@ -95,13 +96,55 @@
<h:panelGrid columns="2">
<h:outputText style="white-space:nowrap"
value="tooltips requested:"/>
- <h:outputText
value="#{tooltipData.tooltipCounter}"
+ <h:outputText
value="#{tooltipBean.tooltipCounter}"
styleClass="tooltipData"/>
</h:panelGrid>
</pn:tooltip>
</rich:panel>
</h:form>
- </h:panelGrid>
+ </h:panelGrid>
+ <br /><br />
+ <h:form>
+ <rich:panel id="tooltip" styleClass="tooltip-text"
+ bodyClass="rich-laguna-panel-no-header">
+ <p>This tool-tip rendered on server <b>in separate
request</b>.
+ </p>
+ <pn:tooltip styleClass="tooltip" layout="block"
+ jointPoint="#{tooltipBean.jointPoint}"
+ direction="#{tooltipBean.direction}"
+ horizontalOffset="#{tooltipBean.horizontalOffset}"
+ verticalOffset="#{tooltipBean.verticalOffset}">
+ Sample tooltip to test attributes:
+ <ul>
+ <li>jointPoint</li>
+ <li>direction</li>
+ <li>horizontalOffset</li>
+ <li>verticalOffset</li>
+ </ul>
+ </pn:tooltip>
+ </rich:panel>
+ <h:panelGrid columns="2">
+ <h:outputText value="Select joint point:" />
+ <h:selectOneMenu value="#{tooltipBean.jointPoint}">
+ <a4j:ajax execute="@form" event="change" render="tooltip
@this" />
+ <f:selectItems value="#{tooltipBean.positioningValues}"
var="v" itemLabel="#{v}" itemValue="#{v}"/>
+ </h:selectOneMenu>
+ <h:outputText value="Select direction:" />
+ <h:selectOneMenu value="#{tooltipBean.direction}">
+ <f:ajax execute="@form" event="change" render="tooltip
@this" />
+ <f:selectItems value="#{tooltipBean.positioningValues}"
var="v" itemLabel="#{v}" itemValue="#{v}"/>
+ </h:selectOneMenu>
+ <h:outputText value="Horisontal offset:" />
+ <h:inputText value="#{tooltipBean.horizontalOffset}">
+ <a4j:ajax execute="@form" event="change" render="tooltip
@this" />
+ </h:inputText>
+ <h:outputText value="Vertical offset:" />
+ <h:inputText value="#{tooltipBean.verticalOffset}">
+ <f:ajax execute="@form" event="change" render="tooltip
@this" />
+ </h:inputText>
+ </h:panelGrid>
+ <a4j:outputPanel
ajaxRendered="true"><h:messages></h:messages></a4j:outputPanel>
+ </h:form>
</ui:define>
</ui:composition>
</body>
Modified: trunk/examples/output-demo/src/main/webapp/qunit/tooltip.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/qunit/tooltip.xhtml 2010-12-29 00:53:56 UTC
(rev 20835)
+++ trunk/examples/output-demo/src/main/webapp/qunit/tooltip.xhtml 2010-12-29 13:07:44 UTC
(rev 20836)
@@ -49,7 +49,7 @@
<div id="myRectangle" style="border: 2px solid red;
background-color: #adff2f; width:300px; height:300px">
Tooltip apeared under green rectangle.
- <pn:tooltip id="tooltip" target="myRectangle"
mode="ajax" showDelay="500">
+ <pn:tooltip id="tooltip" target="myRectangle"
mode="client" showDelay="500">
New Tooltip Yo!!!
</pn:tooltip>
</div>
@@ -63,7 +63,7 @@
<div id="testDiv" style="margin-top:10px; border:1px solid
#a0a0a0">Main Test Div</div>
</div>
- <!--<h:outputScript name="tests/richfaces-tooltip-qunit.js"
/>-->
+ <h:outputScript name="tests/richfaces-tooltip-qunit.js" />
</ui:define>
</ui:composition>
</body>
Modified:
trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-tooltip-qunit.js
===================================================================
---
trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-tooltip-qunit.js 2010-12-29
00:53:56 UTC (rev 20835)
+++
trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-tooltip-qunit.js 2010-12-29
13:07:44 UTC (rev 20836)
@@ -43,15 +43,15 @@
equals(c.id, TOOLTIP_ID, "id");
// test default options
- same(c.options.direction, RichFaces.ui.TooltipDirection.DEFAULT,
"Direction");
+ same(c.options.direction, "AA", "Direction");
same(c.options.attached, true, "Attached");
- same(c.options.offset, {}, "Offset");
+ same(c.options.offset, [10,10], "Offset");
same(c.options.mode, RichFaces.ui.TooltipMode.DEFAULT, "Mode");
same(c.options.disabled, false, "Disabled");
same(c.options.hideDelay, 0, "Hide Delay");
- same(c.options.hideEvent, "leave", "Hide Event");
- same(c.options.showDelay, 0, "Show Delay");
- same(c.options.showEvent, "enter", "Show Event");
+ same(c.options.hideEvent, "mouseleave", "Hide Event");
+ same(c.options.showDelay, 500, "Show Delay");
+ same(c.options.showEvent, "mouseenter", "Show Event");
same(c.options.followMouse, true, "Follow Mouse");
});
Modified: trunk/ui/common/api/src/main/java/org/richfaces/component/Positioning.java
===================================================================
--- trunk/ui/common/api/src/main/java/org/richfaces/component/Positioning.java 2010-12-29
00:53:56 UTC (rev 20835)
+++ trunk/ui/common/api/src/main/java/org/richfaces/component/Positioning.java 2010-12-29
13:07:44 UTC (rev 20836)
@@ -4,18 +4,18 @@
* @author amarkhel
*/
public enum Positioning {
+ auto("AA"),
+ topLeft("LT"),
topRight("RT"),
- topLeft("LT"),
- bottomRight("BR"),
- bottomLeft("BL"),
+ bottomLeft("LB"),
+ bottomRight("RB"),
- auto("AA"),
+ autoLeft("LA"),
+ autoRight("RA"),
topAuto("AT"),
- bottomAuto("AB"),
- autoRight("RA"),
- autoLeft("LA");
+ bottomAuto("AB");
- public static final Positioning DEFAULT = bottomRight;
+ public static final Positioning DEFAULT = auto;
String value;
Modified: trunk/ui/common/ui/src/main/resources/META-INF/resources/org.richfaces/popup.js
===================================================================
---
trunk/ui/common/ui/src/main/resources/META-INF/resources/org.richfaces/popup.js 2010-12-29
00:53:56 UTC (rev 20835)
+++
trunk/ui/common/ui/src/main/resources/META-INF/resources/org.richfaces/popup.js 2010-12-29
13:07:44 UTC (rev 20836)
@@ -25,15 +25,17 @@
rf.ui = rf.ui || {};
rf.ui.Popup = function(id, options) {
- this.id = id;
+ $super.constructor.call(this, id);
+ this.options = $.extend({}, defaultOptions, options);
+ this.positionOptions = {type: this.options.positionType,
from:this.options.jointPoint, to:this.options.direction, offset:
this.options.positionOffset};
+
this.popup = $(document.getElementById(id));
- var mergedOptions = $.extend({}, defaultOptions, options);
- this.visible = mergedOptions.visible;
- this.attachTo = mergedOptions.attachTo;
- this.attachToBody = mergedOptions.attachToBody;
- this.positionType = mergedOptions.positionType;
- this.positionOffset = mergedOptions.positionOffset;
+ this.visible = this.options.visible;
+ this.attachTo = this.options.attachTo;
+ this.attachToBody = this.options.attachToBody;
+ this.positionType = this.options.positionType;
+ this.positionOffset = this.options.positionOffset;
};
rf.BaseComponent.extend(rf.ui.Popup);
@@ -56,7 +58,7 @@
this.visible = true;
}
- this.popup.setPosition(event || {id: this.attachTo}, {type: this.positionType
, offset: this.positionOffset}).show();
+ this.popup.setPosition(event || {id: this.attachTo},
this.positionOptions).show();
},
hide: function() {
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/UITooltip.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/UITooltip.java 2010-12-29
00:53:56 UTC (rev 20835)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/UITooltip.java 2010-12-29
13:07:44 UTC (rev 20836)
@@ -37,6 +37,7 @@
value,
layout,
attached,
+ jointPoint,
direction,
disabled,
followMouse,
@@ -86,7 +87,15 @@
public void setAttached(boolean attached) {
getStateHelper().put(PropertyKeys.attached, attached);
}
+
+ public Positioning getJointPoint() {
+ return (Positioning) getStateHelper().eval(PropertyKeys.jointPoint,
Positioning.DEFAULT);
+ }
+ public void setJointPoint(Positioning jointPoint) {
+ getStateHelper().put(PropertyKeys.jointPoint, jointPoint);
+ }
+
public Positioning getDirection() {
return (Positioning) getStateHelper().eval(PropertyKeys.direction,
Positioning.DEFAULT);
}
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java 2010-12-29
00:53:56 UTC (rev 20835)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java 2010-12-29
13:07:44 UTC (rev 20836)
@@ -160,7 +160,8 @@
Map<String, Object> options = new HashMap<String, Object>();
options.put("ajax", getAjaxOptions(context, tooltip));
- options.put("direction", tooltip.getDirection());
+ options.put("jointPoint", tooltip.getJointPoint().getValue());
+ options.put("direction", tooltip.getDirection().getValue());
options.put("attached", tooltip.isAttached());
options.put("offset", getOffset(tooltip));
options.put("mode", tooltip.getMode());
@@ -181,7 +182,7 @@
}
public Integer[] getOffset(HtmlTooltip tooltip) {
- return new Integer[] {tooltip.getHorizontalOffset(),
tooltip.getHorizontalOffset()};
+ return new Integer[] {tooltip.getHorizontalOffset(),
tooltip.getVerticalOffset()};
}
private void encodeContentEnd(ResponseWriter writer, FacesContext context,
AbstractTooltip tooltip) throws IOException {
Modified:
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/tooltip.js
===================================================================
---
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/tooltip.js 2010-12-29
00:53:56 UTC (rev 20835)
+++
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/tooltip.js 2010-12-29
13:07:44 UTC (rev 20836)
@@ -25,17 +25,6 @@
rf.ui = rf.ui || {};
- rf.ui.TooltipDirection = {
- topRight : "topRight",
- topLeft : "topLeft",
- bottomRight : "bottomRight",
- bottomLeft : "bottomLeft",
- auto : "auto",
-
- DEFAULT: "bottomRight"
- };
- var TooltipDirection = rf.ui.TooltipDirection;
-
rf.ui.TooltipMode = {
client : "client",
ajax : "ajax",
@@ -45,7 +34,9 @@
var TooltipMode = rf.ui.TooltipMode;
var DEFAULT_OPTIONS = {
- direction : TooltipDirection.DEFAULT,
+ jointPoint : "AA",
+ direction : "AA",
+ offset: [0,0],
attached : true,
offset : [10, 10],
mode : TooltipMode.DEFAULT,
@@ -132,7 +123,9 @@
attachTo: this.target,
attachToBody: false,
positionType: "TOOLTIP",
- positionOffset: this.options.offset
+ positionOffset: this.options.offset,
+ jointPoint: this.options.jointPoint,
+ direction: this.options.direction
});
var tooltip = this;