[richfaces-svn-commits] JBoss Rich Faces SVN: r5925 - in trunk: ui/calendar/src/main/config/component and 2 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Thu Feb 7 13:30:34 EST 2008


Author: pyaschenko
Date: 2008-02-07 13:30:34 -0500 (Thu, 07 Feb 2008)
New Revision: 5925

Modified:
   trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
   trunk/ui/calendar/src/main/config/component/calendar.xml
   trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
   trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
Log:
RF-2131

Modified: trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
===================================================================
--- trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp	2008-02-07 17:03:07 UTC (rev 5924)
+++ trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp	2008-02-07 18:30:34 UTC (rev 5925)
@@ -48,6 +48,10 @@
 		        <calendar:calendar cellWidth="5" cellHeight="5"/>
 		        <calendar:calendar cellWidth="40" cellHeight="40" popup="#{calendarBean.popup}"/>
 				<calendar:calendar 
+					onchanged = "alert('changed:'+this.value);"
+					ontimeselected = "alert('time selectED:'+event.rich.date.toString());"
+					ondateselected = "alert('date selectED:'+event.rich.date.toString());"
+					ondateselect = "alert('date select:'+event.rich.date.toString());"
 					id="calendar"
 					dataModel="#{calendarDataModel}"
 					locale="#{calendarBean.locale}"

Modified: trunk/ui/calendar/src/main/config/component/calendar.xml
===================================================================
--- trunk/ui/calendar/src/main/config/component/calendar.xml	2008-02-07 17:03:07 UTC (rev 5924)
+++ trunk/ui/calendar/src/main/config/component/calendar.xml	2008-02-07 18:30:34 UTC (rev 5925)
@@ -315,6 +315,21 @@
 			<description>onDateSelected event handler</description>
 		</property>
 		<property>
+			<name>ontimeselect</name>
+			<classname>java.lang.String</classname>
+			<description>onTimeSelect event handler</description>
+		</property>
+		<property>
+			<name>ontimeselected</name>
+			<classname>java.lang.String</classname>
+			<description>onTimeSelected event handler</description>
+		</property>
+		<property>
+			<name>onchanged</name>
+			<classname>java.lang.String</classname>
+			<description>onChanged event handler</description>
+		</property>
+		<property>
 			<name>oncurrentdateselect</name>
 			<classname>java.lang.String</classname>
 			<description>onCurrentDateSelect event handler</description>

Modified: trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
--- trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js	2008-02-07 17:03:07 UTC (rev 5924)
+++ trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js	2008-02-07 18:30:34 UTC (rev 5925)
@@ -1105,7 +1105,7 @@
 		
 		var element = $(this.id);
 
-		if (this.invokeEvent("expand", element))
+		if (this.invokeEvent("expand", element, e))
 		{
 
 			var iframe=null;
@@ -1117,7 +1117,7 @@
 			
 			if (baseInput && baseInput.value!=undefined)
 			{
-				this.selectDate(baseInput.value);
+				this.selectDate(baseInput.value, false, {event:e, element:element});
 			}
 			
 			//rect calculation
@@ -1181,6 +1181,16 @@
 		return true;
 	},
 	
+	setInputField: function(dateStr, event)
+	{
+		var field = $(this.INPUT_DATE_ID);
+		if (field.value!=dateStr)
+		{
+			field.value=dateStr;
+			this.invokeEvent("changed",field, event, this.selectedDate);
+		}
+	},
+	
 	getCurrentDate: function() {
 		return this.currentDate;
 	},	
@@ -1280,8 +1290,19 @@
 		{
 			var date=new Date(this.currentDate);
 			date.setDate(daydata.day);
+			if (this.timeType)
+			{
+				if (this.selectedDate)
+				{
+					date.setHours(this.selectedDate.getHours());
+					date.setMinutes(this.selectedDate.getMinutes());
+				} else
+				{
+					date.setHours(12);
+				}
+			}
 			
-			if (this.selectDate(date,true) && !this.showApplyButton)
+			if (this.selectDate(date,true, {event:e, element:obj}) && !this.showApplyButton)
 			{
 				this.doCollapse();
 			}
@@ -1291,8 +1312,21 @@
 				if (daydata._month==-1) this.prevMonth(); else this.nextMonth();
 			else if (this.params.boundaryDatesMode == "select") 
 			{
-				if (this.selectDate(daydata.date) && !this.showApplyButton)
+				var date = new Date(daydata.date);
+				if (this.timeType)
 				{
+					if (this.selectedDate)
+					{
+						date.setHours(this.selectedDate.getHours());
+						date.setMinutes(this.selectedDate.getMinutes());
+					} else
+					{
+						date.setHours(12);
+					}
+				}
+				
+				if (this.selectDate(date, false, {event:e, element:obj}) && !this.showApplyButton)
+				{
 				 	this.doCollapse();
 				}
 			}
@@ -1750,8 +1784,21 @@
 		if (this.todayCellId)
 		{
 			var daydata = this.days[parseInt($(this.todayCellId).id.substr(this.DATE_ELEMENT_ID.length),10)];
-			if (daydata.enabled && this.selectDate(new Date(),true) && !this.showApplyButton)
+			var today = new Date();
+			var date = new Date(today.getFullYear(), today.getMonth(), today.getDate());
+			if (this.timeType)
 			{
+				if (this.selectedDate)
+				{
+					date.setHours(this.selectedDate.getHours());
+					date.setMinutes(this.selectedDate.getMinutes());
+				} else
+				{
+					date.setHours(12);
+				}
+			}
+			if (daydata.enabled && this.selectDate(date,true) && !this.showApplyButton)
+			{
 				this.doCollapse();
 			}
 		}		
@@ -1771,13 +1818,11 @@
 		
 		var oldSelectedDate = this.selectedDate;
 		var newSelectedDate;
-		var isDateParsed = false;
 		if (date)
 		{
 			if (typeof date=='string') 
 			{
 				date = Richfaces.Calendar.parseDate(date,this.params.datePattern, this.params.monthLabels, this.params.monthLabelsShort);
-				if (date) isDateParsed = true;
 			}
 			newSelectedDate = date;
 		}
@@ -1791,34 +1836,15 @@
 		var isDateChanged = false;
 		if ( (oldSelectedDate - newSelectedDate) && (oldSelectedDate!=null || newSelectedDate!=null) )
 		{
-			isDateChanged = true 	
+			isDateChanged = true
 			flag = this.invokeEvent("dateselect", eventData.element, eventData.event, date)
 		}	
 		
 		if (flag)
 		{		   
-			var field = $(this.INPUT_DATE_ID);
 			this.selectedDate = newSelectedDate;
 			if (this.selectedDate!=null)
 			{
-				if (this.timeType && !isDateParsed)
-				{
-					if (oldSelectedDate!=null)
-					{
-						this.selectedDate.setHours(oldSelectedDate.getHours());
-						this.selectedDate.setMinutes(oldSelectedDate.getMinutes());
-						
-					}
-					else
-					{
-						this.selectedDate.setHours(12);
-						this.selectedDate.setMinutes(0);
-					}
-					this.selectedDate.setSeconds(0);
-				}
-					
-				if (!this.showApplyButton) field.value=this.getSelectedDateString(this.params.datePattern);
-				
 				var d = new Date(this.selectedDate);
 				if (d.getMonth()==this.currentDate.getMonth() && d.getFullYear()==this.currentDate.getFullYear())
 				{
@@ -1850,7 +1876,6 @@
 			else
 			{
 				this.selectedDate = null;
-				field.value = ""; 
 
 				this.clearEffect(this.selectedDateCellId, this.highlightEffect2, "rich-calendar-select", "rich-calendar-btn");
 				
@@ -1876,6 +1901,10 @@
 			if (isDateChanged)
 			{
 				this.invokeEvent("dateselected", eventData.element, eventData.event, this.selectedDate);
+				if (!this.showApplyButton)
+				{
+					this.setInputField(this.selectedDate!=null ? this.getSelectedDateString(this.params.datePattern) : "", eventData.event);
+				}
 			}
 		}
 		
@@ -1888,15 +1917,15 @@
 		if (this.invokeEvent("dateselect", null, null, null))
 		{
 			this.selectedDate = null;
+			this.invokeEvent("dateselected", null, null, null);
 			
 			this.selectedDateCellId = this.clearEffect(this.selectedDateCellId, this.highlightEffect2, "rich-calendar-select", "rich-calendar-btn");
 			 
 			this.renderHF();
 			if (!this.showApplyButton)
 			{
-				$(this.INPUT_DATE_ID).value = "";
+				this.setInputField("", null);
 				this.doCollapse();
-				this.invokeEvent("dateselected", null, null, null);
 			}
 		}
 	},
@@ -1929,8 +1958,7 @@
 	{
 		if (updateDate)
 		{
-			var field = $(this.INPUT_DATE_ID);
-			field.value=this.getSelectedDateString(this.params.datePattern);
+			this.setInputField(this.getSelectedDateString(this.params.datePattern), null);
 		}		
 		this.doCollapse();
 	},
@@ -1983,7 +2011,6 @@
 		if (updateTime && this.selectedDate)
 		{
 			var m = parseInt($(this.id+'TimeMinutes').value,10);
-			this.selectedDate.setMinutes(m);
 			var h=parseInt($(this.id+'TimeHours').value,10);
 			if (this.timeType==2)
 			{
@@ -1996,8 +2023,13 @@
 					if (h!=12) h+=12;
 				}
 			}
-			this.selectedDate.setHours(h);
-			this.renderHF();
+			var date = new Date(this.selectedDate.getFullYear(), this.selectedDate.getMonth(), this.selectedDate.getDate(), h, m, 0);
+			if (date-this.selectedDate && this.invokeEvent("timeselect",null, null, date))
+			{
+				this.renderHF();
+				this.selectedDate = date;
+				this.invokeEvent("timeselected",null, null, this.selectedDate);
+			}
 		}
 		if (this.params.popup && !this.showApplyButton && updateTime) this.close(true);
 	},

Modified: trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
--- trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx	2008-02-07 17:03:07 UTC (rev 5924)
+++ trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx	2008-02-07 18:30:34 UTC (rev 5925)
@@ -200,6 +200,9 @@
 
 			<f:call name="writeEventHandlerFunction"><f:parameter value="ondateselected" /></f:call>
 			<f:call name="writeEventHandlerFunction"><f:parameter value="ondateselect" /></f:call>
+			<f:call name="writeEventHandlerFunction"><f:parameter value="ontimeselect" /></f:call>
+			<f:call name="writeEventHandlerFunction"><f:parameter value="ontimeselected" /></f:call>
+			<f:call name="writeEventHandlerFunction"><f:parameter value="onchanged" /></f:call>
 			<f:call name="writeEventHandlerFunction"><f:parameter value="ondatemouseover" /></f:call>
 			<f:call name="writeEventHandlerFunction"><f:parameter value="ondatemouseout" /></f:call>
 			<f:call name="writeEventHandlerFunction"><f:parameter value="onexpand" /></f:call>




More information about the richfaces-svn-commits mailing list