Author: nbelaevski
Date: 2007-07-19 15:23:27 -0400 (Thu, 19 Jul 2007)
New Revision: 1707
Added:
trunk/sandbox/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarDataModelItemAdaptor.java
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CurrentDateChangeEvent.java
trunk/sandbox/ui/calendar/src/main/resources/org/
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
Modified:
trunk/docs/xslt/en/
trunk/sandbox/samples/rich-message-demo/
trunk/sandbox/samples/tooltip-sample/src/main/java/org/richfaces/Bean.java
trunk/sandbox/samples/tooltip-sample/src/main/webapp/WEB-INF/faces-config.xml
trunk/sandbox/samples/tooltip-sample/src/main/webapp/pages/index.jsp
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
trunk/sandbox/ui/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java
trunk/sandbox/ui/message/
trunk/sandbox/ui/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js
trunk/sandbox/ui/scrollable-grid/src/main/resources/org/richfaces/renderkit/html/css/grid.xcss
trunk/sandbox/ui/tooltip/src/main/config/component/toolTip.xml
trunk/sandbox/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java
trunk/sandbox/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/css/tooltip.xcss
trunk/sandbox/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js
Log:
Branch diff aplied for r1625:1705
Property changes on: trunk/docs/xslt/en
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
.settings
target
Added: trunk/sandbox/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
===================================================================
--- trunk/sandbox/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
(rev 0)
+++ trunk/sandbox/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp 2007-07-19
19:23:27 UTC (rev 1707)
@@ -0,0 +1,17 @@
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib
uri="http://richfaces.ajax4jsf.org/calendar"
prefix="calendar" %>
+<html>
+ <head>
+ <title></title>
+ </head>
+ <body>
+ <f:view>
+ <h:form>
+ <calendar:calendar id="calendar" >
+ </calendar:calendar>
+
+ </h:form>
+ </f:view>
+ </body>
+</html>
Property changes on: trunk/sandbox/samples/rich-message-demo
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
.settings
target
Modified: trunk/sandbox/samples/tooltip-sample/src/main/java/org/richfaces/Bean.java
===================================================================
--- trunk/sandbox/samples/tooltip-sample/src/main/java/org/richfaces/Bean.java 2007-07-19
18:53:25 UTC (rev 1706)
+++ trunk/sandbox/samples/tooltip-sample/src/main/java/org/richfaces/Bean.java 2007-07-19
19:23:27 UTC (rev 1707)
@@ -20,10 +20,68 @@
*/
package org.richfaces;
+
+import java.util.Date;
+
/**
* @author $Autor$
*
*/
public class Bean {
+ String text;
+
+ String toolTipContent = "ToolTip content";
+
+ String text1 = "ToolTip content1";
+ String text2 = "ToolTip content2";
+ String text3 = "ToolTip content3";
+
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public String getToolTipContent() {
+// toolTipContent += "12";
+// System.out.println("start - " + new Date(System.currentTimeMillis()));
+// for(int i=0;i<100000;i++){
+// double a = Math.cos(i+(Math.asin(1.334)));
+// }
+// System.out.println("end - " + new Date(System.currentTimeMillis()));
+ return toolTipContent;
+ }
+
+ public void setToolTipContent(String toolTipContent) {
+ this.toolTipContent = toolTipContent;
+ }
+
+ public String getText1() {
+ return text1;
+ }
+
+ public void setText1(String text1) {
+ this.text1 = text1;
+ }
+
+ public String getText2() {
+ return text2;
+ }
+
+ public void setText2(String text2) {
+ this.text2 = text2;
+ }
+
+ public String getText3() {
+ return text3;
+ }
+
+ public void setText3(String text3) {
+ this.text3 = text3;
+ }
+
}
\ No newline at end of file
Modified: trunk/sandbox/samples/tooltip-sample/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/sandbox/samples/tooltip-sample/src/main/webapp/WEB-INF/faces-config.xml 2007-07-19
18:53:25 UTC (rev 1706)
+++
trunk/sandbox/samples/tooltip-sample/src/main/webapp/WEB-INF/faces-config.xml 2007-07-19
19:23:27 UTC (rev 1707)
@@ -5,6 +5,12 @@
<managed-bean>
<managed-bean-name>bean</managed-bean-name>
<managed-bean-class>org.richfaces.Bean</managed-bean-class>
- <managed-bean-scope>request</managed-bean-scope>
+ <managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>skinBean</managed-bean-name>
+ <managed-bean-class>org.richfaces.SkinBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+
</faces-config>
Modified: trunk/sandbox/samples/tooltip-sample/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox/samples/tooltip-sample/src/main/webapp/pages/index.jsp 2007-07-19
18:53:25 UTC (rev 1706)
+++ trunk/sandbox/samples/tooltip-sample/src/main/webapp/pages/index.jsp 2007-07-19
19:23:27 UTC (rev 1707)
@@ -1,33 +1,35 @@
<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib
uri="http://richfaces.ajax4jsf.org/tooltip"
prefix="tt"%>
-
+<%@ taglib
uri="https://ajax4jsf.dev.java.net/ajax"
prefix="a4j"%>
<html>
<head>
<title></title>
-
</head>
<body>
<f:view>
<h:form>
- <%--h:inputText value="Input text" id="inp1"
size="50">
- <tt:toolTip value="1231231">
- <f:facet name="defaultContent"><f:verbatim>DEFAULT
VALUE</f:verbatim></f:facet>
- </tt:toolTip>
- </h:inputText--%>
+ <h:selectOneRadio binding="#{skinBean.component}" />
+ <h:commandLink action="#{skinBean.change}" value="set skin"
/>
+ <f:verbatim>
+ <br/><br/>
+ </f:verbatim>
+ <h:inputText value="Ajax mode Tooltip with default content"
id="inp1" size="50">
+ <tt:toolTip id="tt" followMouse="false"
direction="top-right" mode="ajax"
value="#{bean.toolTipContent}" horizontalOffset="20"
verticalOffset="20">
+ <f:facet name="defaultContent"><f:verbatim>DEFAULT
CONTENT</f:verbatim>
+ </f:facet>
+ <h:outputText id="ot"
value="#{bean.toolTipContent}"></h:outputText>
+ <h:commandLink value="Click here to close
window..."></h:commandLink>
+ </tt:toolTip>
+ </h:inputText>
+
+ <h:commandButton value="Tooltip with followMouse mode"
id="btn">
+ <tt:toolTip value="Tooltip text"
followMouse="true"></tt:toolTip>
+ </h:commandButton>
+
+ <%--a4j:log popup="false" level="ALL"></a4j:log--%>
+ </h:form>
- <h:selectOneListbox value="sdfsfd" id="ddl">
- <tt:toolTip value="1231231">
- <f:facet name="defaultContent"><f:verbatim>DEFAULT VALUE
DropDown</f:verbatim></f:facet>
- </tt:toolTip>
-
- </h:selectOneListbox>
-
-
-
-
- <!-- h:inputText value="ddd"
onclick="toolTipAttach();alert(document.getElementById('lkjl'))"/-->
- </h:form>
</f:view>
</body>
</html>
Modified: trunk/sandbox/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
===================================================================
---
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-07-19
18:53:25 UTC (rev 1706)
+++
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-07-19
19:23:27 UTC (rev 1707)
@@ -21,16 +21,306 @@
package org.richfaces.component;
-import javax.faces.component.UIComponentBase;
+import java.io.IOException;
+import java.util.AbstractCollection;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.TimeZone;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.ConverterException;
+import javax.faces.convert.DateTimeConverter;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.ValueChangeEvent;
+import javax.faces.render.Renderer;
+
+import org.ajax4jsf.framework.ajax.AjaxChildrenEncoder;
+import org.ajax4jsf.framework.ajax.AjaxContext;
+import org.ajax4jsf.framework.ajax.AjaxEvent;
+import org.ajax4jsf.framework.util.message.Messages;
+import org.richfaces.renderkit.CalendarDataModelItemAdaptor;
+import org.richfaces.renderkit.CalendarRendererBase;
+import org.richfaces.renderkit.CurrentDateChangeEvent;
+
+// import org.richfaces.renderkit.html.BaseGradient.Data;
+
/**
* JSF component class
- *
+ *
*/
-public abstract class UICalendar extends UIComponentBase {
-
- public static final String COMPONENT_TYPE = "org.richfaces.Calendar";
-
+public abstract class UICalendar extends UIInput {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.Calendar";
+
private static final String COMPONENT_FAMILY = "org.richfaces.Calendar";
+
+ public abstract Locale getLocale();
+
+ public abstract void setLocale(Locale locale);
+
+ public abstract TimeZone getTimeZone();
+
+ public abstract void setTimeZone(TimeZone timeZone);
+
+ public abstract Date getPreloadDateRangeBegin();
+
+ public abstract void setPreloadDateRangeBegin(Date date);
+
+ public abstract Date getPreloadDateRangeEnd();
+
+ public abstract void setPreloadDateRangeEnd(Date date);
+
+ public abstract Date getCurrentDate();
+
+ public abstract void setCurrentDate(Date date);
+
+ public abstract CalendarDataModel getData();
+
+ public abstract void setData(CalendarDataModel dataModel);
+
+ // currentDate processing -------------------------------------------------
+
+ private Date currentDate = null;
+
+ public String getValueAsString(FacesContext context, UIComponent component)
+ throws IOException {
+ UICalendar calendar = (UICalendar) component;
+ Date valueString = calendar.getCurrentDate();
+ return valueString.toString();
+ }
+
+ public Date getConvertedValue(FacesContext context, String currentDateString)
+ throws ConverterException {
+
+ DateTimeConverter datetime = new DateTimeConverter();
+ datetime.setPattern("MM/yyyy");
+ Date newCurrentDate = (Date) datetime.getAsObject(context, this,
+ currentDateString);
+ return newCurrentDate;
+ }
+ public void updateCurrentDate(FacesContext context, Date currentDate) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ try{
+ ValueBinding vb = getValueBinding("currentDate");
+ if (vb != null) {
+ vb.setValue(context, currentDate);
+ return;
+ }else{ setCurrentDate(currentDate);}
+ }catch (Exception e) {
+
+ String messageString = e.getMessage();
+ FacesMessage message = new FacesMessage(messageString);
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ context.addMessage(getClientId(context), message);
+ }
+ }
+
+ private int getLastDayOfWeek(Calendar calendar) {
+ int i = calendar.getFirstDayOfWeek();
+ if (i == calendar.getActualMinimum(Calendar.DAY_OF_WEEK)) {
+ i = calendar.getActualMaximum(Calendar.DAY_OF_WEEK);
+ } else {
+ i--;
+ }
+
+ return i;
+ }
+
+ protected Date getDefaultPreloadBegin(Date date) {
+ Calendar calendar = Calendar.getInstance(getTimeZone(), getLocale());
+ calendar.setTime(date);
+ calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DATE));
+ /*
+ * //force recalculation calendar.getTimeInMillis();
+ * calendar.set(Calendar.DAY_OF_WEEK, calendar.getFirstDayOfWeek());
+ */
+ return calendar.getTime();
+ }
+
+ protected Date getDefaultPreloadEnd(Date date) {
+ Calendar calendar = Calendar.getInstance(getTimeZone(), getLocale());
+ calendar.setTime(date);
+ calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
+ /*
+ * //force recalculation calendar.getTimeInMillis();
+ * calendar.set(Calendar.DAY_OF_WEEK, getLastDayOfWeek(calendar));
+ */
+ return calendar.getTime();
+ }
+
+ protected Locale getDefaultLocale() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if (facesContext != null) {
+ UIViewRoot viewRoot = facesContext.getViewRoot();
+ if (viewRoot != null) {
+ Locale locale = viewRoot.getLocale();
+ if (locale != null) {
+ return locale;
+ }
+ }
+ }
+
+ return Locale.US;
+ }
+
+ protected TimeZone getDefaultTimeZone() {
+ return TimeZone.getDefault();
+ }
+
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ // TODO Auto-generated method stub
+ if (event instanceof AjaxEvent) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ AjaxContext ajaxContext = AjaxContext
+ .getCurrentInstance(facesContext);
+ ajaxContext.setResponseData(getPreload());
+ } else {
+ if (event instanceof CurrentDateChangeEvent) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ CurrentDateChangeEvent dateChangeEvent = (CurrentDateChangeEvent) event;
+ String currentDateString = dateChangeEvent.getCurrentDateString();
+
+ if (currentDateString != null) {
+ // if currentDateString is not null then event cames from apply request phase
+ try {
+ Date currentDate = getConvertedValue(facesContext, currentDateString);
+ CurrentDateChangeEvent newDateChangeEvent = new CurrentDateChangeEvent(this,
currentDate);
+ newDateChangeEvent.queue();
+ } catch (Exception e) {
+ String messageString = e.getMessage();
+ FacesMessage message = new FacesMessage(messageString);
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ facesContext.addMessage(getClientId(facesContext), message);
+ }
+
+ }
+ else{
+ Date currentDate1 = dateChangeEvent.getCurrentDate();
+ Date currentDate2 = getCurrentDate();
+ if(!currentDate1.equals(currentDate2)){
+ updateCurrentDate(facesContext, currentDate1);
+ ValueChangeEvent changeEvent = new
ValueChangeEvent(this,currentDate2,currentDate1);
+ changeEvent.queue();
+ //TODO Add ValueChange Events for currentDate
+
+ }
+
+ }
+ } else {
+ super.broadcast(event);
+ }
+
+ }
+
+ }
+
+ public Object getPreload() {
+ Date[] preloadDateRange = getPreloadDateRange();
+ if (preloadDateRange != null && preloadDateRange.length != 0) {
+ CalendarDataModel calendarDataModel = (CalendarDataModel) getData();
+ if (calendarDataModel != null) {
+ CalendarDataModelItem[] calendarDataModelItems = calendarDataModel
+ .getData(preloadDateRange);
+
+ HashMap args = new HashMap();
+ args.put("startDate", CalendarRendererBase
+ .formatDate(preloadDateRange[0]));
+ args
+ .put("days", new AdaptingCollection(
+ calendarDataModelItems));
+ return args;
+ }
+ }
+
+ return null;
+ }
+
+ public Date[] getPreloadDateRange() {
+ Date dateRangeBegin = this.getPreloadDateRangeBegin();
+ Date dateRangeEnd = this.getPreloadDateRangeEnd();
+
+ if (dateRangeBegin.after(dateRangeEnd)) {
+ // TODO add message
+ throw new IllegalArgumentException();
+ }
+
+ List dates = new ArrayList();
+
+ Calendar calendar = Calendar.getInstance(this.getTimeZone(), this
+ .getLocale());
+ Calendar calendar2 = (Calendar) calendar.clone();
+ calendar.setTime(dateRangeBegin);
+ calendar2.setTime(dateRangeEnd);
+
+ do {
+ dates.add(calendar.getTime());
+ calendar.add(Calendar.DATE, 1);
+ } while (!calendar.after(calendar2));
+
+ return (Date[]) dates.toArray(new Date[dates.size()]);
+ }
+
+ public void encodeAjaxChild(FacesContext context, String path, Set ids,
+ Set renderedAreas) throws IOException {
+
+ Renderer renderer = this.getRenderer(context);
+ if (renderer instanceof AjaxChildrenEncoder) {
+ ((AjaxChildrenEncoder) renderer).encodeAjaxChild(context, path,
+ ids, renderedAreas);
+ }
+ }
}
+
+class AdaptingCollection extends AbstractCollection {
+ private CalendarDataModelItem[] items;
+
+ public AdaptingCollection(CalendarDataModelItem[] items) {
+ super();
+ this.items = items;
+ }
+
+ public Iterator iterator() {
+ return new Iterator() {
+ private int idx = 0;
+
+ private CalendarDataModelItemAdaptor adaptor = new CalendarDataModelItemAdaptor();
+
+ public boolean hasNext() {
+ return idx < items.length;
+ }
+
+ public Object next() {
+ adaptor.setItem(items[idx++]);
+ return adaptor;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ };
+ }
+
+ public int size() {
+ return this.items.length;
+ }
+}
Added:
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarDataModelItemAdaptor.java
===================================================================
---
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarDataModelItemAdaptor.java
(rev 0)
+++
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarDataModelItemAdaptor.java 2007-07-19
19:23:27 UTC (rev 1707)
@@ -0,0 +1,49 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit;
+
+import org.richfaces.component.CalendarDataModelItem;
+
+/**
+ * @author Nick Belaevski - mailto:nbelaevski@exadel.com
+ * created 04.07.2007
+ *
+ */
+public class CalendarDataModelItemAdaptor {
+ private CalendarDataModelItem item;
+
+ public void setItem(CalendarDataModelItem item) {
+ this.item = item;
+ }
+
+ public CalendarDataModelItem getItem() {
+ return item;
+ }
+
+ public Object getDate() {
+ return CalendarRendererBase.formatDate(item.getDate());
+ }
+
+ public Object getData() {
+ return item.getData();
+ }
+}
Modified:
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
---
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-07-19
18:53:25 UTC (rev 1706)
+++
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-07-19
19:23:27 UTC (rev 1707)
@@ -21,19 +21,162 @@
package org.richfaces.renderkit;
+import java.io.IOException;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
+
+import org.ajax4jsf.framework.ajax.AjaxEvent;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.util.javascript.JSFunction;
+import org.ajax4jsf.framework.util.javascript.JSFunctionDefinition;
+import org.ajax4jsf.framework.util.javascript.JSReference;
+import org.ajax4jsf.framework.util.javascript.ScriptUtils;
import org.richfaces.component.UICalendar;
+import org.richfaces.component.util.HtmlUtil;
/**
- * @author Nick Belaevski - mailto:nbelaevski@exadel.com
- * created 08.06.2007
- *
+ * @author Nick Belaevski - mailto:nbelaevski@exadel.com created 08.06.2007
+ *
*/
public class CalendarRendererBase extends TemplateEncoderRendererBase {
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ public static final String DATE_SCROLL = "DateScroll";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
*/
protected Class getComponentClass() {
return UICalendar.class;
}
+
+ public String qualifySize(Object size) {
+ if (size == null) {
+ return "";
+ }
+ return HtmlUtil.qualifySize(size.toString());
+ }
+
+ public Date convertCurrentDate(String currentDateString) {
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.clear();
+ calendar.set(Calendar.DATE, 1);
+ int idx = currentDateString.indexOf('/');
+ calendar.set(Calendar.MONTH, Integer.parseInt(currentDateString
+ .substring(0, idx)));
+ calendar.set(Calendar.YEAR, Integer.parseInt(currentDateString
+ .substring(idx + 1)));
+
+ return calendar.getTime();
+
+ }
+
+ protected void doDecode(FacesContext context, UIComponent component) {
+ // TODO Auto-generated method stub
+ super.doDecode(context, component);
+
+ String clientId = component.getClientId(context);
+
+ Map requestParameterMap = context.getExternalContext()
+ .getRequestParameterMap();
+
+ String currentDateString = (String) requestParameterMap.get(clientId
+ + DATE_SCROLL);
+
+ if (currentDateString != null) {
+// ((UICalendar) component)
+// .setCurrentDate(convertCurrentDate(currentDateString));
+ CurrentDateChangeEvent ev = new CurrentDateChangeEvent(component, currentDateString)
;
+ ev.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
+ ev.queue();
+
+ new AjaxEvent(component).queue();
+ }
+
+ }
+
+
+
+ public void encodeChildren(FacesContext context, UIComponent calendar)
+ throws IOException {
+
+ }
+
+ public void writeMarkupScriptBody(FacesContext context,
+ UIComponent component, boolean children) throws IOException {
+ ResponseWriter responseWriter = context.getResponseWriter();
+ responseWriter
+ .write("function (context) { return this.invoke('getContent',
context).join('')");
+ responseWriter.write("}.bind(");
+ writeScriptBody(context, component, children);
+ responseWriter.write(")");
+ }
+
+ public void writePreloadBody(FacesContext context, UICalendar calendar)
+ throws IOException {
+ Object preload = calendar.getPreload();
+ if (preload != null) {
+ ResponseWriter writer = context.getResponseWriter();
+ writer.write(ScriptUtils.toScript(preload));
+ }
+ }
+
+ public void writeSubmitFunction(FacesContext context, UICalendar calendar)
+ throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+
+ String clientId = calendar.getClientId(context);
+
+ JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(calendar,
+ context, AjaxRendererUtils.AJAX_FUNCTION_NAME);
+ ajaxFunction.addParameter(JSReference.NULL);
+ Map options = AjaxRendererUtils.buildEventOptions(context, calendar);
+ options.put("calendar", JSReference.THIS);
+ // ajax single
+ options.put("control", new JSReference(JSReference.THIS.toScript(),
+ "id"));
+
+ String oncomplete = AjaxRendererUtils.getAjaxOncomplete(calendar);
+ JSFunctionDefinition oncompleteDefinition = new JSFunctionDefinition();
+ oncompleteDefinition.addParameter("request");
+ oncompleteDefinition.addParameter("event");
+ oncompleteDefinition.addParameter("data");
+ oncompleteDefinition.addToBody("this.calendar.load(data);");
+ if (oncomplete != null) {
+ oncompleteDefinition.addToBody(oncomplete);
+ }
+
+ options.put("oncomplete", oncompleteDefinition);
+ Map parametersMap = (Map) options.get("parameters");
+ JSReference requestValue = new JSReference("requestValue");
+ parametersMap.remove(clientId);
+ parametersMap.put(clientId + DATE_SCROLL, requestValue);
+ ajaxFunction.addParameter(options);
+ JSFunctionDefinition definition = new JSFunctionDefinition();
+ definition.addParameter(requestValue);
+ definition.addToBody(ajaxFunction);
+ writer.write(definition.toScript());
+ }
+
+ public static Object formatDate(Date date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ JSFunction result = new JSFunction("new Date");
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.YEAR)));
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.MONTH)));
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.DATE)));
+
+ return result;
+ }
+
}
Added:
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CurrentDateChangeEvent.java
===================================================================
---
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CurrentDateChangeEvent.java
(rev 0)
+++
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CurrentDateChangeEvent.java 2007-07-19
19:23:27 UTC (rev 1707)
@@ -0,0 +1,41 @@
+package org.richfaces.renderkit;
+
+import java.util.Date;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+public class CurrentDateChangeEvent extends FacesEvent {
+
+ private Date currentDate = null;
+ private String currentDateString = null;
+
+ public CurrentDateChangeEvent(UIComponent component, Date curentDate) {
+ super(component);
+ this.currentDate = curentDate;
+
+ }
+ public CurrentDateChangeEvent(UIComponent component, String curentDateString) {
+ super(component);
+ this.currentDateString = curentDateString;
+ }
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return false;
+ }
+
+ public void processListener(FacesListener listener) {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException();
+ }
+
+ public Date getCurrentDate() {
+ return currentDate;
+ }
+
+ public String getCurrentDateString() {
+ return currentDateString;
+ }
+
+}
Added:
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss
===================================================================
---
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss
(rev 0)
+++
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss 2007-07-19
19:23:27 UTC (rev 1707)
@@ -0,0 +1,236 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<f:template
xmlns:f='http:/jsf.exadel.com/template'
+
xmlns:u='http:/jsf.exadel.com/template/util'
+
xmlns="http://www.w3.org/1999/xhtml" >
+ <f:verbatim><![CDATA[
+.calendar_exterior{
+ border : 1px solid #c0c0c0; /*panelBorderColor*/
+}
+.calendar_btn{
+ cursor : pointer;
+}
+.calendar_header{
+ border-bottom : 1px solid #c0c0c0; /*panelBorderColor*/
+ background : #C7D7EC; /*additionalBackgroundColor*/
+ font-size : 11px; /*generalSizeFont*/
+ font-family : verdana; /*generalFamilyFont*/
+ padding : 7px;
+ height : 22px;
+}
+
+.cell_size{
+ width : 25px;
+ height : 22px;
+}
+
+.calendar_cell{
+ background-color : #FFFFFF; /*generalBackgroundColor*/
+ border-bottom : 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right : 1px solid #c0c0c0; /*panelBorderColor*/
+ font-size : 11px; /*generalSizeFont*/
+ font-family : verdana; /*generalFamilyFont*/
+ padding : 0px;
+ vertical-align : middle;
+ text-align : center;
+}
+
+.calendar_tool{
+ border-bottom : 1px solid #c0c0c0; /*panelBorderColor*/
+ background-color : #224986; /*headerBackgroundColor*/
+ font-size : 11px; /*headerSizeFont*/
+ font-family : verdana; /*headerFamilyFont*/
+ color : #ffffff; /*headerTextColor*/
+ font-weight : bold;
+ vertical-align : middle;
+ text-align : center;
+ width : 25px;
+ height : 22px;
+}
+
+.calendar_month{
+ border-bottom : 1px solid #c0c0c0; /*panelBorderColor*/
+ background-color : #224986; /*headerBackgroundColor*/
+ font-size : 11px; /*headerSizeFont*/
+ font-family : verdana; /*headerFamilyFont*/
+ color : #ffffff; /*headerTextColor*/
+ font-weight : bold;
+ vertical-align : middle;
+ text-align : center;
+}
+
+.calendar_days{
+ border-bottom : 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right : 0px solid #c0c0c0; /*panelBorderColor*/
+ background : #C7D7EC; /*additionalBackgroundColor*/
+ font-size : 11px; /*generalSizeFont*/
+ font-family : verdana; /*generalFamilyFont*/
+ vertical-align : middle;
+ text-align : center;
+ height : 22px;
+}
+
+.calendar_week{
+ border-bottom : 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right : 1px solid #c0c0c0; /*panelBorderColor*/
+ font-size : 11px; /*generalSizeFont*/
+ font-family : verdana; /*generalFamilyFont*/
+ background-color : #f5f5f5; /*unknown parameter - need to add*/
+ vertical-align : middle;
+ text-align : center;
+ width : 25px;
+}
+
+.calendar_holly{
+ background-color : #ffebda; /*unknown parameter - need to add*/
+ color : #ff7800; /*unknown parameter - need to add*/
+}
+
+/*.calendar_current{
+ background-color : #ff7800; /*unknown parameter - need to add*/
+ color : #ffebda; /*unknown parameter - need to add*/
+ font-weight : bold;
+}*/
+
+.calendar_spec{
+ background-color : #e4f5e2; /*unknown parameter - need to add*/
+}
+
+.calendar_select{
+ background-color : #224986; /*headerBackgroundColor*/
+ color : #FFFFFF; /*headerTextColor*/
+ font-weight : bold;
+}
+
+
+.right_cell{
+ border-right : 0px;
+}
+
+.bottom_cell{
+ border-bottom : 0px;
+}
+
+.calendar_toolfooter{
+ border-top : 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right : 0px solid #c0c0c0; /*panelBorderColor*/
+ background : #C7D7EC; /*additionalBackgroundColor*/
+ font-size : 11px; /*generalSizeFont*/
+ font-family : verdana; /*generalFamilyFont*/
+ padding : 0px 7px 0px 7px;
+ height : 22px;
+}
+
+.calendar_footer{
+ border-top : 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right : 0px solid #c0c0c0; /*panelBorderColor*/
+ background : #C7D7EC; /*additionalBackgroundColor*/
+ font-size : 11px; /*generalSizeFont*/
+ font-family : verdana; /*generalFamilyFont*/
+ padding : 7px;
+ height : 22px;
+}
+ ]]>
+ </f:verbatim>
+
+ <u:selector name=".calendar_exterior">
+ <u:style name="border-color" skin="panelBorderColor"/>
+ </u:selector>
+
+ <u:selector name=".calendar_header">
+ <u:style name="border-bottom" skin="panelBorderColor"/>
+ <u:style name="background"
skin="additionalBackgroundColor"/>
+ <u:style name="font-size" skin="generalSizeFont"/>
+ <u:style name="font-family" skin="generalFamilyFont"/>
+ </u:selector>
+
+ <u:selector name=".calendar_cell">
+ <u:style name="border-bottom" skin="panelBorderColor"/>
+ <u:style name="border-right" skin="panelBorderColor"/>
+ <u:style name="background-color"
skin="generalBackgroundColor"/>
+ <u:style name="font-size" skin="generalSizeFont"/>
+ <u:style name="font-family" skin="generalFamilyFont"/>
+ </u:selector>
+
+ <u:selector name=".calendar_tool">
+ <u:style name="border-bottom" skin="panelBorderColor"/>
+ <u:style name="background-color"
skin="headerBackgroundColor"/>
+ <u:style name="font-size" skin="headerSizeFont"/>
+ <u:style name="font-family" skin="headerFamilyFont"/>
+ <u:style name="color" skin="headerTextColor"/>
+ </u:selector>
+
+ <u:selector name=".calendar_month">
+ <u:style name="border-bottom" skin="panelBorderColor"/>
+ <u:style name="background-color"
skin="headerBackgroundColor"/>
+ <u:style name="font-size" skin="headerSizeFont"/>
+ <u:style name="font-family" skin="headerFamilyFont"/>
+ <u:style name="color" skin="headerTextColor"/>
+ </u:selector>
+
+ <u:selector name=".calendar_days">
+ <u:style name="border-bottom" skin="panelBorderColor"/>
+ <u:style name="border-right" skin="panelBorderColor"/>
+ <u:style name="background"
skin="additionalBackgroundColor"/>
+ <u:style name="font-size" skin="generalSizeFont"/>
+ <u:style name="font-family" skin="generalFamilyFont"/>
+ </u:selector>
+
+/* background-color : #f5f5f5; unknown parameter - need to add*/
+ <u:selector name=".calendar_week">
+ <u:style name="border-bottom" skin="panelBorderColor"/>
+ <u:style name="border-right" skin="panelBorderColor"/>
+ <u:style name="font-size" skin="generalSizeFont"/>
+ <u:style name="font-family" skin="generalFamilyFont"/>
+ </u:selector>
+
+/*
+.calendar_holly{
+ background-color : #ffebda; /*unknown parameter - need to add
+ color : #ff7800; /*unknown parameter - need to add
+}
+*/
+/*
+.calendar_current{
+ background-color : #ff7800; /*unknown parameter - need to add
+ color : #ffebda; /*unknown parameter - need to add
+ font-weight : bold;
+}
+*/
+/*
+.calendar_spec{
+ background-color : #e4f5e2; /*unknown parameter - need to add
+}
+*/
+ <u:selector name=".calendar_current">
+ <u:style name="background-color" value="#ff7800"/> /*unknown
parameter - need to add*/
+ <u:style name="color" value="#ffebda"/> /*unknown parameter
- need to add*/
+ <u:style name="font-weight" value="bold"/>
+ </u:selector>
+
+ <u:selector name=".calendar_select">
+ <u:style name="background-color"
skin="headerBackgroundColor"/>
+ <u:style name="color" skin="headerTextColor"/>
+ </u:selector>
+
+ <u:selector name=".calendar_select">
+ <u:style name="background-color"
skin="headerBackgroundColor"/>
+ <u:style name="color" skin="headerTextColor"/>
+ </u:selector>
+
+ <u:selector name=".calendar_toolfooter">
+ <u:style name="border-top" skin="panelBorderColor"/>
+ <u:style name="border-right" skin="panelBorderColor"/>
+ <u:style name="background"
skin="additionalBackgroundColor"/>
+ <u:style name="font-size" skin="generalSizeFont"/>
+ <u:style name="font-family" skin="generalFamilyFont"/>
+ </u:selector>
+
+ <u:selector name=".calendar_footer">
+ <u:style name="border-top" skin="panelBorderColor"/>
+ <u:style name="border-right" skin="panelBorderColor"/>
+ <u:style name="background"
skin="additionalBackgroundColor"/>
+ <u:style name="font-size" skin="generalSizeFont"/>
+ <u:style name="font-family" skin="generalFamilyFont"/>
+ </u:selector>
+
+</f:template>
\ No newline at end of file
Added:
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
---
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
(rev 0)
+++
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-07-19
19:23:27 UTC (rev 1707)
@@ -0,0 +1,752 @@
+if(!window.LOG){
+ window.LOG = {warn:function(){}};
+}
+
+//if (!window.Richfaces) window.Richfaces={};
+
+Object.extend(Event, {
+ findElementByAttr : function(event, tagName, attribute, value, flag) {
+ var element = Event.findElement(event, tagName);
+ while (!element[attribute] || (flag ? element[attribute].indexOf(value)!=0 :
element[attribute]!=value) )
+ {
+ element = element.parentNode;
+ }
+ return element;
+ }
+});
+
+Object.extend(Element, {
+ replaceClassName : function (element, whichClassName, toClassName) {
+ if (!(element = $(element))) return;
+ var e = Element.classNames(element);
+ e.remove(whichClassName);
+ e.add(toClassName);
+ return element;
+ }
+});
+
+/* Year:
+ * yy - 00-99
+ * y,yyy+ - 1999
+ * Month:
+ * M - 1-12
+ * MM - 01-12
+ * MMM - short (Jul)
+ * MMMM+ - long (July)
+ * Date:
+ * d - 1-31
+ * dd+ - 01-31 */
+Object.extend(Date.prototype, {
+ format : function(pattern, monthNames, monthNamesShort) {
+ if (!monthNames) monthNames =
['January','February','March','April','May','June','July','August','September','October','November','December'];
+ if (!monthNamesShort) monthNamesShort =
['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
+ var d = this; var mm; var dd;
+ return pattern.replace(/(yy^y|y+|M^M|MM^M|MMM^M|M+|d^d|d+)/g,
+ function($1) {
+ switch ($1) {
+ case 'yy': return d.getYear().toString().substr(-2);
+ case 'M': return d.getMonth()+1;
+ case 'MM': return (mm = d.getMonth()+1)<10 ? '0'+mm :
mm;
+ case 'MMM': return monthNamesShort[d.getMonth()];
+ case 'd': return d.getDate();
+ }
+ // y+,M+,d+
+ var ch = $1.charAt(0);
+ if (ch=='y') return d.getFullYear();
+ if (ch=='M') return monthNames[d.getMonth()];
+ if (ch=='d') return (dd = d.getDate())<10 ? '0'+dd : dd;
+ }
+ );
+ }
+});
+
+function isLeapYear(year) {
+ return new Date(year, 1, 29).getDate()==29;
+}
+
+function daysInMonth(year,month) {
+ return 32 - new Date(year, month, 32).getDate();
+}
+
+function daysInMonthByDate(date) {
+ return 32 - new Date(date.getYear(), date.getMonth(), 32).getDate();
+}
+
+function getDay(date, firstWeekDay ) {
+ var value = date.getDay() - firstWeekDay;
+ if (value < 0) value = 7 + value;
+ return value;
+}
+
+function getFirstWeek(year, mdifw, fdow) {
+ var date = new Date(year,0,1);
+ var firstday = getDay(date, fdow);
+
+ var weeknumber = (7-firstday<mdifw) ? 0 : 1;
+
+ return {date:date, firstDay:firstday, weekNumber:weeknumber, mdifw:mdifw, fdow:fdow};
+}
+
+function getLastWeekOfPrevYear(o) {
+ var year = o.date.getFullYear()-1;
+ var days = (isLeapYear(year) ? 366 : 365);
+ var obj = getFirstWeek(year, o.mdifw, o.fdow);
+ days = (days - 7 + o.firstDay);
+ var weeks = Math.floor(days/7)+1;
+
+ return weeks+obj.weekNumber;
+}
+
+function weekNumber(year, month, mdifw, fdow) {
+
+ var o = getFirstWeek(year, mdifw, fdow);
+
+ if (month==0)
+ {
+ if (o.weekNumber==1) return 1;
+ return getLastWeekOfPrevYear(o);
+ }
+ var oneweek = 604800000;
+ var d = new Date(year, month,1);
+ d.setDate( 1+o.firstDay + (getDay(d,fdow)==0?1:0));
+
+ weeknumber = o.weekNumber + Math.floor((d.getTime() - o.date.getTime()) / oneweek);
+
+ return weeknumber;
+}
+
+Calendar = Class.create();
+Object.extend(Calendar.prototype, {
+ initialize: function(id,parameters) {
+
+ // dayListTableId, weekNumberBarId, weekDayBarId - 3 tables ids',
+ // dayListMarkup - day cell markup
+ // weekNumberMarkup - week number cell markup
+ // weekDayMarkup - week day cell markup
+
+ // currentDate - date to show month (day not used) (mm/yyyy)
+ // selectedDate - selected date (mm/dd/yyyy)
+ // weekDayLabels - collection of week day labels keyed by week day numbers
+ // minDaysInFirstWeek - locale-specific constant defining number of days in the first
week
+ // firstWeekDay - (0..6) locale-specific constant defining number of the first week
day
+ // showWeekDaysBar - show WeekDays Bar [default value is true]
+ // showWeeksBar - show Weeks numbers bar [default value is true]
+
+ // headerHtml - user defined header (optional)
+ // footeHtml - user defined footer (optional)
+
+ // direction - [top-left, top-right, bottom-left, bottom-right, auto]
+ // jointPoint
+ // popup - true
+ // userClasses - inputClass, inputDisabledClass, inputInvalidClass, buttonClass,
buttonDisabledClass
+ // id+PopupButton, id+PopupInput,
+
+
+ this.id = id;
+ this.params = parameters;
+ if (!this.params.showWeekDaysBar) this.params.showWeekDaysBar = true;
+ if (!this.params.showWeeksBar) this.params.showWeeksBar = true;
+ if (this.params.monthLabels) this.params.monthLabels.push(this.params.monthLabels[0]);
+ if (!this.params.datePattern) this.params.datePattern = "MMM d, y"
+
+ this.currentDate = this.params.currentDate ? this.params.currentDate : new Date();
+ this.selectedDate = this.params.selectedDate;
+
+ this.todayDate = new Date();
+
+ this.selectedDateElement;
+
+ this.firstWeekendDayNumber = 6-this.params.firstWeekDay;
+ this.secondWeekendDayNumber = (this.params.firstWeekDay>0 ?
7-this.params.firstWeekDay : 0);
+
+ this.calendarContext = new CalendarContext(this);
+
+ /*this.ids = {
+ currentYearMonthId: this.id+':currentyearmonth'
+ };*/
+
+ this.daysData = {startDate:null, days:[]};
+ this.days = [];
+
+ var htmlTextHeader = '<input id="'+this.id+'InputSelectedDate"
name="'+this.id+'InputSelectedDate" type="hidden"
value="'+this.getSelectedDateString(this.params.datePattern)+'"/>\n'
+
+ '<input id="'+this.id+'InputCurrentDate"
name="'+this.id+'InputCurrentDate" type="hidden"
value="'+this.getCurrentDate().format("MM/y")+'"/>\n'
+
+ '<table border="0" cellpadding="0"
cellspacing="0" class="calendar_exterior"><tbody>\n';
+ var colspan = (this.params.showWeeksBar ? "8" : "7");
+ var htmlHeaderOptional = (this.params.headerHtml &&
this.params.headerHtml!='') ? '<tr><td
class="calendar_header"
colspan="'+colspan+'">'+this.params.headerHtml+'</td></tr>'
: '';
+ var htmlFooterOptional = (this.params.footerHtml &&
this.params.footerHtml!='') ? '<tr><td
class="calendar_footer"
colspan="'+colspan+'">'+this.params.footerHtml+'</td></tr>'
: '';
+ var htmlControlsHeader = '<tr><td colspan="'+colspan+'"
id="'+this.id+':header"></td></tr>'
+ var htmlControlsFooter = '<tr><td colspan="'+colspan+'"
id="'+this.id+':footer"></td></tr>'
+ var htmlTextFooter = '</tbody></table>\n';
+
+ // days bar creation
+ var styleClass;
+ var bottomStyleClass;
+ var htmlTextWeekDayBar='';
+ if (this.params.showWeekDaysBar)
+ {
+ var htmlTextWeekDayBar = '<tr
id="'+this.params.weekDayBarId+'">';
+ if (this.params.showWeeksBar) htmlTextWeekDayBar+='<td
style="calendar_days"><br/></td>';
+ var weekDayCounter = this.params.firstWeekDay;
+ for (var i=0;i<7;i++)
+ {
+ var weekDayHtml = this.params.weekDayMarkup( {weekDayLabel:
this.params.weekDayLabels[weekDayCounter], weekDayNumber:weekDayCounter,
componentId:this.getWeekDayComponentId(i)} );
+ if (weekDayCounter==6) weekDayCounter=0; else weekDayCounter++;
+
+ styleClass = (i==this.firstWeekendDayNumber || i==this.secondWeekendDayNumber ?
"Weekendclass" : "calendar_days");
+ if (i==6) styleClass +=" right_cell";
+ htmlTextWeekDayBar+='<td
class="'+styleClass+'">'+weekDayHtml+'</td>';
+ }
+ htmlTextWeekDayBar+='</tr>\n';
+ }
+
+ // week & weekNumber creation
+ var htmlTextWeek='';
+ var p=0;
+
+ for (k=1;k<7;k++)
+ {
+ htmlTextWeek+='<tr
id="'+this.params.weekNumberBarId+k+'">';
+ if (this.params.showWeeksBar)
+ {
+ var weekNumberHtml = this.params.weekNumberMarkup( {weekNumber: k,
componentId:this.getWeekNumberComponentId(k-1)} );
+ htmlTextWeek+='<td
class="calendar_week">'+weekNumberHtml+'</td>';
+ }
+
+ // day cells creation
+ bottomStyleClass = (k==6 ? "bottom_cell " : "");
+ for (var i=0;i<7;i++)
+ {
+ styleClass = bottomStyleClass+"cell_size calendar_cell calendar_btn";
+ if (i==this.firstWeekendDayNumber || i==this.secondWeekendDayNumber)
styleClass+=" calendar_holly";
+ if (i==6) styleClass+=" right_cell";
+
+ htmlTextWeek+='<td class="'+styleClass+'"
id="'+this.params.dayListTableId+'Cell'+p+'"></td>';
+ p++;
+ }
+ htmlTextWeek+='</tr>';
+ }
+
+ // footer
+
+
+ // set content
+ var obj=$(id);
+ obj.component = this;
+ obj.richfacesComponent="richfaces:calendar";
+ obj.innerHTML =
htmlTextHeader+htmlHeaderOptional+htmlControlsHeader+htmlTextWeekDayBar+htmlTextWeek+htmlControlsFooter+htmlFooterOptional+htmlTextFooter;
+
+ this.submitFunction = this.params.submitFunction.bind(this);
+ this.prepareEvents();
+ },
+
+ getWeekDayComponentId: function (v) {
+ return this.id+"WeekDay"+v;
+ },
+
+ getWeekNumberComponentId: function (v) {
+ return this.id+"WeekNumber"+v;
+ },
+
+ getDateComponentId: function (v) {
+ return this.id+"Date"+v;
+ },
+
+ getCurrentDate: function() {
+ return this.currentDate;
+ },
+ getSelectedDate: function() {
+ if (!this.selectedDate) return null; else return this.selectedDate;
+ },
+ getSelectedDateString: function(pattern) {
+ if (!this.selectedDate) return "";
+ if (!pattern) pattern = "dd/MM/y";
+ return this.selectedDate.format(pattern, this.params.monthLabels,
this.params.monthLabelsShort);
+ },
+
+ getPrevYear: function() {
+ var value = this.currentDate.getFullYear()-1;
+ if (value<0) value = 0;
+ return value;
+ },
+ getPrevMonth: function(asMonthLabel) {
+ var value = this.currentDate.getMonth()-1;
+ if (value < 0 ) value = 11;
+ if (asMonthLabel)
+ {
+ return this.params.monthLabels[value];
+ } else return value;
+ },
+ getCurrentYear: function() {
+ return this.currentDate.getFullYear();
+ },
+ getCurrentMonth: function(asMonthLabel) {
+ var value = this.currentDate.getMonth();
+ if (asMonthLabel)
+ {
+ return this.params.monthLabels[value];
+ } else return value;
+ },
+ getNextYear: function() {
+ return this.currentDate.getFullYear()+1;
+ },
+ getNextMonth: function(asMonthLabel) {
+ var value = this.currentDate.getMonth()+1;
+ if (value > 11 ) value = 0;
+ if (asMonthLabel)
+ {
+ return this.params.monthLabels[value];
+ } else return value;
+ },
+
+ isWeekend: function(weekday) {
+ return (weekday == this.firstWeekendDayNumber || weekday ==
this.secondWeekendDayNumber);
+ },
+
+ prepareEvents: function() {
+ this.eventCellOnClick = this.eventCellOnClick.bindAsEventListener(this);
+ this.eventCellOnMouseOver = this.eventCellOnMouseOver.bindAsEventListener(this);
+ this.eventCellOnMouseOut = this.eventCellOnMouseOut.bindAsEventListener(this);
+ },
+
+ setCellEvents: function(obj) {
+ Event.observe(obj, "click", this.eventCellOnClick, false);
+ Event.observe(obj, "mouseover", this.eventCellOnMouseOver, false);
+ Event.observe(obj, "mouseout", this.eventCellOnMouseOut, false);
+ },
+ stopCellEvents: function(obj) {
+ Event.stopObserving(obj, "click", this.eventCellOnClick, false);
+ Event.stopObserving(obj, "mouseover", this.eventCellOnMouseOver, false);
+ Event.stopObserving(obj, "mouseout", this.eventCellOnMouseOut, false);
+ },
+
+ eventCellOnClick: function (e) {
+ var idstr = this.params.dayListTableId+'Cell';
+ var obj = Event.findElementByAttr(e, "TD", "id", idstr, true);
+ if (obj)
+ {
+ var daydata = this.days[parseInt(obj.id.substr(idstr.length))];
+ if (daydata._month==0)
+ {
+ this.selectedDate=new Date(this.currentDate);
+ this.selectedDate.setDate(obj.data);
+ if (this.selectedDateElement) Element.removeClassName(this.selectedDateElement,
"Selecteddayclass");
+ this.selectedDateElement = obj;
+ Element.addClassName(obj, "Selecteddayclass");
+
+ $(this.id+'InputSelectedDate').value=this.getSelectedDateString(this.params.datePattern);
+ this.renderFooter();
+ } else {
+ if (daydata._month==-1) this.prevMonth(); else this.nextMonth();
+ }
+ }
+ },
+
+ eventCellOnMouseOver: function (e) {
+ var idstr = this.params.dayListTableId+'Cell';
+ var obj = Event.findElementByAttr(e, "TD", "id", idstr, true);
+ if (obj)
+ {
+ var daydata = this.days[parseInt(obj.id.substr(idstr.length))];
+ if (daydata._month==0 && Element.hasClassName(obj,daydata._className))
Element.replaceClassName(obj,daydata._className, daydata._hoverClassName);
+ }
+ },
+
+ eventCellOnMouseOut: function (e) {
+ var idstr = this.params.dayListTableId+'Cell';
+ var obj = Event.findElementByAttr(e, "TD", "id", idstr, true);
+ if (obj)
+ {
+ var daydata = this.days[parseInt(obj.id.substr(idstr.length))];
+ if (daydata._month==0 && Element.hasClassName(obj,daydata._hoverClassName))
Element.replaceClassName(obj,daydata._hoverClassName, daydata._className);
+ }
+ },
+
+ load:function(daysData, isAjaxMode) {
+ // startDate,
+ // days:array[]
+ // {
+ // data
+ // enabled boolean or function
+ // isEnabled function
+ // text1: 'Meeting...',
+ // text2: 'Meeting...'
+ // tooltip
+ // hasTooltip
+ // dayStyleClass
+ // }
+
+ if (daysData) {
+ this.daysData = this.indexData(daysData, isAjaxMode);
+ } else {
+ this.daysData = null;
+ }
+
+ this.render();
+ },
+
+ indexData:function(daysData, isAjaxMode) {
+ var dateYear = daysData.startDate.getFullYear();
+ var dateMonth = daysData.startDate.getMonth();
+
+ daysData.index = [];
+ daysData.index[dateYear+'-'+dateMonth] = 0;
+ if (isAjaxMode)
+ {
+ this.currentDate = daysData.startDate;
+ this.currentDate.setDate(1);
+ return daysData;
+ }
+ var idx = daysInMonthByDate(daysData.startDate)-daysData.startDate.getDate()+1;
+
+ while (daysData.days[idx])
+ {
+ if (dateMonth==11) {dateYear++; dateMonth=0;} else dateMonth++;
+ daysData.index[dateYear+'-'+dateMonth] = idx;
+ idx+= (32 - new Date(dateYear, dateMonth, 32).getDate());
+ }
+ return daysData;
+ },
+
+ render:function() {
+ this.todayDate = new Date();
+
+ var currentYear = this.getCurrentYear();
+ var currentMonth = this.getCurrentMonth();
+
+ var todayflag = (currentYear == this.todayDate.getFullYear() && currentMonth ==
this.todayDate.getMonth());
+ var todaydate = this.todayDate.getDate();
+
+ var selectedflag = (currentYear == this.selectedDate.getFullYear() &&
currentMonth == this.selectedDate.getMonth())
+ var selecteddate = this.selectedDate.getDate();
+
+ var wd = getDay(this.currentDate, this.params.firstWeekDay);
+ var currentMonthDays = daysInMonthByDate(this.currentDate);
+ var previousMonthDays = daysInMonth(currentYear, currentMonth-1);
+
+ var p=0;
+ var month=-1;
+ this.days = [];
+ var dayCounter = previousMonthDays - wd + 1;
+
+ // previuos month days
+ if (wd>0) while (dayCounter<=previousMonthDays) {this.days.push({day:dayCounter,
_isWeekend: this.isWeekend(p), _month:month, _className:"Disableddayclass"});
dayCounter++; p++; }
+ dayCounter = 1;
+ month=0;
+
+ // current month days
+ if (this.daysData &&
this.daysData.index[currentYear+'-'+currentMonth]!=undefined)
+ {
+ var idx = this.daysData.index[currentYear+'-'+currentMonth];
+ var firstDay = this.daysData.days[idx].day;
+ while (dayCounter<firstDay)
+ {
+ if (this.isWeekend(p%7))
+ this.days.push({day:dayCounter, _isWeekend: true, _month:month,
_className:"Weekenddayclass", _hoverClassName:"Hoveredweekclass"});
+ else
+ this.days.push({day:dayCounter, _isWeekend: false, _month:month,
_className:"Commondayclass", _hoverClassName:"Hovereddayclass"});
+
+ dayCounter++;
+ p++;
+ }
+
+ var len = this.daysData.days.length;
+ var obj;
+ var flag;
+ while (idx<len && dayCounter<=currentMonthDays)
+ {
+ flag = this.isWeekend(p%7);
+ obj = this.daysData.days[idx];
+ obj.day = dayCounter;
+ obj._isWeekend = flag;
+ obj._month = month;
+ if (flag) {obj._className = "Weekenddayclass"; obj._hoverClassName =
"Hoveredweekclass";}
+ else {obj._className = "Commondayclass"; obj._hoverClassName =
"Hovereddayclass";}
+ this.days.push(obj);
+ idx++;
+ dayCounter++;
+ p++;
+ }
+ }
+ while (p<42)
+ {
+ if (dayCounter>currentMonthDays) {dayCounter=1; month=1;}
+ if (this.isWeekend(p%7))
+ this.days.push({day:dayCounter, _isWeekend: true, _month:month,
_className:"Weekenddayclass", _hoverClassName:"Hoveredweekclass"});
+ else
+ this.days.push({day:dayCounter, _isWeekend: false, _month:month,
_className:"Commondayclass", _hoverClassName:"Hovereddayclass"});
+ dayCounter++;
+ p++;
+ }
+
+ // render
+ this.renderHeader();
+ this.renderFooter();
+
+ //days render
+ p=0;
+ var element;
+ var dataobj;
+ var wn;
+ if (this.params.showWeeksBar) wn = weekNumber(currentYear, currentMonth,
this.params.minDaysInFirstWeek, this.params.firstWeekDay); /// fix it
+ this.selectedDayElement=null;
+ var weekflag=true;
+
+ var e;
+
+ //var _d=new Date();
+
+ for (var k=1;k<7;k++)
+ {
+ //
+ dataobj = this.days[p];
+
+ var obj = $(this.params.weekNumberBarId+k);
+ element = obj.firstChild;
+
+ // week number update
+ if (this.params.showWeeksBar)
+ {
+ if (weekflag && currentMonth==11 &&
+ (k==5||k==6) &&
+ (dataobj._month==1 ||
(currentMonthDays-dataobj.day+1)<this.params.minDaysInFirstWeek) )
+ {
+ wn=1;
+ weekflag=false;
+ }
+ element.innerHTML = this.params.weekNumberMarkup( {weekNumber: wn++,
componentId:this.getWeekNumberComponentId(k-1)} );
+ if (k==1&&wn>52) wn=1;
+ element = element.nextSibling;
+ }
+
+ while (element)
+ {
+ // TODO calendar_spec class not implemented
+ // TODO fix start/stop event's calls
+ this.stopCellEvents(element);
+
+ element.data=dataobj.day;
+ dataobj.componentId=this.getDateComponentId(p);
+ element.innerHTML = this.params.dayListMarkup( dataobj );
+
+ // class styles
+ e = Element.classNames(element);
+ // ?? dataobj._className
+ // TODO make some optimization with calendar_current class
+ if (todayflag && dataobj._month==0 && dataobj.day==todaydate)
e.add("calendar_current"); else e.remove("calendar_current");
+ if (selectedflag && dataobj._month==0 && dataobj.day==selecteddate)
{
+ this.selectedDateElement = element;
+ e.add("Selecteddayclass");
+ }
+
+ this.setCellEvents(element);
+ p++;
+
+ dataobj = this.days[p];
+ element=element.nextSibling;
+ }
+ }
+ //alert(new Date().getTime()-_d.getTime());
+ },
+ renderHeader: function()
+ {
+ var header = $(this.id+":header");
+ if (header)
+ {
+ header.innerHTML = Calendar.header.getContent(this.calendarContext);
+ }
+ },
+
+ renderFooter: function()
+ {
+ var footer = $(this.id+":footer");
+ if (footer)
+ {
+ footer.innerHTML = Calendar.footer.getContent(this.calendarContext);
+ }
+ },
+
+ onUpdate: function()
+ {
+ $(this.id+'InputCurrentDate').value=this.getCurrentDate().format("MM/y");
+
+ if (this.submitFunction)
+ this.submitFunction(this.getCurrentMonth() + '/' + this.getCurrentYear());
+ else
+ this.render();
+ },
+
+ nextMonth: function() {
+ this.currentDate = new Date(this.currentDate.getFullYear(),
this.currentDate.getMonth()+1,1);
+ this.onUpdate();
+ },
+
+ prevMonth: function() {
+ this.currentDate = new Date(this.currentDate.getFullYear(),
this.currentDate.getMonth()-1,1);
+ this.onUpdate();
+ },
+
+ nextYear: function() {
+ this.currentDate = new Date(this.currentDate.getFullYear() + 1,
this.currentDate.getMonth(),1);
+ this.onUpdate();
+ },
+
+ prevYear: function() {
+ this.currentDate = new Date(this.currentDate.getFullYear() - 1,
this.currentDate.getMonth(),1);
+ this.onUpdate();
+ },
+
+ today: function() {
+ var now = new Date();
+ var nowyear = now.getFullYear();
+ var nowmonth = now.getMonth();
+ var nowdate = now.getDate();
+ var updateflag = false;
+
+ if (nowdate!=this.todayDate.getDate()) {updateflag=true; this.todayDate = now;}
+
+ if (nowyear != this.currentDate.getFullYear() || nowmonth !=
this.currentDate.getMonth() )
+ {
+ updateflag = true;
+ this.currentDate = new Date(nowyear, nowmonth, 1);
+ }
+
+ if (updateflag) this.onUpdate();
+ },
+
+ help: function() {
+ alert("Calendar help");
+ }
+
+});
+
+Calendar.getDayView = function(context) {
+ return Richfaces.evalSimpleMacro("day", context);
+};
+
+Calendar.getWeekNumberView = function(context) {
+ return Richfaces.evalSimpleMacro("weekNumber", context);
+};
+
+Calendar.getWeekDayView = function(context) {
+ return Richfaces.evalSimpleMacro("weekDayLabel", context);
+};
+
+Calendar.getControl = function(context, attributes, text, functionName) {
+ var attr = {
+ onclick: (functionName ?
"Richfaces.invokeOnComponent('richfaces:calendar',this,'"+functionName+"');"
: "")+"return false;",
+ width: "100%"
+ };
+
+ if (attributes) {
+ Object.extend(attr, attributes);
+ }
+ return new E('div',attr,[new T(text)]);
+};
+
+Calendar.nextYearControl = function(context) {
+ //return Calendar.getControl(context, null, ">>
"+context.calendar.getNextYear(), "nextYear");
+ return Calendar.getControl(context, null, "��", "nextYear");
+};
+Calendar.previousYearControl = function(context) {
+ //return Calendar.getControl(context, null, context.calendar.getPrevYear()+"
<<", "prevYear");
+ return Calendar.getControl(context, null, "��", "prevYear");
+};
+Calendar.nextMonthControl = function(context) {
+ //return Calendar.getControl(context, null, ">
"+context.calendar.getNextMonth(true), "nextMonth");
+ return Calendar.getControl(context, null, "�", "nextMonth");
+};
+Calendar.previousMonthControl = function(context) {
+ //return Calendar.getControl(context, null, context.calendar.getPrevMonth(true)+"
<", "prevMonth");
+ return Calendar.getControl(context, null, "�", "prevMonth");
+};
+Calendar.currentMonthControl = function(context) {
+ var value =context.calendar.getCurrentDate().format("MMMM, y",
context.monthLabels, context.monthLabelsShort);
+ return value;
+};
+Calendar.todayControl = function(context) {
+ return Calendar.getControl(context, null, "Today", "today");
+};
+Calendar.selectedDateControl = function(context) {
+ var value = Calendar.getControl(context, null,
context.calendar.getSelectedDateString(context.calendar.params.datePattern),
"prevMonth");
+ return value;
+};
+Calendar.helpControl = function(context)
+{
+ return Calendar.getControl(context, null, "Help", "help");
+};
+
+
+Calendar.header =
+ new E('table',{'border': '0', 'cellpadding':
'0', 'cellspacing': '0', 'width': '100%'},
+ [
+ new E('tbody',{},
+ [
+ new E('tr',{},
+ [
+ new E('td',{'class': 'calendar_tool calendar_btn'},
+ [
+ new ET(function (context) { return
Richfaces.evalMacro("previousYearControl", context)})
+ ]),
+ new E('td',{'class': 'calendar_tool calendar_btn'},
+ [
+ new ET(function (context) { return
Richfaces.evalMacro("previousMonthControl", context)})
+ ]),
+ new E('td',{'class': 'calendar_month'},
+ [
+ new ET(function (context) { return
Richfaces.evalMacro("currentMonthControl", context)})
+ ]),
+ new E('td',{'class': 'calendar_tool calendar_btn'},
+ [
+ new ET(function (context) { return
Richfaces.evalMacro("nextMonthControl", context)})
+ ]),
+ new E('td',{'class': 'calendar_tool calendar_btn'},
+ [
+ new ET(function (context) { return Richfaces.evalMacro("nextYearControl",
context)})
+ ])
+ ])
+ ])
+ ]
+ );
+
+Calendar.footer =
+ new E('table',{'border': '0', 'cellpadding':
'0', 'cellspacing': '0', 'width': '100%'},
+ [
+ new E('tbody',{},
+ [
+ new E('tr',{},
+ [
+ new E('td',{'class': 'calendar_toolfooter', 'style':
'white-space:nowrap'},
+ [
+ new ET(function (context) { return
Richfaces.evalMacro("Calendar.selectedDateControl", context)})
+ ]),
+ new E('td',{'class': 'calendar_toolfooter calendar_btn',
'width': '100%'},
+ [
+ new ET(function (context) { return
Richfaces.evalMacro("Calendar.helpControl", context)})
+ ]),
+ new E('td',{'class': 'calendar_toolfooter calendar_btn',
'align': 'right'},
+ [
+ new ET(function (context) { return
Richfaces.evalMacro("Calendar.todayControl", context)})
+ ])
+ ])
+ ])
+ ]
+ );
+
+
+CalendarContext = Class.create();
+Object.extend(CalendarContext.prototype, {
+ initialize: function(calendar) {
+ this.calendar=calendar;
+ this.monthLabels=calendar.params.monthLabels;
+ this.monthLabelsShort=calendar.params.monthLabelsShort;
+ },
+
+ nextYearControl: Calendar.nextYearControl,
+ previousYearControl: Calendar.previousYearControl,
+ nextMonthControl: Calendar.nextMonthControl,
+ previousMonthControl: Calendar.previousMonthControl,
+ currentMonthControl: Calendar.currentMonthControl,
+ todayControl: Calendar.todayControl,
+ selectedDateControl: Calendar.selectedDateControl,
+ helpControl: Calendar.helpControl,
+});
\ No newline at end of file
Modified: trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
---
trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-07-19
18:53:25 UTC (rev 1706)
+++
trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-07-19
19:23:27 UTC (rev 1707)
@@ -1,21 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
-<f:root
-
xmlns:f="http://ajax4jsf.org/cdk/template"
- xmlns:c="
http://java.sun.com/jsf/core"
+<f:root
xmlns:f="http://ajax4jsf.org/cdk/template"
+ xmlns:c="
http://java.sun.com/jsf/core"
xmlns:ui="
http://ajax4jsf.org/cdk/ui"
xmlns:u="
http://ajax4jsf.org/cdk/u"
xmlns:x="
http://ajax4jsf.org/cdk/x"
xmlns:vcp="
http://ajax4jsf.org/cdk/vcp"
class="org.richfaces.renderkit.html.CalendarRenderer"
baseclass="org.richfaces.renderkit.CalendarRendererBase"
- component="org.richfaces.component.UICalendar"
- >
- <f:clientid var="clientId"/>
- <h:scripts>new org.ajax4jsf.javascript.PrototypeScript(),new
org.ajax4jsf.javascript.AjaxScript(),/org/richfaces/renderkit/html/scripts/utils.js,/org/richfaces/renderkit/html/scripts/json/json-dom.js</h:scripts>
+ component="org.richfaces.component.UICalendar">
+ <f:clientid var="clientId" />
+ <h:scripts>new org.ajax4jsf.framework.resource.PrototypeScript(),new
org.ajax4jsf.framework.ajax.AjaxScript(),/org/richfaces/renderkit/html/scripts/utils.js,/org/richfaces/renderkit/html/scripts/json/json-dom.js,/org/richfaces/renderkit/html/scripts/calendar.js</h:scripts>
+ <h:styles>/org/richfaces/renderkit/html/css/calendar.xcss</h:styles>
+
<div id="#{clientId}"
- x:passThruWithExclusions="value,name,type,id"
- >
-
- <vcp:body />
+ style="display:inline; width:
#{this:qualifySize(component.attributes['width'])}; height:
#{this:qualifySize(component.attributes['height'])};
#{component.attributes['style']}"
+ class="#{component.attributes['styleClass']}"
+ x:passThruWithExclusions="value,name,type,id"><script
+ type="text/javascript">
+ new Calendar('#{clientId}', {
+ submitFunction:
+ <jsp:scriptlet>/*<![CDATA[*/
+ writeSubmitFunction(context, component);
+ /*]]>*/</jsp:scriptlet>,
+ dayListTableId: '#{clientId}Day',
+ weekNumberBarId: '#{clientId}WeekNum',
+ weekDayBarId: '#{clientId}WeekDay',
+ currentDate: new Date(2007,6,1),
+ selectedDate: new Date(2007,4,5),
+ weekDayLabels:
['Sun','Mon','Tue','Wen','Thu','Fri','Sat'],
+ monthLabels: ['January', 'February', 'March',
'April', 'May', 'June', 'July', 'August',
'September', 'October', 'November', 'December'],
+ monthLabelsShort: ['Jan', 'Feb', 'Mar', 'Apr',
'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
'Nov', 'Dec'],
+ firstWeekDay: 0,
+ minDaysInFirstWeek: 4,
+ headerHtml: '<b>User defined header</b>',
+ footerHtml: 'User defined footer',
+ dayListMarkup:
+ <jsp:scriptlet>/*<![CDATA[*/
+ if (component.getChildCount() != 0) {
+ writeMarkupScriptBody(context, component, true);
+ } else {
+ /*]]>*/</jsp:scriptlet>
+ Calendar.getDayView
+ <jsp:scriptlet>/*<![CDATA[*/
+ }
+ /*]]>*/</jsp:scriptlet>
+ ,
+
+ weekDayMarkup: <jsp:scriptlet>/*<![CDATA[*/
+ UIComponent weekDayFacet = component.getFacet("weekDay");
+ if (weekDayFacet != null && weekDayFacet.isRendered()) {
+ writeMarkupScriptBody(context, weekDayFacet, false);
+ } else {
+ /*]]>*/</jsp:scriptlet>
+ Calendar.getWeekDayView
+ <jsp:scriptlet>/*<![CDATA[*/
+ }
+ /*]]>*/</jsp:scriptlet>
+ ,
+
+ weekNumberMarkup: <jsp:scriptlet>/*<![CDATA[*/
+ UIComponent weekNumberFacet = component.getFacet("weekNumber");
+ if (weekNumberFacet != null && weekNumberFacet.isRendered()) {
+ writeMarkupScriptBody(context, weekNumberFacet, false);
+ } else {
+ /*]]>*/</jsp:scriptlet>
+ Calendar.getWeekNumberView
+ <jsp:scriptlet>/*<![CDATA[*/
+ }
+ /*]]>*/</jsp:scriptlet>
+ }).load(
+ <jsp:scriptlet>/*<![CDATA[*/
+ writePreloadBody(context, component);
+ /*]]>*/</jsp:scriptlet>
+ );
+ </script> <jsp:scriptlet>
+ <![CDATA[
+ boolean popup = attributeToBoolean(component, "popup");
+ if (popup) {]]>
+ </jsp:scriptlet>
+ <span> <input
+ x:passThruWithExclusions="name,id"
+ value="#{this:getInputValue(context,component)}"
+ type="text"
+ readonly="#{component.attributes['readonly']}"
+ disabled="#{component.attributes['disabled']}"
+ accesskey="#{component.attributes['accesskey']}"
+ maxlength="#{component.attributes['maxlength']}"
+ onchange="#{component.attributes['onchange']}"
+ onselect="#{component.attributes['onselect']}"
+ onfocus="#{component.attributes['onfocus']}"
+ onblur="#{component.attributes['onblur']}"
+ size="#{component.attributes['inputSize']}"
+ style="#{component.attributes['style']}"
+ tabindex="#{component.attributes['tabindex']}"
+ class="#{component.attributes['class']}"
+ onclick="#{component.attributes['onclick']}">
+ </input>
+ <button id="#{clientId}Button"
+ accesskey="#{component.attributes['accesskey']}"
+ class="#{component.attributes['class']}"
+ name="#{clientId}"
+ onclick="#{component.attributes['onclick']}"
+ value="#{component.attributes['value']"
+ style="#{component.attributes['style']}"
+ tabindex="#{component.attributes['tabindex']}"
+ type="button">
+ </button>
+ </span>
+ <jsp:scriptlet>
+ <![CDATA[
+ }
+ ]]>
+ </jsp:scriptlet>
</div>
-</f:root>
\ No newline at end of file
+</f:root>
Modified:
trunk/sandbox/ui/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java
===================================================================
---
trunk/sandbox/ui/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java 2007-07-19
18:53:25 UTC (rev 1706)
+++
trunk/sandbox/ui/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java 2007-07-19
19:23:27 UTC (rev 1707)
@@ -3,10 +3,14 @@
*/
package org.richfaces.component;
+import java.util.Calendar;
+import java.util.Date;
import java.util.List;
+import java.util.Locale;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlForm;
import javax.faces.component.html.HtmlOutputText;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
@@ -19,12 +23,35 @@
*
*/
public class CalendarComponentTest extends AbstractAjax4JsfTestCase {
+
+
+ private UIComponent form;
+ private UICalendar calendar;
+
public CalendarComponentTest(String name) {
super(name);
}
-
- public void testTidy() throws Exception {
+
+ public void setUp()throws Exception{
+
+ super.setUp();
+
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ calendar = (UICalendar) application.createComponent(UICalendar.COMPONENT_TYPE);
+ calendar.setLocale(Locale.CHINESE);
+ Calendar calendarObject = Calendar.getInstance();
+ calendarObject.set(2001, Calendar.SEPTEMBER, 11);
+ calendar.setId("calendar");
+
+ form.getChildren().add(calendar);
+
+ }
+
+/* public void testTidy() throws Exception {
UIViewRoot viewRoot = facesContext.getViewRoot();
List children = viewRoot.getChildren();
UIComponent calendar = application.createComponent(UICalendar.COMPONENT_TYPE);
@@ -37,4 +64,71 @@
HtmlPage renderView = renderView();
System.out.println(renderView.asXml());
}
+*/
+ public void testPreloadRanges() throws Exception {
+ UICalendar calendar = (UICalendar)
application.createComponent(UICalendar.COMPONENT_TYPE);
+ calendar.setLocale(Locale.FRENCH);
+ Calendar calendarObject = Calendar.getInstance();
+ calendarObject.set(2007, Calendar.JUNE, 10);
+
+ Calendar preloadRangeBegin = Calendar.getInstance();
+ preloadRangeBegin.setTime(calendar.getDefaultPreloadBegin(calendarObject.getTime()));
+ assertEquals(2007, preloadRangeBegin.get(Calendar.YEAR));
+ assertEquals(Calendar.MAY, preloadRangeBegin.get(Calendar.MONTH));
+ assertEquals(28, preloadRangeBegin.get(Calendar.DATE));
+
+ Calendar preloadRangeEnd = Calendar.getInstance();
+ preloadRangeEnd.setTime(calendar.getDefaultPreloadEnd(calendarObject.getTime()));
+ assertEquals(2007, preloadRangeEnd.get(Calendar.YEAR));
+ assertEquals(Calendar.JULY, preloadRangeEnd.get(Calendar.MONTH));
+ assertEquals(1, preloadRangeEnd.get(Calendar.DATE));
+
+ calendarObject.set(2007, Calendar.JANUARY, 1);
+ preloadRangeBegin.setTime(calendar.getDefaultPreloadBegin(calendarObject.getTime()));
+ assertEquals(2007, preloadRangeBegin.get(Calendar.YEAR));
+ assertEquals(Calendar.JANUARY, preloadRangeBegin.get(Calendar.MONTH));
+ assertEquals(1, preloadRangeBegin.get(Calendar.DATE));
+
+
+ calendarObject.set(2007, Calendar.JUNE, 10);
+ calendar.setLocale(Locale.US);
+
+ preloadRangeBegin.setTime(calendar.getDefaultPreloadBegin(calendarObject.getTime()));
+ assertEquals(2007, preloadRangeBegin.get(Calendar.YEAR));
+ assertEquals(Calendar.MAY, preloadRangeBegin.get(Calendar.MONTH));
+ assertEquals(27, preloadRangeBegin.get(Calendar.DATE));
+
+ preloadRangeEnd.setTime(calendar.getDefaultPreloadEnd(calendarObject.getTime()));
+ assertEquals(2007, preloadRangeEnd.get(Calendar.YEAR));
+ assertEquals(Calendar.JUNE, preloadRangeEnd.get(Calendar.MONTH));
+ assertEquals(30, preloadRangeEnd.get(Calendar.DATE));
+ }
+
+ public void testGetPreloadDateRange() throws Exception {
+ UICalendar calendar = (UICalendar)
application.createComponent(UICalendar.COMPONENT_TYPE);
+ calendar.setLocale(Locale.FRENCH);
+ Calendar calendarObject = Calendar.getInstance();
+ calendarObject.set(2007, Calendar.JUNE, 10);
+ calendar.setCurrentDate(calendarObject.getTime());
+
+ Date[] range = calendar.getPreloadDateRange();
+ assertEquals(calendar.getPreloadDateRangeBegin(), range[0]);
+ assertEquals(calendar.getPreloadDateRangeEnd(), range[range.length - 1]);
+ assertEquals(35, range.length);
+ }
+
+ public void testCalendarRenderer()throws Exception{
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ System.out.println(page.asXml());
+
+
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ form = null;
+ calendar = null;
+ }
}
Property changes on: trunk/sandbox/ui/message
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
.settings
target
Modified:
trunk/sandbox/ui/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js 2007-07-19
18:53:25 UTC (rev 1706)
+++
trunk/sandbox/ui/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js 2007-07-19
19:23:27 UTC (rev 1707)
@@ -44,6 +44,7 @@
*/
initialize: function(template, grid) {
this.grid = grid;
+ this.gridId = grid.getElement().id;
ClientUI.controls.grid.GridBody.parentClass.constructor().call(this, template);
// declare event listeners
@@ -86,7 +87,7 @@
var childs = template.childNodes;
for(var i=0; i<childs.length; i++) {
- if(childs[i].tagName && childs[i].tagName.toLowerCase() == "div") {
+ if(childs[i].id == this.gridId + ":bc") {
this.container = new ClientUI.common.box.Box(childs[i], null, true);
this.container.makeAbsolute();
this.container.setStyle({'z-index' : 20});
@@ -96,13 +97,10 @@
}
// create scroll box
- this.scrollBox = new ClientUI.common.box.ScrollableBox(null, this.getElement());
- this.scrollBox.makeAbsolute();
+ this.scrollBox = new ClientUI.common.box.ScrollableBox(this.gridId + ":scb",
this.getElement());
this.scrollBox.setWidth(this.getWidth());
this.scrollBox.setHeight(this.getHeight());
- this.scrollBox.setStyle({'z-index' : 0});
- this.sizeBox = new ClientUI.common.box.Box(null, this.scrollBox.getElement());
- this.sizeBox.makeAbsolute();
+ this.sizeBox = new ClientUI.common.box.Box(this.gridId + ":sb",
this.scrollBox.getElement());
var normal = null, frozen = null;
var childs = this.container.getElement().childNodes;
@@ -126,14 +124,8 @@
this.frozenContentBox = new ClientUI.common.box.Box(frozen);
this.frozenContentBox.makeAbsolute();
- this.helpObject1 = new
ClientUI.common.box.Box($(document.createElement("span")),
this.contentBox.getElement());
- this.helpObject1.setWidth(10);
- this.helpObject1.setHeight(10);
- this.helpObject1.makeAbsolute();
- this.helpObject2 = new
ClientUI.common.box.Box($(document.createElement("span")),
this.frozenContentBox.getElement());
- this.helpObject2.setWidth(10);
- this.helpObject2.setHeight(10);
- this.helpObject2.makeAbsolute();
+ this.helpObject1 = new ClientUI.common.box.Box(this.gridId + ":nho",
this.contentBox.getElement());
+ this.helpObject2 = new ClientUI.common.box.Box(this.gridId + ":fho",
this.frozenContentBox.getElement());
// create row template
var ch = this.frozenContentBox.getElement().firstChild;
@@ -191,9 +183,9 @@
this.rowsCount = Math.min(templNormal.rows.length, this.grid.dataModel.getCount());
var cell = templNormal.rows[0].cells[0];
this.defaultRowHeight = cell!=null ? Element.getHeight(cell) : 0;
- if(ClientUILib.isGecko) {
- this.defaultRowHeight -= this.getBorderWidth("tb") +
this.getPadding("tb");
- }
+ //if(ClientUILib.isGecko) {
+ // this.defaultRowHeight -= this.getBorderWidth("tb") +
this.getPadding("tb");
+ //}
this.helpObj = new ClientUI.common.box.Box(templFrozen, null, true);
this.countToLoad = 0;
this.startRow = 0;
@@ -212,9 +204,9 @@
},
updateSize: function() {
this.defaultRowHeight =
Element.getHeight(this.templNormal.getElement().rows[0].cells[0]);
- if(ClientUILib.isGecko) {
- this.defaultRowHeight -= this.getBorderWidth("tb") +
this.getPadding("tb");
- }
+ //if(ClientUILib.isGecko) {
+ // this.defaultRowHeight -= this.getBorderWidth("tb") +
this.getPadding("tb");
+ //}
},
updateLayout: function() {
if(!this.controlCreated || !this.grid.controlCreated) {
@@ -620,7 +612,7 @@
setTimeout(function () {
this.rearrangeRows(options, true, true);
this.container.show();
- this.splash.hide();
+ if(this.splash) this.splash.hide();
this.updateStarted = false;
}.bind(this), 10);
Modified:
trunk/sandbox/ui/scrollable-grid/src/main/resources/org/richfaces/renderkit/html/css/grid.xcss
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/resources/org/richfaces/renderkit/html/css/grid.xcss 2007-07-19
18:53:25 UTC (rev 1706)
+++
trunk/sandbox/ui/scrollable-grid/src/main/resources/org/richfaces/renderkit/html/css/grid.xcss 2007-07-19
19:23:27 UTC (rev 1707)
@@ -64,7 +64,6 @@
*/
.ClientUI_Grid_HR {
background-color: #ebeadb;
- height: 22px;
z-index:2;
}
@@ -85,7 +84,6 @@
white-space: nowrap;
border-bottom: 1px solid #cbc7b8;
border-right: 1px solid #ebeadb;
- height:30px !important;
}
.ClientUI_Grid_HC .sort-asc {
@@ -93,9 +91,8 @@
background-position: right;
background-repeat: no-repeat;
display: none;
- height: 14px;
- width: 16px;
- position: relative;
+ width: 16px !important;;
+ position: absolute;
}
.ClientUI_Grid_HC .sort-desc {
@@ -103,9 +100,8 @@
background-position: right;
background-repeat: no-repeat;
display: none;
- height: 14px;
- width: 16px;
- position: relative;
+ width: 16px !important;;
+ position: absolute;
}
/**
@@ -129,15 +125,14 @@
.ClientUI_Grid_HSplit {
width:1px;
border-right:1px dashed #6593cf;
- background:none;
cursor: col-resize;
- z-index: 70;
+ z-index: 100;
}
/**
* Header cell body
*/
-.ClientUI_Grid_HCBody1 {
+.ClientUI_Grid_HCBody {
cursor: default;
padding: 0px 0px;
white-space: nowrap;
@@ -145,24 +140,8 @@
display: block;
overflow: hidden;
width: 100%;
-}
-.ClientUI_Grid_HCBody {
- cursor: default;
font: normal 8pt arial;
- padding: 3px 5px;
- white-space: nowrap;
- position: relative;
- display: block;
- overflow: hidden;
}
-.ClientUI_Grid_HCBody span {
- font: normal 8pt arial;
- white-space: nowrap;
-}
-.ClientUI_Grid_HCBodyContent {
- font: normal 8pt arial;
- white-space: nowrap;
-}
.ClientUI_Grid_HC_Over{
border-bottom: 1px solid #fcc247;
@@ -277,12 +256,17 @@
/**
* Body row style
*/
+.ClientUI_Grid_HO {
+ position: absolute;
+ height: 10px;
+ width: 10px;
+}
+
.ClientUI_Grid_BR {
font: normal 8pt arial;
white-space: nowrap;
box-sizing: border-box;
-moz-box-sizing: border-box;
- height:21px !important;
}
.idg-row-selected-h {
@@ -308,23 +292,30 @@
.ClientUI_Grid_BCBody {
cursor: default;
font: normal 8pt arial;
- padding: 3px 5px;
- white-space: nowrap;
-}
-.ClientUI_Grid_BCBody1 {
- cursor: default;
- font: normal 8pt arial;
+ white-space: nowrap;
padding: 0px 0px;
- white-space: nowrap;
position: relative;
display: block;
- overflow: hidden;
+ overflow: hidden;
+ -o-text-overflow: ellipsis;
+ text-overflow: ellipsis;
+ -moz-box-sizing: border-box;
+ -moz-outline: none;
width: 100%;
+ height: 20px;
}
/**
* Helper classes for grid template
*/
+.ClientUI_Substrate {
+ filter:Alpha(opacity=0);
+ position:absolute;
+ top:0px;
+ left:0px;
+ display:block;
+}
+
.ClientUI_TmplBox {
display: block;
float:left;
Modified: trunk/sandbox/ui/tooltip/src/main/config/component/toolTip.xml
===================================================================
--- trunk/sandbox/ui/tooltip/src/main/config/component/toolTip.xml 2007-07-19 18:53:25 UTC
(rev 1706)
+++ trunk/sandbox/ui/tooltip/src/main/config/component/toolTip.xml 2007-07-19 19:23:27 UTC
(rev 1707)
@@ -1,25 +1,39 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN"
"https://ajax4jsf.dev.java.net/nonav/dtds/component-config.dtd" >
+<!--
+<!DOCTYPE components PUBLIC "-//EXADEL//Generator config/EN"
"http://exadel.com/dtds/component-config.dtd" >
+ -->
+
+
+
<components>
<component>
<name>org.richfaces.component.ToolTip</name>
<family>org.richfaces.component.ToolTip</family>
- <description>Defines the menu on the page and the set of the child elements
properties in layout.</description>
+ <classname>org.richfaces.component.html.HtmlToolTip</classname>
<superclass>org.richfaces.component.UIToolTip</superclass>
- <classname>org.richfaces.component.html.HtmlToolTip</classname>
+ <description><![CDATA[Defines tooltip for parent
component.]]></description>
+ <test>
+ <classname>org.richfaces.component.html.HtmlToolTipTest</classname>
+ <superclassname>org.ajax4jsf.tests.AbstractAjax4JsfTestCase</superclassname>
+ </test>
+
<renderer generate="true" override="true">
<name>org.richfaces.renderkit.html.ToolTipRenderer</name>
<template>org/richfaces/htmltooltip.jspx</template>
</renderer>
<tag>
<name>toolTip</name>
- <classname>org.richfaces.taglib.ToolTipTag</classname>
- <superclass>org.ajax4jsf.webapp.taglib.HtmlComponentTagBase</superclass>
+ <classname>org.richfaces.taglib.HtmlToolTipTag</classname>
+ <superclass>org.ajax4jsf.framework.taglib.HtmlComponentTagBase</superclass>
+ <test>
+ <classname>org.richfaces.taglib.HtmlToolTipTagTest</classname>
+ <superclassname>org.ajax4jsf.tests.AbstractAjax4JsfTestCase</superclassname>
+ </test>
</tag>
-
<property>
- <name>onactivate</name>
+ <name>oncomplete</name>
<classname>java.lang.String</classname>
<description></description>
<defaultvalue><![CDATA[""]]></defaultvalue>
@@ -31,7 +45,7 @@
<defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
- <name>ondeactivate</name>
+ <name>onhide</name>
<classname>java.lang.String</classname>
<description></description>
<defaultvalue><![CDATA[""]]></defaultvalue>
@@ -49,7 +63,7 @@
<name>event</name>
<classname>java.lang.String</classname>
<description>event that triggers the tooltip appearance (default =
onmouseover)</description>
- <defaultvalue><![CDATA["onmouseover"]]></defaultvalue>
+ <defaultvalue><![CDATA["mouseover"]]></defaultvalue>
</property>
<property>
<name>mode</name>
@@ -58,7 +72,7 @@
<defaultvalue><![CDATA["client"]]></defaultvalue>
</property>
<property>
- <name>disabled</name>
+ <name>disabled</name>
<classname>boolean</classname>
<description>If false the components is rendered on the client but Js for
calling – disabled.</description>
<defaultvalue>false</defaultvalue>
Modified:
trunk/sandbox/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java
===================================================================
---
trunk/sandbox/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java 2007-07-19
18:53:25 UTC (rev 1706)
+++
trunk/sandbox/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java 2007-07-19
19:23:27 UTC (rev 1707)
@@ -1,18 +1,20 @@
package org.richfaces.renderkit.html;
import java.io.IOException;
+import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
-import org.richfaces.skin.Skin;
+import org.ajax4jsf.framework.ajax.AjaxEvent;
+import org.ajax4jsf.framework.renderer.AjaxComponentRendererBase;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.skin.Skin;
+import org.ajax4jsf.framework.util.javascript.JSFunction;
+import org.ajax4jsf.framework.util.javascript.JSFunctionDefinition;
+import org.ajax4jsf.framework.util.javascript.JSReference;
import org.richfaces.component.UIToolTip;
-import org.richfaces.renderkit.html.image.cornerimages.BottomLeftToolTipCornerImage;
-import org.richfaces.renderkit.html.image.cornerimages.BottomRightToolTipCornerImage;
-import org.richfaces.renderkit.html.image.cornerimages.TopLeftToolTipCornerImage;
-import org.richfaces.renderkit.html.image.cornerimages.TopRightToolTipCornerImage;
public class ToolTipRenderer extends AjaxComponentRendererBase{
@@ -21,66 +23,6 @@
return org.richfaces.component.UIToolTip.class;
}
- public void encodeChildren(FacesContext context, UIComponent component)
- throws IOException {
- // TODO Auto-generated method stub
- super.encodeChildren(context, component);
- }
-
- /**
- *
- * @param context
- * @param component 'tl'-top left, 'tr'-top right, 'bl'-bottom
left, 'br'-bottom right
- * @param position
- * @throws IOException
- */
- public void insertImage(FacesContext context, UIComponent component, Object position)
throws IOException{
- //if(position == null) throw new IllegalArgumentException("Parameter passed is
invalid, use \"0 - 3\"");
- String posStr = (String)position;
- drawImageElement(context, component, posStr);
- }
-
-
- /**
- *
- * @param writer
- * @param component
- * @param position 0-tl, 1-tr, 2-bl, 3-br
- * @throws IOException
- */
- private void drawImageElement(FacesContext context, UIComponent component, String
position) throws IOException{
- String imageSrc = getImageSrc(context, component, position);
- ResponseWriter writer = context.getResponseWriter();
- int h = 15; //width(context);
- writer.startElement("img", component);
- writer.writeAttribute("src", imageSrc, null);
- writer.writeAttribute("alt", "", null);
- writer.writeAttribute("vspace", "0", null);
- writer.writeAttribute("hspace", "0", null);
- writer.writeAttribute("class", "corner", null);
- writer.writeAttribute("style", "display:block; ", null);
- writer.writeAttribute("width", String.valueOf(h), null);
- writer.writeAttribute("height", String.valueOf(h), null);
- writer.endElement("img");
- }
-
-
- protected String getImageSrc(FacesContext context, UIComponent component, String
position){
- String color = getBgColor(context, component);
- String imageSource = null;
- if(position == null || position.equals("tl")) {
- imageSource = getResource(TopLeftToolTipCornerImage.class.getName()).getUri(context,
color);
- } else if(position.equals("tr")){
- imageSource = getResource(TopRightToolTipCornerImage.class.getName()).getUri(context,
color);
- } else if (position.equals("bl")){
- imageSource =
getResource(BottomLeftToolTipCornerImage.class.getName()).getUri(context, color);
- } else if (position.equals("br")){
- imageSource =
getResource(BottomRightToolTipCornerImage.class.getName()).getUri(context, color);
- }
-
- return imageSource;
- }
-
public String getBgColor(FacesContext context, UIComponent component){
Skin skin = getSkin(context);
String color = (String) skin.getParameter(context,"headerBackgroundColor");
@@ -100,29 +42,42 @@
context.getResponseWriter().write(value.toString());
}
}
-
- protected String getTopRightDivStyle(FacesContext context, UIComponent component){
- String trImgSrc = getImageSrc(context, component, "tr");
- return "background: url(" + trImgSrc + ") no-repeat top
right;";
- }
- protected String getBottomRightDivStyle(FacesContext context, UIComponent component){
- String brImgSrc = getImageSrc(context, component, "br");
- return "background: url(" + brImgSrc + ") no-repeat top
right;";
- }
-
- protected String getMainDivStyle(FacesContext context, UIComponent component){
- String style = "width: 250px;background-color:" + getBgColor(context,
component) + ";color: " + getColor(context, component) + ";";
- return style;
- }
- protected String getTRImageSrc(FacesContext context, UIComponent component){
- return getImageSrc(context, component, "tr");
+ public String insertAjaxFunction(FacesContext context, UIComponent component){
+ JSFunction function = AjaxRendererUtils.buildAjaxFunction(component, context);
+ component.getClientId(context);
+
+ Map eventOptions = AjaxRendererUtils.buildEventOptions(context, component);
+
+ //after element is subsituted in DOM tree, we have to re-create
+ //it's JS-reference, cause old one is already invalid
+ String refreshTooltipInDOM = ";" + getJsVarName(context, component) +
".toolTip = $('" + component.getClientId(context) + "');" +
+ ";" + getJsVarName(context, component) + ".toolTipContent =
$('" + component.getClientId(context) + "content');";
+
+ String showNewToolTip = ";" + getJsVarName(context, component) +
".displayDiv();";
+
+ //enable ajaxSingle mode, i.e. we do not need to submit all form controls to get
tooltip content
+ eventOptions.put("control", JSReference.THIS);
+
+ if(eventOptions.containsKey("oncomplete")){
+ JSFunctionDefinition onComplete =
(JSFunctionDefinition)eventOptions.get("oncomplete");
+ onComplete.addToBody(refreshTooltipInDOM + showNewToolTip);
+ eventOptions.put("oncomplete", onComplete);
+ } else {
+ JSFunctionDefinition onComplete = new JSFunctionDefinition();
+ onComplete.addParameter("request");
+ onComplete.addParameter("event");
+ onComplete.addParameter("data");
+ onComplete.addToBody(refreshTooltipInDOM + showNewToolTip);
+ eventOptions.put("oncomplete", onComplete);
+ }
+
+ function.addParameter(eventOptions);
+
+ return function.toScript();
}
- protected String getBRImageSrc(FacesContext context, UIComponent component){
- return getImageSrc(context, component, "br");
- }
public void insertScript(FacesContext context, UIComponent component) throws
IOException{
@@ -136,27 +91,62 @@
String quot = "\"";
StringBuffer script = new StringBuffer();
//
- script.append("var tooltip1 = ").
+ String event = toolTip.getEvent();
+ if(event.startsWith("on")){
+ event = event.substring(2);
+ }
+ String events = "{event:\"" + event + "\",onshow:\""
+ toolTip.getOnshow() +
+ "\",oncomplete:\"" + toolTip.getOncomplete() +
"\",onhide:\"" + toolTip.getOnhide() +
+ "\"}";
+ //script.append("var tooltip1 = ").
- append("new ToolTip(").append(quot).append("tooltip" +
toolTip.getClientId(context).toString()).append(quot).append(comma).
+ script.append(getJsVarName(context, toolTip) + " = ").
+ append("new ToolTip(" + events).append(comma).append(quot).append(
toolTip.getClientId(context)).append(quot).append(comma).
append(quot).append(parentClientId).append(quot).append(comma).
append(quot).append(toolTip.getMode()).append(quot).append(comma).
append(toolTip.isDisabled()).append(comma).
append(quot).append(toolTip.getDirection()).append(quot).append(comma).
append(toolTip.isFollowMouse()).append(comma).
append(toolTip.getHorizontalOffset()).append(comma).
- append(toolTip.getVerticalOffset()).append(");\n");
+ append(toolTip.getVerticalOffset()).append(comma).
+ append("\"").append(insertAjaxFunction(context,
component)).append("\");\n");
ret.append(script.toString());
//
//ret.append("function toolTipAttach(){tooltip1.attachParentEvents() }\n");
ret.append("\n</script>");
-
ResponseWriter writer = context.getResponseWriter();
writer.write(ret.toString());
}
+
+ private String getJsVarName(FacesContext context, UIComponent component){
+ return "window.tooltip" +
component.getClientId(context).replaceAll("[^A-Za-z0-9_]", "_");
+ }
+
+ protected void doDecode(FacesContext context, UIComponent component) {
+
+ UIToolTip tooltip = (UIToolTip)component;
+
+ String clientId = tooltip.getClientId(context);
+
+ if(context.getExternalContext().getRequestParameterMap().containsKey(clientId)){
+ if("ajax".equals(tooltip.getMode())){
+ new AjaxEvent(component).queue();
+ }
+ }
+ }
+
+ public void encodeTooltipText(FacesContext context, UIToolTip component) throws
IOException {
+ ResponseWriter responseWriter = context.getResponseWriter();
+ responseWriter.startElement("span", component);
+ responseWriter.writeAttribute("id", component.getClientId(context) +
"content", null);
+ responseWriter.write(component.getValue() != null ? component.getValue() :
"");
+ super.renderChildren(context, component);
+ responseWriter.endElement("span");
+ }
+
}
Modified:
trunk/sandbox/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/css/tooltip.xcss
===================================================================
---
trunk/sandbox/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/css/tooltip.xcss 2007-07-19
18:53:25 UTC (rev 1706)
+++
trunk/sandbox/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/css/tooltip.xcss 2007-07-19
19:23:27 UTC (rev 1707)
@@ -4,13 +4,16 @@
xmlns:u="http://jsf.exadel.com/template/util"
xmlns="http://www.w3.org/1999/xhtml">
-<f:verbatim>
-img.corner {
- width: 15px;
- height: 15px;
- border: none;
- display: block !important;
-}
-</f:verbatim>
+ <u:selector name=".dr-rich-tool-tip">
+ <u:style name="background-color" skin="tipBackgroundColor"/>
+ <u:style name="padding" value="7px"/>
+ <u:style name="border" value="1px solid"/>
+ <u:style name="border-color" skin="tipBorderColor"/>
+ <u:style name="font-size" skin="generalSizeFont"/>
+ <u:style name="font-family" skin="generalFamilyFont"/>
+ <u:style name="color" skin="generalFontColor"/>
+ <u:style name="float" value="left"/>
+ </u:selector>
+
</f:template>
Modified:
trunk/sandbox/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js
===================================================================
---
trunk/sandbox/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js 2007-07-19
18:53:25 UTC (rev 1706)
+++
trunk/sandbox/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js 2007-07-19
19:23:27 UTC (rev 1707)
@@ -2,39 +2,15 @@
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false;
-// If NS -- that is, !IE -- then set up for mouse capture
-if (!IE) document.captureEvents(Event.MOUSEMOVE)
-
-// Temporary variables to hold mouse x-y pos.s
-var cursorX = 0;
-var cursorY = 0;
-
-// Main function to retrieve mouse x-y pos.s
-
-function getMouseXY(e) {
-if (IE) { // grab the x-y pos.s if browser is IE
-cursorX = event.clientX + document.body.scrollLeft;
-cursorY = event.clientY + document.body.scrollTop;
-} else { // grab the x-y pos.s if browser is NS
-cursorX = e.pageX;
-cursorY = e.pageY;
-}
-// catch possible negative values in NS4
-if (cursorX < 0){cursorX = 0;}
-if (cursorY < 0){cursorY = 0;}
-// show the position values in the form named Show
-// in the text fields named MouseX and MouseY
-return true;
-}
-
-// Set-up to use getMouseXY function onMouseMove
-document.onmousemove = getMouseXY;
-
-
ToolTip = Class.create();
ToolTip.prototype = {
- initialize:function(id, parentId, mode, disabled, direction, followMouse,
horizontalOffset, verticalOffset){
+ initialize:function(events, id, parentId, mode, disabled, direction, followMouse,
horizontalOffset, verticalOffset, ajaxFunction){
+ this.event = events.event;
+ this.onshow = events.onshow;
+ this.oncomplete = events.oncomplete;
+ this.onhide = events.onhide;
+
this.id = id;
this.parentId = parentId;
this.mode = mode;
@@ -43,48 +19,127 @@
this.followMouse = followMouse;
this.horizontalOffset = horizontalOffset;
this.verticalOffset = verticalOffset;
+ this.ajaxExecuteString = ajaxFunction;
this.toolTip = $(id);
- this.toolTipW = this.toolTip.clientWidth;
- this.toolTipH = this.toolTip.clientHeight;
+ this.toolTipContent = $(id + 'content');
+ this.toolTipDefaultContent = $(id + 'defaultContent');
+
+ this.toolTip.style.visibility='hidden';
+ this.toolTip.style.display='block';
+
+ this.toolTipOffsetW = this.toolTip.offsetWidth;
+ this.toolTipOffsetH = this.toolTip.offsetHeight;
+
+ this.toolTipW = this.toolTip.getWidth();
+ this.toolTipH = this.toolTip.getHeight();
+
+ this.toolTipBorderHeight = (this.toolTipOffsetH - this.toolTipH) / 2;
+ this.toolTipBorderWidth = (this.toolTipOffsetW - this.toolTipW) / 2;
+ this.toolTip.style.visibility = 'visible';
this.toolTip.style.display = "none";
this.parentAttached = false;
+ this.hintParentElement = null;
- //document.body.attachEvent("load", this.attachOnLoadEvents);
- //document.body.onload = this.attachOnLoadEvents.bindAsEventListener(this);
-
- Event.observe(document.getElementsByTagName("body")[0],
"mousemove", this.attachOnLoadEvents.bindAsEventListener(this), true);
+ // mouse could be overed while ajax request is still in process,
+ // so, after DOM-element replaced, we should not display it
+ this.isMouseOvered = false;
+
+ if(IE){
+ var toolTipZindex = parseInt(this.toolTip.style.zIndex);
+ new Insertion.Before(this.toolTip,
+ "<iframe src=\"javascript:''\" frameborder=\"0\"
scrolling=\"no\" id=\"" + this.id + "iframe\"" +
+ "style=\"position: absolute; width: " + this.toolTipOffsetW +
"px; height: " + this.toolTipOffsetH + "px; display:
none;background-color:black; z-index: " +
+ + (toolTipZindex-1) + ";\">" + "</iframe>");
+ this.iframe = $(this.id + 'iframe');
+ }
+
+ if(!this.disabled) Event.observe(document.getElementsByTagName("body")[0],
"mousemove", this.attachOnLoadEvents.bindAsEventListener(this), true);
},
attachOnLoadEvents: function(){
- //alert('onload');
if(!this.parentAttached){
this.parent = $(this.parentId);
if(this.parent != null && !this.disabled){
this.attachParentEvents();
this.parentAttached = true;
}
+ Event.stopObserving(document.getElementsByTagName("body")[0],
"mousemove", this.attachOnLoadEvents.bindAsEventListener(this), false);
}
},
attachParentEvents: function(){
if(this.followMouse){
- Event.observe(this.parent, "mousemove",
this.doShow.bindAsEventListener(this), false);
- } else {
- Event.observe(this.parent, "mouseover",
this.doShow.bindAsEventListener(this), false);
+ Event.observe(this.parent, 'mousemove',
this.setToolTipPosition.bindAsEventListener(this), false);
}
+ Event.observe(this.parent, this.event, this.doShow.bindAsEventListener(this), false);
+ Event.observe(this.parent, "mouseout", this.doHide.bindAsEventListener(this),
false);
- Event.observe(this.parent, "mouseout", this.doHide.bindAsEventListener(this),
false);
+ Event.observe(this.toolTip, 'mouseout',
this.leaveToolTip.bindAsEventListener(this), false)
},
- doShow: function(){
-
- this.setToolTipPosition();
- this.toolTip.style.display = "block";
-
+
+ detectAncestorNode: function(leaf, element) {
+ // Return true if "element" is "leaf" or one of its parents
+ var node = leaf;
+ while (node != null && node != element)
+ node = node.parentNode;
+ return (node != null);
},
+
+
+ leaveToolTip: function(e) {
+
+ var hintNotLeft = false;
- doHide: function(){
- this.toolTip.style.display = "none";
+ // detect mouse move from hint to owner
+ // if mouse entered the just the owner hintNotLeft is set true
+ hintNotLeft = this.detectAncestorNode(e.toElement,this.hintParentElement);
+ hintNotLeft = hintNotLeft ||
this.detectAncestorNode(e.relatedTarget,this.hintParentElement);
+
+ if (!hintNotLeft){
+ this.doHide(e);
+ this.isMouseOvered = false;
+ }
},
+
+
+
+ doShow: function(e){
+ this.isMouseOvered = true;
+ if (e.target)
+ this.hintParentElement = e.target;
+ if (e.srcElement)
+ this.hintParentElement = e.srcElement;
+
+
+ this.setToolTipPosition(e);
+ if(this.mode == 'ajax'){
+ if(this.toolTipDefaultContent){
+ this.toolTipContent.innerHTML = this.toolTipDefaultContent.innerHTML;
+ }
+ var event = e;
+ eval(this.ajaxExecuteString);
+ }
+ this.displayDiv(e);
+ },
+
+ doHide: function(e){
+ var fakeEvent = false;
+ fakeEvent = this.detectAncestorNode(e.toElement,this.toolTip);
+ fakeEvent = fakeEvent || this.detectAncestorNode(e.relatedTarget,this.toolTip);
+
+
+ if (!fakeEvent) {
+ this.isMouseOvered = false;
+ this.toolTip.style.display = "none";
+ if(this.iframe){
+ this.iframe.style.display = "none";
+ }
+ this.hintParentElement = null;
+ this.isMouseOvered = false;
+ }
+
+ },
+
doEnable: function(){
this.disabled = false;
},
@@ -92,14 +147,20 @@
this.disabled = true;
},
- setToolTipPosition: function(){
+ setToolTipPosition: function(e){
var windowDim = this.windowSize();
-
+ var cursorX = e.clientX + document.body.scrollLeft;
+ var cursorY = e.clientY + document.body.scrollTop;
+
+ this.toolTipH = this.toolTip.getHeight();
+ this.toolTipW = this.toolTip.getWidth();
+
+
if(this.direction == "top-left"){
- if(cursorY - this.verticalOffset - this.toolTip.clientHeight < 0){
+ if(cursorY - this.verticalOffset - this.toolTipH < 0){
+ this.toolTip.style.top = cursorY + this.verticalOffset - this.toolTipH;
+ } else {
this.toolTip.style.top = cursorY - this.verticalOffset - this.toolTipH;
- } else {
- this.toolTip.style.top = cursorY + this.verticalOffset;
}
if(cursorX - this.horizontalOffset - this.toolTipW < 0){
this.toolTip.style.left = cursorX + this.horizontalOffset;
@@ -108,7 +169,7 @@
}
} else if(this.direction == "bottom-left"){
- if(cursorY + this.verticalOffset - this.toolTipH > windowDim[1]){
+ if(cursorY + this.verticalOffset + this.toolTipH > windowDim[1]){
this.toolTip.style.top = cursorY - this.verticalOffset - this.toolTipH;
} else {
this.toolTip.style.top = cursorY + this.verticalOffset;
@@ -116,7 +177,7 @@
if(cursorX - this.horizontalOffset - this.toolTipW < 0){
this.toolTip.style.left = cursorX + this.horizontalOffset ;
} else {
- this.toolTip.style.left = cursorX - this.horizontalOffset - this.toolTopW;
+ this.toolTip.style.left = cursorX - this.horizontalOffset - this.toolTipW;
}
} else if(this.direction == "top-right"){
if(cursorY - this.verticalOffset - this.toolTipH < 0){
@@ -161,9 +222,16 @@
wHeight = document.body.clientHeight;
}
return [wWidth,wHeight];
+ },
+
+ displayDiv: function(e){
+ if(this.isMouseOvered){
+ this.toolTip.style.display = "block";
+ if(this.iframe){
+ this.iframe.style.top = parseInt(this.toolTip.style.top) - this.toolTipBorderHeight;
+ this.iframe.style.left = parseInt(this.toolTip.style.left) -
this.toolTipBorderWidth;
+ this.iframe.style.display = "block";
+ }
+ }
}
-
-
- //
-
}
\ No newline at end of file