cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r293349 - in /cocoon: blocks/forms/trunk/java/org/apache/cocoon/forms/resources/mattkruse-lib/CalendarPopup.js trunk/status.xml
Date Mon, 03 Oct 2005 13:42:05 GMT
Author: sylvain
Date: Mon Oct  3 06:41:59 2005
New Revision: 293349

URL: http://svn.apache.org/viewcvs?rev=293349&view=rev
Log:
Add time dropdowns to the Calendar CForms styling. Thanks to JC Kermagoret <jck@bluexml.org>

Modified:
    cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/mattkruse-lib/CalendarPopup.js
    cocoon/trunk/status.xml

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/mattkruse-lib/CalendarPopup.js
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/mattkruse-lib/CalendarPopup.js?rev=293349&r1=293348&r2=293349&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/mattkruse-lib/CalendarPopup.js
(original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/mattkruse-lib/CalendarPopup.js
Mon Oct  3 06:41:59 2005
@@ -20,6 +20,8 @@
 
 // HISTORY
 // ------------------------------------------------------------------
+// September 27, 2005: Added support for drop-down hours, minutes
+//      and seconds (Jean-Christophe Kermagoret, jck@bluexml.org)
 // March 24, 2004: Fixed bug - when month name and abbreviations were
 //      changed, date format still used original values.
 // January 26, 2004: Added support for drop-down month and year
@@ -191,7 +193,8 @@
 		}
 	else {
 		c = new PopupWindow();
-		c.setSize(150,175);
+		c.setSize(150,180);
+		//c.setSize(150,175);
 		}
 	c.offsetX = -152;
 	c.offsetY = 25;
@@ -206,6 +209,7 @@
 	c.returnYearFunction = "CP_tmpReturnYearFunction";
 	c.weekStartDay = 0;
 	c.isShowYearNavigation = false;
+	c.isShowDateTimeDropdowns = false;
 	c.displayType = "date";
 	c.disabledWeekDays = new Object();
 	c.disabledDatesExpression = "";
@@ -234,6 +238,8 @@
 	c.setYearSelectStartOffset = CP_setYearSelectStartOffset;
 	c.setTodayText = CP_setTodayText;
 	c.showYearNavigation = CP_showYearNavigation;
+	// BlueXML
+	c.showDateTimeDropdowns = BX_showDateTimeDropdowns;	
 	c.showCalendar = CP_showCalendar;
 	c.hideCalendar = CP_hideCalendar;
 	c.getStyles = getCalendarStyles;
@@ -260,9 +266,9 @@
 	}
 }
 // Temporary default functions to be called when items clicked, so no error is thrown
-function CP_tmpReturnFunction(y,m,d) { 
+function CP_tmpReturnFunction(y,m,d,hh,mm,ss) { 
 	if (window.CP_targetInput!=null) {
-		var dt = new Date(y,m-1,d,0,0,0);
+		var dt = new Date(y,m-1,d,hh,mm,ss);
 		if (window.CP_calendarObject!=null) { window.CP_calendarObject.copyMonthNamesToWindow();
}
 		window.CP_targetInput.value = formatDate(dt,window.CP_dateFormat);
 		}
@@ -310,6 +316,9 @@
 // Show next/last year navigation links
 function CP_showYearNavigation() { this.isShowYearNavigation = (arguments.length>0)?arguments[0]:true;
}
 
+// Show next/last year navigation links
+function BX_showDateTimeDropdowns() { this.isShowDateTimeDropdowns = (arguments.length>0)?arguments[0]:true;
}
+
 // Which type of calendar to display
 function CP_setDisplayType(type) {
 	if (type!="date"&&type!="week-end"&&type!="month"&&type!="quarter"&&type!="year")
{ alert("Invalid display type! Must be one of: date,week-end,month,quarter,year"); return
false; }
@@ -417,6 +426,8 @@
 		else { this.currentDate=new Date(time); }
 		}
 	window.CP_dateFormat = format;
+	// DATE dropdown: show them if the format contains the hour
+	this.showDateTimeDropdowns(format.indexOf("HH") != -1);
 	this.showCalendar(linkname);
 	}
 	
@@ -447,6 +458,12 @@
 // Return a string containing all the calendar code to be displayed
 function CP_getCalendar() {
 	var now = new Date();
+
+	var dateTimeDropdowns = '0,0,0';
+	if (this.isShowDateTimeDropdowns) {
+		dateTimeDropdowns = initDateTimeDropdowns();
+	}
+		
 	// Reference to window
 	if (this.type == "WINDOW") { var windowref = "window.opener."; }
 	else { var windowref = ""; }
@@ -578,7 +595,7 @@
 						selected_month = d.getMonth()+1;
 						selected_date = d.getDate();
 						}
-					result += '	<TD CLASS="'+this.cssPrefix+dateClass+'"><A HREF="javascript:'+windowref+this.returnFunction+'('+selected_year+','+selected_month+','+selected_date+');'+windowref+'CP_hideCalendar(\''+this.index+'\');"
CLASS="'+this.cssPrefix+dateClass+'">'+display_date+'</A></TD>\n';
+					result += '	<TD CLASS="'+this.cssPrefix+dateClass+'"><A HREF="javascript:'+windowref+this.returnFunction+'('+selected_year+','+selected_month+','+selected_date+','+dateTimeDropdowns+');'+windowref+'CP_hideCalendar(\''+this.index+'\');"
CLASS="'+this.cssPrefix+dateClass+'">'+display_date+'</A></TD>\n';
 					}
 				display_date++;
 				if (display_date > daysinmonth[display_month]) {
@@ -592,6 +609,7 @@
 				}
 			result += '</TR>';
 			}
+			
 		var current_weekday = now.getDay() - this.weekStartDay;
 		if (current_weekday < 0) {
 			current_weekday += 7;
@@ -606,10 +624,14 @@
 			result += '		<SPAN CLASS="'+this.cssPrefix+'cpTodayTextDisabled">'+this.todayText+'</SPAN>\n';
 			}
 		else {
-			result += '		<A CLASS="'+this.cssPrefix+'cpTodayText" HREF="javascript:'+windowref+this.returnFunction+'(\''+now.getFullYear()+'\',\''+(now.getMonth()+1)+'\',\''+now.getDate()+'\');'+windowref+'CP_hideCalendar(\''+this.index+'\');">'+this.todayText+'</A>\n';
+			result += '		<A CLASS="'+this.cssPrefix+'cpTodayText" HREF="javascript:'+windowref+this.returnFunction+'(\''+now.getFullYear()+'\',\''+(now.getMonth()+1)+'\',\''+now.getDate()+'\','+dateTimeDropdowns+');'+windowref+'CP_hideCalendar(\''+this.index+'\');">'+this.todayText+'</A>\n';
 			}
 		result += '		<BR>\n';
 		result += '	</TD></TR></TABLE></CENTER></TD></TR></TABLE>\n';
+
+		if (this.isShowDateTimeDropdowns) {
+			result += showDateTimeDropdowns(this.currentDate);
+		}		
 	}
 
 	// Code common for MONTH, QUARTER, YEAR
@@ -686,3 +708,69 @@
 		}
 	return result;
 	}
+
+
+function initDateTimeDropdowns() {	
+	var hours = 'window.document.forms[0].elements[0].options[window.document.forms[0].elements[0].selectedIndex].value';
+	var minutes = 'window.document.forms[0].elements[1].options[window.document.forms[0].elements[1].selectedIndex].value';
+	var seconds = 'window.document.forms[0].elements[2].options[window.document.forms[0].elements[2].selectedIndex].value';
+
+	return hours + ',' + minutes + ',' + seconds;
+}
+
+function showDateTimeDropdowns(currentDate) {
+	var result = '';
+	
+	result += '<form id="dateTime">';
+	result += '<div class="dateTime" style="text-align: center;font-size: 100%;">\n';
+
+	// Hours
+	result += '<select style="font-size: 70%;" id="hours">\n';
+	result += '<option value="00">hh</option>\n';
+	for (var i = 0; i < 24; i++) {
+		var selected = '';
+		var hh = formatHMS(i);
+		if (hh == formatHMS(currentDate.getHours())) {
+			selected = 'selected';
+		}
+		result += '<option ' + selected + ' value="' + hh + '">' + hh + '</option>\n';
			
+	}
+	result += '</select>\n';
+
+	// Minutes
+	result += '<select style="font-size: 70%;" id="minutes">\n';
+	result += '<option value="00">mm</option>\n';
+	for (var i = 0; i < 59; i++) {
+		var selected = '';
+		var mm = formatHMS(i);
+		if (mm == formatHMS(currentDate.getMinutes())) {
+			selected = 'selected';
+		}
+		result += '<option ' + selected + ' value="' + mm + '">' + mm + '</option>\n';
+	}
+	result += '</select>\n';
+		
+	// Seconds
+	result += '<select style="font-size: 70%;" id="seconds">\n';
+	result += '<option value="00">ss</option>\n';
+	for (var i = 0; i < 59; i++) {
+		var selected = '';
+		var ss = formatHMS(i);
+		if (ss == formatHMS(currentDate.getSeconds())) {
+			selected = 'selected';
+		}
+		result += '<option ' + selected + ' value="' + ss + '">' + ss + '</option>\n';
			
+	}
+	result += '</select>\n';
+	
+	return result;
+}
+
+function formatHMS(input) {
+	if (input < 10) {
+		return '0' + input;
+	} else {
+		return input;
+	}
+	
+}
\ No newline at end of file

Modified: cocoon/trunk/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/status.xml?rev=293349&r1=293348&r2=293349&view=diff
==============================================================================
--- cocoon/trunk/status.xml (original)
+++ cocoon/trunk/status.xml Mon Oct  3 06:41:59 2005
@@ -573,6 +573,10 @@
    </action>
   </release>
   <release version="2.1.8" date="TBD">
+    <action dev="SW" type="add" due-to="Jean-Chrisophe Kermagoret" due-to-email="jck@bluexml.org">
+	   CForms: Small change to the calendar styling which now shows dropdowns to choose the
time when
+	   the date format includes time also.
+	 </action>
     <action dev="AG" type="update">
       Updated quartz to 1.5.0.
     </action>



Mime
View raw message