Author: pyaschenko
Date: 2010-11-18 03:29:52 -0500 (Thu, 18 Nov 2010)
New Revision: 20083
Modified:
trunk/core/impl/src/main/resources/META-INF/resources/jquery.position.js
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml
trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml
Log:
https://jira.jboss.org/browse/RF-9650
https://jira.jboss.org/browse/RF-9644
Modified: trunk/core/impl/src/main/resources/META-INF/resources/jquery.position.js
===================================================================
--- trunk/core/impl/src/main/resources/META-INF/resources/jquery.position.js 2010-11-18
07:24:59 UTC (rev 20082)
+++ trunk/core/impl/src/main/resources/META-INF/resources/jquery.position.js 2010-11-18
08:29:52 UTC (rev 20083)
@@ -5,7 +5,7 @@
*/
// draft examples of usage
-// jQuery('#tooltip').setPosition('#aaa',{from:'LB',
to:'AA'});
+// jQuery('#tooltip').setPosition('#aaa',{from:'bottom-left',
to:'auto-auto'});
//
jQuery('#bbb').bind("click",function(e){jQuery('#tooltip').setPosition(e);});
// TODO: clear code
// TODO: optimization
@@ -81,6 +81,14 @@
var def = params.type || params.from || params.to ? $.PositionTypes[params.type ||
defaultType] : {noPositionType:true};
var options = $.extend({}, defaults, def, params);
+ if (!options.noPositionType) {
+ if (options.from.length>2) {
+ options.from = positionDefinition[options.from.toLowerCase()];
+ }
+ if (options.to.length>2) {
+ options.to = positionDefinition[options.to.toLowerCase()];
+ }
+ }
return this.each(function() {
element = $(this);
//alert(rect.left+" "+rect.top+" "+rect.width+"
"+rect.height);
@@ -98,6 +106,17 @@
var re = /^(left|right)-(top|buttom|auto)$/i;
// TODO: make it private
+ var positionDefinition = {
+ 'top-left':'LT',
+ 'top-right':'RT',
+ 'bottom-left':'LB',
+ 'bottom-right':'RB',
+ 'top-auto':'AT',
+ 'bottom-auto':'AB',
+ 'auto-left':'LA',
+ 'auto-right':'RA',
+ 'auto-auto':'AA'
+ };
$.PositionTypes = {
// horisontal constants: L-left, R-right, C-center, A-auto
// vertical constants: T-top, B-bottom, M-middle, A-auto
@@ -147,15 +166,15 @@
offset = e.offset();
var d = rect.left - offset.left;
if (d<0) {
- rect.width = (width > rect.width) ? width : rect.width - d;
+ if (width-d > rect.width) rect.width = width - d;
} else {
- if (d + width > rect.width) rect.width = d + width;
+ rect.width += d;
}
var d = rect.top - offset.top;
if (d<0) {
- rect.height = (height > rect.height) ? height : rect.height - d;
+ if (height-d > rect.height) rect.height = height -d;
} else {
- if (d + height > rect.height) rect.height = d + height;
+ rect.height += d;
}
if (offset.left < rect.left) rect.left = offset.left;
if (offset.top < rect.top) rect.top = offset.top;
Modified: trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
===================================================================
---
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java 2010-11-18
07:24:59 UTC (rev 20082)
+++
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java 2010-11-18
08:29:52 UTC (rev 20083)
@@ -18,6 +18,8 @@
private boolean showApply = true;
private boolean useCustomDayLabels;
private String mode = "client";
+ private String jointPoint = "auto-auto";
+ private String direction = "auto-auto";
public CalendarBean() {
@@ -92,4 +94,20 @@
this.showApply = showApply;
}
+ public void setJointPoint(String jointPoint) {
+ this.jointPoint = jointPoint;
+ }
+
+ public String getJointPoint() {
+ return jointPoint;
+ }
+
+ public void setDirection(String direction) {
+ this.direction = direction;
+ }
+
+ public String getDirection() {
+ return direction;
+ }
+
}
\ No newline at end of file
Modified: trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml
===================================================================
--- trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-18 07:24:59
UTC (rev 20082)
+++ trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-18 08:29:52
UTC (rev 20083)
@@ -37,14 +37,14 @@
<h:panelGrid id="panel" columns="2">
<h:panelGroup layout="block">
<calendar:calendar value="#{calendarBean.selectedDate}"
id="calendar"
+ jointPoint="#{calendarBean.jointPoint}"
direction="#{calendarBean.direction}"
locale="#{calendarBean.locale}" popup="#{calendarBean.popup}"
datePattern="#{calendarBean.pattern}"
dataModel="#{calendarDataModel}"
mode="#{calendarBean.mode}"
showApplyButton="#{calendarBean.showApply}" cellWidth="24px"
- cellHeight="22px" style="width:200px">
- <f:convertDateTime pattern="#{calendarBean.pattern}"
- onchange="alert('1')" />
+ cellHeight="22px" style="width:200px"
minDaysInFirstWeek="3">
+ <f:convertDateTime pattern="#{calendarBean.pattern}" />
</calendar:calendar>
</h:panelGroup>
<h:panelGrid columns="2">
@@ -82,6 +82,24 @@
<f:selectItem itemValue="ajax"/>
</h:selectOneMenu><br/>
+ <h:outputText value="Select joint point:" />
+ <h:selectOneMenu value="#{calendarBean.jointPoint}">
+ <f:ajax execute="@form" event="change" render="calendar
@this" />
+ <f:selectItem itemLabel="auto-auto" itemValue="auto-auto"
/>
+ <f:selectItem itemLabel="top-left" itemValue="top-left"
/>
+ <f:selectItem itemLabel="top-right" itemValue="top-right"
/>
+ <f:selectItem itemLabel="bottom-left" itemValue="bottom-left"
/>
+ <f:selectItem itemLabel="bottom-right"
itemValue="bottom-right" />
+ </h:selectOneMenu>
+ <h:outputText value="Select direction:" />
+ <h:selectOneMenu value="#{calendarBean.direction}">
+ <f:ajax execute="@form" event="change" render="calendar
@this" />
+ <f:selectItem itemLabel="auto-auto" itemValue="auto-auto"
/>
+ <f:selectItem itemLabel="top-left" itemValue="top-left"
/>
+ <f:selectItem itemLabel="top-right" itemValue="top-right"
/>
+ <f:selectItem itemLabel="bottom-left" itemValue="bottom-left"
/>
+ <f:selectItem itemLabel="bottom-right"
itemValue="bottom-right" />
+ </h:selectOneMenu>
</h:panelGrid>
</h:panelGrid>
</h:form>
Modified: trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml 2010-11-18 07:24:59
UTC (rev 20082)
+++ trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml 2010-11-18 08:29:52
UTC (rev 20083)
@@ -26,7 +26,7 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:pn="http://richfaces.org/output">
+
xmlns:rich="http://richfaces.org/output">
<body>
<ui:composition template="/templates/template.xhtml">
@@ -39,11 +39,67 @@
<ui:define name="body_head">TOOLTIP JS Development</ui:define>
<ui:define name="body">
- <h:form id="f" style="border:blue solid thin;">
- <pn:tooltip id="tooltip">
- <!-- TODO -->
- </pn:tooltip>
- </h:form>
+ <h:panelGrid columns="2">
+ <rich:panel id="sample1" styleClass="tooltip-text"
+ bodyClass="rich-laguna-panel-no-header">
+ <p>Here you can see <b>default client-side</b>
tool-tip</p>
+ <rich:tooltip id="tt1" styleClass="tooltip">
+ <span style="white-space: nowrap"> This tool-tip content
was
+ <strong>pre-rendered</strong> to the page.<br />
+ Also the tooltip following mouse by default </span>
+ </rich:tooltip>
+ </rich:panel>
+ <rich:panel id="sample2" styleClass="tooltip"
+ bodyClass="rich-laguna-panel-no-header">
+ <p>This tool-tip will not <b>follow mouse</b>. Also this
tool-tip
+ has a <b>delay 1.5 sec</b>, so be patient!</p>
+ <rich: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 />
+ </span>
+ </rich:tooltip>
+ </rich:panel>
+ <h:form>
+ <rich:panel id="sample3" styleClass="tooltip-text"
+ bodyClass="rich-laguna-panel-no-header">
+ <p>This tool-tip rendered on server <b>in separate
request</b>.
+ </p>
+ <rich:tooltip mode="ajax" styleClass="tooltip"
layout="block">
+ <f:facet name="defaultContent">
+ <strong>Wait...</strong>
+ </f:facet>
+ <span style="white-space: nowrap">This tool-tip
content was
+ <strong>rendered on server</strong> </span>
+ <h:panelGrid columns="2">
+ <h:outputText style="white-space:nowrap"
+ value="tooltips requested" />
+ </h:panelGrid>
+ </rich:tooltip>
+ </rich:panel>
+ </h:form>
+ <h:form>
+ <rich:panel id="sample4" styleClass="tooltip-text"
+ bodyClass="rich-laguna-panel-no-header">
+ <p>This tool-tip will be <b>activated on mouse
click</b>.</p>
+ <rich:tooltip showEvent="click" mode="ajax"
styleClass="tooltip"
+ layout="block">
+ <f:facet name="defaultContent">
+ <strong>Wait...</strong>
+ </f:facet>
+ <span style="white-space: nowrap">This tool-tip
content was
+ <strong>rendered on server</strong><br />
+ </span>
+ <h:panelGrid columns="2">
+ <h:outputText style="white-space:nowrap"
+ value="tooltips requested:" />
+ <h:outputText
value="#{tooltipData.tooltipCounter}"
+ styleClass="tooltipData" />
+ </h:panelGrid>
+ </rich:tooltip>
+ </rich:panel>
+ </h:form>
+ </h:panelGrid>
</ui:define>
</ui:composition>
</body>