[richfaces-svn-commits] JBoss Rich Faces SVN: r4471 - in branches/3.1.x: framework/impl/src/main/javascript/jquery and 13 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Tue Dec 4 13:51:39 EST 2007
Author: pyaschenko
Date: 2007-12-04 13:51:39 -0500 (Tue, 04 Dec 2007)
New Revision: 4471
Added:
branches/3.1.x/framework/impl/src/main/javascript/jquery/identity.js
branches/3.1.x/ui/calendar/design/calendar/calendar_div_more.html
branches/3.1.x/ui/calendar/design/calendar/icons/
branches/3.1.x/ui/calendar/design/calendar/icons/close.gif
branches/3.1.x/ui/calendar/design/calendar/icons/separator.gif
branches/3.1.x/ui/calendar/design/calendar/icons/spacer.gif
branches/3.1.x/ui/calendar/src/main/java/org/richfaces/renderkit/html/iconimages/CalendarSeparator.java
branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/JQuerySpinBtn.js
Modified:
branches/3.1.x/framework/impl/generatescript.xml
branches/3.1.x/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/json/json-dom.js
branches/3.1.x/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java
branches/3.1.x/samples/calendar-sample/src/main/java/org/richfaces/CalendarDataModelImpl.java
branches/3.1.x/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
branches/3.1.x/ui/calendar/pom.xml
branches/3.1.x/ui/calendar/src/main/config/component/calendar.xml
branches/3.1.x/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
branches/3.1.x/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss
branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
branches/3.1.x/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
Log:
calendar was merged with trunk + RF-1192
Modified: branches/3.1.x/framework/impl/generatescript.xml
===================================================================
--- branches/3.1.x/framework/impl/generatescript.xml 2007-12-04 18:39:29 UTC (rev 4470)
+++ branches/3.1.x/framework/impl/generatescript.xml 2007-12-04 18:51:39 UTC (rev 4471)
@@ -50,7 +50,7 @@
-->
<filelist id="jquery"
dir="${basedir}/src/main/javascript/jquery"
- files="jquery-1.2.1.js,noConflict.js">
+ files="jquery-1.2.1.js,noConflict.js,identity.js">
</filelist>
Added: branches/3.1.x/framework/impl/src/main/javascript/jquery/identity.js
===================================================================
--- branches/3.1.x/framework/impl/src/main/javascript/jquery/identity.js (rev 0)
+++ branches/3.1.x/framework/impl/src/main/javascript/jquery/identity.js 2007-12-04 18:51:39 UTC (rev 4471)
@@ -0,0 +1,10 @@
+if (jQuery(jQuery) != jQuery) {
+ var oldJQuery = jQuery;
+ jQuery = function() {
+ if (arguments[0] == arguments.callee) {
+ return arguments.callee;
+ } else {
+ return oldJQuery.apply(this, arguments);
+ }
+ };
+};
\ No newline at end of file
Modified: branches/3.1.x/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/json/json-dom.js
===================================================================
--- branches/3.1.x/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/json/json-dom.js 2007-12-04 18:39:29 UTC (rev 4470)
+++ branches/3.1.x/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/json/json-dom.js 2007-12-04 18:51:39 UTC (rev 4471)
@@ -152,6 +152,7 @@
E.prototype.getContent = function(context) {
var html = "<"+this.tag;
var inner = this.getInnerHTML(context);
+ if (inner=='') this.isEmpty = true; else this.isEmpty=false;
for(var i in this.attrs) {
if (!this.attrs.hasOwnProperty(i)) {
continue ;
@@ -160,7 +161,7 @@
var attrValue = this.attrs[i];
if (typeof attrValue == "function")
- attrValue = attrValue(context);
+ attrValue = attrValue.call(this, context);
if (attrValue)
html += " "+(i=='className'?'class':i)+'="'+this.xmlEscape(attrValue)+'"';
Modified: branches/3.1.x/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java
===================================================================
--- branches/3.1.x/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java 2007-12-04 18:39:29 UTC (rev 4470)
+++ branches/3.1.x/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java 2007-12-04 18:51:39 UTC (rev 4471)
@@ -45,16 +45,22 @@
private boolean popup;
private boolean readonly;
private boolean showInput;
- private boolean enableManualInput;
+ private boolean enableManualInput;
+ private boolean disabled;
+ private boolean showApplyButton;
private String pattern;
private Date currentDate;
private Date selectedDate;
private String jointPoint;
private String direction;
private String boundary;
+ private String todayControlMode;
private int counter;
+
+
+
private boolean useCustomDayLabels;
public Locale getLocale() {
@@ -100,6 +106,9 @@
enableManualInput=false;
showInput=true;
boundary = "inactive";
+ disabled = false;
+ todayControlMode = "select";
+
}
@@ -223,4 +232,28 @@
public int getCounter() {
return counter++;
}
+
+ public boolean isDisabled() {
+ return disabled;
+ }
+
+ public void setDisabled(boolean disabled) {
+ this.disabled = disabled;
+ }
+
+ public boolean isShowApplyButton() {
+ return showApplyButton;
+ }
+
+ public void setShowApplyButton(boolean showApplyButton) {
+ this.showApplyButton = showApplyButton;
+ }
+
+ public String getTodayControlMode() {
+ return todayControlMode;
+ }
+
+ public void setTodayControlMode(String todayControlMode) {
+ this.todayControlMode = todayControlMode;
+ }
}
\ No newline at end of file
Modified: branches/3.1.x/samples/calendar-sample/src/main/java/org/richfaces/CalendarDataModelImpl.java
===================================================================
--- branches/3.1.x/samples/calendar-sample/src/main/java/org/richfaces/CalendarDataModelImpl.java 2007-12-04 18:39:29 UTC (rev 4470)
+++ branches/3.1.x/samples/calendar-sample/src/main/java/org/richfaces/CalendarDataModelImpl.java 2007-12-04 18:51:39 UTC (rev 4471)
@@ -69,9 +69,11 @@
item.setDay(c.get(Calendar.DAY_OF_MONTH));*/
if (new Random().nextInt(10) > 5) {
- item.setEnabled(true);
+ item.setEnabled(true);
+
} else {
item.setEnabled(false);
+ item.setStyleClass("rich-calendar-boundary-dates");
}
item.setData(data);
Modified: branches/3.1.x/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
===================================================================
--- branches/3.1.x/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp 2007-12-04 18:39:29 UTC (rev 4470)
+++ branches/3.1.x/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp 2007-12-04 18:51:39 UTC (rev 4471)
@@ -38,6 +38,9 @@
</h:panelGrid>
<br />
<br />
+ <calendar:calendar todayControlMode="#{calendarBean.todayControlMode}" datePattern="#{calendarBean.pattern}" showApplyButton="#{calendarBean.showApplyButton}" popup="#{calendarBean.popup}"/>
+ <calendar:calendar cellWidth="5" cellHeight="5"/>
+ <calendar:calendar cellWidth="40" cellHeight="40"/>
<calendar:calendar
id="calendar"
dataModel="#{calendarDataModel}"
@@ -51,6 +54,7 @@
direction="#{calendarBean.direction}"
buttonLabel="Select Date"
enableManualInput="#{calendarBean.enableManualInput}"
+ disabled="#{calendarBean.disabled}"
showInput="#{calendarBean.showInput}"
boundaryDatesMode="#{calendarBean.boundary}"
currentDateChangeListener="#{calendarBean.dcl}"
@@ -60,7 +64,11 @@
buttonClass="bc"
horizontalOffset="3"
verticalOffset="3"
- mode="ajax">
+ cellHeight="50"
+ cellWidth="50"
+ mode="ajax"
+ showApplyButton="#{calendarBean.showApplyButton}"
+ todayControlMode="#{calendarBean.todayControlMode}">
<f:facet name="optionalHeader">
<h:outputText value="optionalHeader Facet" />
</f:facet>
@@ -68,6 +76,8 @@
<h:outputText value="optionalFooter Facet" />
</f:facet>
+ <f:facet name="weekDay"><f:verbatim><span style="padding: 2px; font-size: 10px" >{weekDayLabelShort}</span></f:verbatim></f:facet>
+
<f:validator validatorId="org.richfaces.CalendarValidator" />
<h:panelGrid columns="2">
@@ -92,12 +102,16 @@
<h:selectBooleanCheckbox value="#{calendarBean.popup}" onclick="submit()"/>
<h:outputText value="Custom day labels:" />
<h:selectBooleanCheckbox value="#{calendarBean.useCustomDayLabels}" onclick="submit()"/>
+ <h:outputText value="Show Apply Button:" />
+ <h:selectBooleanCheckbox value="#{calendarBean.showApplyButton}" onclick="submit()"/>
<h:outputText value="Select Date Pattern:"/>
<h:selectOneMenu value="MMM d, yyyy" onchange="submit()" valueChangeListener="#{calendarBean.selectPattern}">
<f:selectItem itemLabel="d/M/yy" itemValue="d/M/yy"/>
<f:selectItem itemLabel="dd/M/yy" itemValue="dd/M/yy"/>
<f:selectItem itemLabel="d/MMM/y" itemValue="d/MMM/y"/>
- <f:selectItem itemLabel="MMM d, yyyy" itemValue="MMM d, yyyy"/>
+ <f:selectItem itemLabel="MMM d, yyyy" itemValue="MMM d, yyyy"/>
+ <f:selectItem itemLabel="dd/M/yy HH:mm" itemValue="dd/M/yy HH:mm"/>
+ <f:selectItem itemLabel="MMM d, yyyy h:mm a" itemValue="MMM d, yyyy h:mm a"/>
</h:selectOneMenu>
<h:inputText id="selectdate"/><h:commandButton type="button" value="Select Date" onclick="$(this.form.id+':calendar').component.selectDate(this.form[this.form.id+':selectdate'].value);"/>
<h:outputText value="Select Popup Joint Point:" />
@@ -121,6 +135,13 @@
<f:selectItem itemLabel="select" itemValue="select"/>
<f:selectItem itemLabel="scroll" itemValue="scroll"/>
</h:selectOneRadio>
+
+ <h:outputText value="TodayControlMode:" />
+ <h:selectOneRadio onclick="submit()" value="#{calendarBean.todayControlMode}">
+ <f:selectItem itemLabel="hidden" itemValue="hidden"/>
+ <f:selectItem itemLabel="select" itemValue="select"/>
+ <f:selectItem itemLabel="scroll" itemValue="scroll"/>
+ </h:selectOneRadio>
<h:outputText value="EnableManualInput:"></h:outputText>
<h:selectBooleanCheckbox value="#{calendarBean.enableManualInput}"
onclick="submit()">
@@ -129,6 +150,10 @@
<h:selectBooleanCheckbox value="#{calendarBean.showInput}"
onclick="submit()">
</h:selectBooleanCheckbox>
+ <h:outputText value="Disabled:"></h:outputText>
+ <h:selectBooleanCheckbox value="#{calendarBean.disabled}"
+ onclick="submit()">
+ </h:selectBooleanCheckbox>
Added: branches/3.1.x/ui/calendar/design/calendar/calendar_div_more.html
===================================================================
--- branches/3.1.x/ui/calendar/design/calendar/calendar_div_more.html (rev 0)
+++ branches/3.1.x/ui/calendar/design/calendar/calendar_div_more.html 2007-12-04 18:51:39 UTC (rev 4471)
@@ -0,0 +1,403 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+
+<html>
+<head>
+<title>calendar</title>
+<style>
+.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; /*NEW ATTRIBUTE - tableBackgroundColor*/
+ 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; /*NEW ATTRIBUTE - calendarwWeekBackgroundColor*/
+ vertical-align : middle;
+ text-align : center;
+ width : 25px;
+}
+
+.calendar_holly{
+ background-color : #ffebda; /*NEW ATTRIBUTE - calendarHolidaysBackgroundColor*/
+ color : #ff7800; /*NEW ATTRIBUTE - calendarHolidaysTextColor*/
+}
+
+.calendar_current{
+ background-color : #ff7800; /*NEW ATTRIBUTE - calendarCurrentBackgroundColor*/
+ color : #ffebda; /*NEW ATTRIBUTE - calendarCurrentTextColor*/
+ font-weight : bold;
+}
+
+.calendar_spec{
+ background-color : #e4f5e2; /*NEW ATTRIBUTE - calendarSpecBackgroundColor*/
+ color : #000000; /*NEW ATTRIBUTE - calendarSpecTextColor*/
+}
+
+.calendar_select{
+ background-color : #224986; /*headerBackgroundColor*/
+ color : #FFFFFF; /*headerTextColor*/
+ font-weight : bold;
+}
+
+
+.right_cell{
+ border-right : 0px;
+}
+
+.bottom_cell{
+ border-bottom : 0px;
+}
+
+.calendar_toolfooter{
+ background : #C7D7EC; /*additionalBackgroundColor*/
+ font-size : 11px; /*generalSizeFont*/
+ font-family : verdana; /*generalFamilyFont*/
+ padding : 1px;
+}
+
+.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 : 0px;
+}
+
+.footer_btn{border : 0px solid #C7D7EC; padding : 1px 3px 1px 3px;white-space : nowrap;text-align : center;}
+.footer_btn_over{background-color : #f5f5f5;border-top : 1px solid #FFFFFF; border-left : 1px solid #FFFFFF; border-right : 1px solid #C0C0C0; border-bottom : 1px solid #C0C0C0; padding : 0px 2px 0px 2px;white-space : nowrap;text-align : center;}
+.footer_btn_press{background-color : #f5f5f5; border-bottom : 1px solid #FFFFFF; border-right : 1px solid #FFFFFF; border-left : 1px solid #C0C0C0; border-top : 1px solid #C0C0C0; padding : 0px 2px 0px 2px;white-space : nowrap;text-align : center;}
+
+.header_btn{border : 0px solid #C7D7EC; padding : 3px; white-space : nowrap;}
+.header_btn_over{background-color : #f5f5f5; border-top : 1px solid #FFFFFF; border-left : 1px solid #FFFFFF; border-right : 1px solid #C0C0C0; border-bottom : 1px solid #C0C0C0; padding : 2px;white-space : nowrap;}
+.header_btn_press{background-color : #f5f5f5; border-bottom : 1px solid #FFFFFF; border-right : 1px solid #FFFFFF; border-left : 1px solid #C0C0C0; border-top : 1px solid #C0C0C0; padding : 2px;white-space : nowrap;}
+
+.calendar_closetab{
+border-bottom : 1px solid #C0C0C0; /*panelBorderColor*/
+background : url(icons/separator.gif) center left no-repeat #224986;
+padding : 0px 2px 0px 4px;
+text-align : center;
+}
+</style>
+
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<div>
+<table border="0" cellpadding="0" cellspacing="0" class="calendar_exterior">
+
+ <tr>
+ <td colspan="7">
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
+ <td class="calendar_tool calendar_btn">
+ ««
+ </td>
+ <td class="calendar_tool calendar_btn">
+ «
+ </td>
+ <td class="calendar_month calendar_btn">
+ November, 2007
+ </td>
+ <td class="calendar_tool calendar_btn">
+ »
+ </td>
+ <td class="calendar_tool calendar_btn">
+ »»
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="calendar_closetab calendar_btn">
+ <div class="header_btn" onmouseover="this.className='header_btn_over'" onmouseout="this.className='header_btn'" onmousedown="this.className='header_btn_press'">
+ <img src="icons/close.gif" width="11" height="11" alt="Close" border="0"><br>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td class="calendar_days">
+ <br>
+ </td>
+ <td class="calendar_days">
+ Sun
+ </td>
+ <td class="calendar_days">
+ Mon
+ </td>
+ <td class="calendar_days">
+ Tue
+ </td>
+ <td class="calendar_days">
+ Wed
+ </td>
+ <td class="calendar_days">
+ Thu
+ </td>
+ <td class="calendar_days">
+ Fri
+ </td>
+ <td class="calendar_days right_cell">
+ Sat
+ </td>
+ </tr>
+
+ <tr>
+ <td class="calendar_week">
+ 1
+ </td>
+ <td class="cell_size calendar_cell calendar_holly">
+ <br>
+ </td>
+ <td class="cell_size calendar_cell calendar_cell">
+ <br>
+ </td>
+ <td class="cell_size calendar_cell calendar_btn">
+ 1<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_btn">
+ 2<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_btn">
+ 3<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_btn">
+ 4<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_holly right_cell calendar_btn">
+ 5<br>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="calendar_week">
+ 2
+ </td>
+ <td class="cell_size calendar_cell calendar_holly calendar_btn">
+ 6<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_btn">
+ 7<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_current calendar_btn">
+ 8<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_btn">
+ 9<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_spec calendar_btn">
+ 10<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_spec calendar_btn">
+ 11<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_holly right_cell calendar_btn">
+ 12<br>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="calendar_week">
+ 3
+ </td>
+ <td class="cell_size calendar_cell calendar_holly calendar_btn">
+ 13<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_btn">
+ 14<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_btn">
+ 15<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_spec calendar_btn">
+ 16<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_btn">
+ 17<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_btn">
+ 18<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_holly right_cell calendar_btn">
+ 19<br>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="calendar_week">
+ 4
+ </td>
+ <td class="cell_size calendar_cell calendar_holly calendar_btn">
+ 20<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_btn">
+ 21<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_btn">
+ 22<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_btn">
+ 23<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_select calendar_btn">
+ 24<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_btn">
+ 25<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_holly right_cell calendar_btn">
+ 26<br>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="calendar_week bottom_cell calendar_btn">
+ 5
+ </td>
+ <td class="cell_size calendar_cell calendar_holly bottom_cell calendar_btn">
+ 27<br>
+ </td>
+ <td class="cell_size calendar_cell bottom_cell calendar_btn">
+ 28<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_spec bottom_cell calendar_btn">
+ 29<br>
+ </td>
+ <td class="cell_size calendar_cell calendar_spec bottom_cell calendar_btn">
+ 30<br>
+ </td>
+ <td class="cell_size calendar_cell bottom_cell">
+ <br>
+ </td>
+ <td class="cell_size calendar_cell bottom_cell">
+ <br>
+ </td>
+ <td class="cell_size calendar_cell calendar_holly right_cell bottom_cell">
+ <br>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="8" class="calendar_footer">
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
+ <td class="calendar_toolfooter calendar_btn">
+ <div class="footer_btn" onmouseover="this.className='footer_btn_over'" onmouseout="this.className='footer_btn'" onmousedown="this.className='footer_btn_press'">
+ Clean<br>
+ </div>
+ </td>
+ <td>
+ <img src="icons/separator.gif" width="1" height="15" alt="" border="0"><br>
+ </td>
+ <td class="calendar_toolfooter calendar_btn">
+ <div class="footer_btn_press" onmouseover="this.className='footer_btn_over'" onmouseout="this.className='footer_btn_press'" onmousedown="this.className='footer_btn_press'">
+ 11:36 AM
+ </div>
+ </td>
+ <td>
+ <img src="icons/separator.gif" width="1" height="15" alt="" border="0"><br>
+ </td>
+ <td class="calendar_toolfooter calendar_btn">
+ <img src="icons/spacer.gif" width="11" height="1" alt="" border="0"><br>
+ </td>
+ <td class="calendar_toolfooter" width="100%">
+
+ </td>
+ <td>
+ <img src="icons/separator.gif" width="1" height="15" alt="" border="0"><br>
+ </td>
+ <td class="calendar_toolfooter calendar_btn">
+ <div class="footer_btn" onmouseover="this.className='footer_btn_over'" onmouseout="this.className='footer_btn'" onmousedown="this.className='footer_btn_press'">
+ Today
+ </div>
+ </td>
+ <td>
+ <img src="icons/separator.gif" width="1" height="15" alt="" border="0"><br>
+ </td>
+ <td class="calendar_toolfooter calendar_btn">
+ <div class="footer_btn" onmouseover="this.className='footer_btn_over'" onmouseout="this.className='footer_btn'" onmousedown="this.className='footer_btn_press'">
+ Apply
+ </div>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+
+
+</table>
+
+</div>
+
+
+
+
+
+
+</body>
+</html>
Added: branches/3.1.x/ui/calendar/design/calendar/icons/close.gif
===================================================================
(Binary files differ)
Property changes on: branches/3.1.x/ui/calendar/design/calendar/icons/close.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/3.1.x/ui/calendar/design/calendar/icons/separator.gif
===================================================================
(Binary files differ)
Property changes on: branches/3.1.x/ui/calendar/design/calendar/icons/separator.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/3.1.x/ui/calendar/design/calendar/icons/spacer.gif
===================================================================
(Binary files differ)
Property changes on: branches/3.1.x/ui/calendar/design/calendar/icons/spacer.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/3.1.x/ui/calendar/pom.xml
===================================================================
--- branches/3.1.x/ui/calendar/pom.xml 2007-12-04 18:39:29 UTC (rev 4470)
+++ branches/3.1.x/ui/calendar/pom.xml 2007-12-04 18:51:39 UTC (rev 4471)
@@ -47,5 +47,12 @@
<artifactId>richfaces-impl</artifactId>
<version>3.1.3-SNAPSHOT</version>
</dependency>
+
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>inputnumber-spinner</artifactId>
+ <version>3.1.3-SNAPSHOT</version>
+ </dependency>
+
</dependencies>
</project>
\ No newline at end of file
Modified: branches/3.1.x/ui/calendar/src/main/config/component/calendar.xml
===================================================================
--- branches/3.1.x/ui/calendar/src/main/config/component/calendar.xml 2007-12-04 18:39:29 UTC (rev 4470)
+++ branches/3.1.x/ui/calendar/src/main/config/component/calendar.xml 2007-12-04 18:51:39 UTC (rev 4471)
@@ -51,18 +51,6 @@
&ajax_component_attributes;
&ui_input_attributes;
&ui_output_attributes;
- <property>
- <name>width</name>
- <classname>java.lang.String</classname>
- <description>Defines a width of the calendar</description>
- <defaultvalue>"400px;"</defaultvalue>
- </property>
- <property>
- <name>height</name>
- <classname>java.lang.String</classname>
- <description>Defines a height of the calendar</description>
- <defaultvalue>"250px"</defaultvalue>
- </property>
<property elonly="true">
<name>dataModel</name>
<classname>org.richfaces.model.CalendarDataModel</classname>
@@ -403,10 +391,6 @@
<classname>boolean</classname>
<description>valid</description>
</property>
- <property hidden="true">
- <name>valid</name>
- <description>valid</description>
- </property>
<property>
<name>ajaxSingle</name>
@@ -476,7 +460,80 @@
</description>
<defaultvalue>0</defaultvalue>
</property>
-
+
+ <property>
+ <name>cellWidth</name>
+ <classname>java.lang.String</classname>
+ <description>
+ attribute to set fixed cells width
+ </description>
+ </property>
+
+ <property>
+ <name>cellHeight</name>
+ <classname>java.lang.String</classname>
+ <description>
+ attribute to set fixed cells height
+ </description>
+ </property>
+
+ <property>
+ <name>dayStyleClass</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Should be binded to some JS function that will provide style classes
+ for special sets of days highlighting.
+ </description>
+ </property>
+
+ <property>
+ <name>isDayEnabled</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Should be binded to some JS function that returns day state.
+ </description>
+ </property>
+ <property>
+ <name>showWeekDaysBar</name>
+ <classname>boolean</classname>
+ <description>
+ If false this bar should not be shown
+ </description>
+ <defaultvalue>true</defaultvalue>
+ </property>
+ <property>
+ <name>showWeeksBar</name>
+ <classname>boolean</classname>
+ <description>
+ If false this bar should not be shown
+ </description>
+ <defaultvalue>true</defaultvalue>
+ </property>
+ <property>
+ <name>showScrollerBar</name>
+ <classname>boolean</classname>
+ <description>
+ If false this bar should not be shown
+ </description>
+ <defaultvalue>true</defaultvalue>
+ </property>
+ <property>
+ <name>todayControlMode</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Possible values are "scroll", "select", "hidden"
+ </description>
+ <defaultvalue>"select"</defaultvalue>
+ </property>
+ <property>
+ <name>showApplyButton</name>
+ <classname>boolean</classname>
+ <description>
+ If false ApplyButton should not be shown
+ </description>
+ <defaultvalue>false</defaultvalue>
+ </property>
+
</component>
&listeners;
</components>
Modified: branches/3.1.x/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
===================================================================
--- branches/3.1.x/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-12-04 18:39:29 UTC (rev 4470)
+++ branches/3.1.x/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-12-04 18:51:39 UTC (rev 4471)
@@ -163,7 +163,43 @@
public abstract void setHorizontalOffset(int horizontalOffset);
+ public abstract String getDayStyleClass();
+ public abstract void setDayStyleClass(String DayStyleClass);
+
+ public abstract String getIsDayEnabled();
+
+ public abstract void setIsDayEnabled(String isDayEnabled);
+
+ public abstract String getCellHeight();
+
+ public abstract void setCellHeight(String cellHeight);
+
+ public abstract String getCellWidth();
+
+ public abstract void setCellWidth(String cellWidth);
+
+ public abstract boolean isShowWeekDaysBar();
+
+ public abstract void setShowWeekDaysBar(boolean showWeekDaysBar);
+
+ public abstract boolean isShowWeeksBar();
+
+ public abstract void setShowWeeksBar(boolean showWeeksBar);
+
+ public abstract boolean isShowScrollerBar();
+
+ public abstract void setShowScrollerBar(boolean showScrollerBar);
+
+ public abstract String getTodayControlMode();
+
+ public abstract void setTodayControlMode(String todayControlMode);
+
+ public abstract boolean isShowApplyButton();
+
+ public abstract void setShowApplyButton(boolean showApplyButton);
+
+
// TODO onclick add users onclick
// currentDate processing -------------------------------------------------
Modified: branches/3.1.x/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
--- branches/3.1.x/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-12-04 18:39:29 UTC (rev 4470)
+++ branches/3.1.x/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-12-04 18:51:39 UTC (rev 4471)
@@ -21,7 +21,8 @@
package org.richfaces.renderkit;
-import java.awt.Component;
+
+
import java.io.IOException;
import java.text.DateFormatSymbols;
import java.util.Calendar;
@@ -34,26 +35,22 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.DateTimeConverter;
import javax.faces.event.PhaseId;
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.event.AjaxEvent;
-import org.ajax4jsf.event.AjaxSingleEvent;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.util.SelectUtils;
-import org.richfaces.event.CurrentDateChangeEvent;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.richfaces.component.UICalendar;
import org.richfaces.component.util.ComponentUtil;
-import org.ajax4jsf.event.AjaxSingleEvent;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.richfaces.event.CurrentDateChangeEvent;
/**
* @author Nick Belaevski - mailto:nbelaevski at exadel.com created 08.06.2007
@@ -155,18 +152,114 @@
}
+ public void writeClass(FacesContext context, UIComponent component)
+ throws IOException {
+
+ UICalendar calendar = (UICalendar) component;
+ String styleClass = (String) calendar.getAttributes().get("styleClass");
+ if (styleClass != null && styleClass.length() != 0) {
+ ResponseWriter writer = context.getResponseWriter();
+ writer.writeText(",\n className: " + styleClass, null);
+ }
+ }
+
+ public void writeDayStyleClass(FacesContext context, UIComponent component)
+ throws IOException {
+
+ UICalendar calendar = (UICalendar) component;
+ String dayStyleClass = (String) calendar.getAttributes().get(
+ "dayStyleClass");
+ if (dayStyleClass != null && dayStyleClass.length() != 0) {
+ ResponseWriter writer = context.getResponseWriter();
+ writer.writeText(",\n dayStyleClass: " + dayStyleClass, null);
+ }
+
+ }
+
+ public void writeIsDayEnabled(FacesContext context, UIComponent component)
+ throws IOException {
+ UICalendar calendar = (UICalendar) component;
+ String isDayEnabled = (String) calendar.getAttributes().get(
+ "isDayEnabled");
+ if (isDayEnabled != null && isDayEnabled.length() != 0) {
+ ResponseWriter writer = context.getResponseWriter();
+ writer.writeText(",\n isDayEnabled: " + isDayEnabled, null);
+ }
+ }
+
public void writeMarkupScriptBody(FacesContext context,
UIComponent component, boolean children) throws IOException {
writeScriptBody(context, component, children);
}
+ public void writeOptionalFacetMarkupScriptBody(FacesContext context,
+ UIComponent component, String facetName) throws IOException {
+
+ UIComponent facet = component.getFacet(facetName);
+ if (facet != null && facet.isRendered()) {
+ ResponseWriter writer = context.getResponseWriter();
+ writer.writeText(",\n " + facetName + MARKUP_SUFFIX + ": "
+ + "[new E('b',{},", null);
+ writeMarkupScriptBody(context, facet, false);
+ writer.writeText(")]", null);
+ }
+ }
+
+ public void dayCellClass(FacesContext context, UIComponent component)
+ throws IOException {
+ // if cellWidth/Height is set send dayCellClass to script
+ String cellwidth = (String) component.getAttributes().get("cellWidth");
+ String cellheight = (String) component.getAttributes()
+ .get("cellHeight");
+ ResponseWriter writer = context.getResponseWriter();
+ String clientId = component.getClientId(context);
+ String divStyle = "";
+ if (cellwidth != null && cellwidth.length() != 0) {
+ if (cellwidth.contains("px") || cellwidth.contains("%")) {
+ divStyle = divStyle + "width:" + cellwidth + ";";
+ } else {
+ divStyle = divStyle + "width:" + cellwidth + "px;";
+ }
+ }
+ if (cellheight != null && cellheight.length() != 0) {
+ if (cellheight.contains("px") || cellheight.contains("%")) {
+ divStyle = divStyle + "height:" + cellheight.toString() + ";";
+ } else {
+ divStyle = divStyle + "height:" + cellheight.toString() + "px;";
+ }
+ }
+
+ if (divStyle.length() != 0) {
+ writer.startElement("style", component);
+ getUtils().writeAttribute(writer, "type", "text/css");
+ writer.writeText("." + clientId.replace(':', '_') + "DayCell{"
+ + divStyle + "}", null);
+ writer.endElement("style");
+ }
+ }
+
+ public void writeDayCellClass(FacesContext context, UIComponent component)
+ throws IOException {
+
+ String cellwidth = (String) component.getAttributes().get("cellWidth");
+ String cellheight = (String) component.getAttributes()
+ .get("cellHeight");
+ ResponseWriter writer = context.getResponseWriter();
+ if (cellwidth != null && cellwidth.length() != 0 || cellheight != null
+ && cellheight.length() != 0) {
+ String clientId = component.getClientId(context);
+ writer.writeText(",\n dayCellClass: '" + clientId.replace(':', '_')
+ + "DayCell'", null);
+ }
+ }
+
public void writeFacetMarkupScriptBody(FacesContext context,
UIComponent component, String facetName) throws IOException {
UIComponent facet = component.getFacet(facetName);
if (facet != null && facet.isRendered()) {
ResponseWriter writer = context.getResponseWriter();
- writer.writeText(", " + facetName + MARKUP_SUFFIX + ": ", null);
+ writer.writeText(",\n " + facetName + MARKUP_SUFFIX + ": ", null);
writeMarkupScriptBody(context, facet, false);
}
}
@@ -236,9 +329,8 @@
public String getInputValue(FacesContext context, UIComponent component) {
UICalendar input = (UICalendar) component;
// XXX nick - nick - can contain either Date or String instance
-
+ //Fix for myFaces 1.1.x RF-997
Date value = null;
- //Fix for myfaces-1.1.x (RF-997.)
try {
value = input.getAsDate(input.getSubmittedValue());
} catch (Exception e) {
@@ -266,6 +358,7 @@
ResponseWriter writer = facesContext.getResponseWriter();
Map symbolsMap = getSymbolsMap(facesContext, calendar);
Iterator entryIterator = symbolsMap.entrySet().iterator();
+ writer.writeText(", \n", null);
while (entryIterator.hasNext()) {
Map.Entry entry = (Map.Entry) entryIterator.next();
@@ -274,7 +367,7 @@
writer.writeText(ScriptUtils.toScript(entry.getValue()), null);
if (entryIterator.hasNext()) {
- writer.writeText(", ", null);
+ writer.writeText(", \n", null);
}
}
}
@@ -361,7 +454,7 @@
public String getSelectedDate(FacesContext context, UICalendar calendar)
throws IOException {
- //Fix for myFaces 1.1.x RF-997
+ //Fix for myFaces 1.1.x RF-997
Date date;
if(calendar.isValid()){
Date submittedValue = calendar.getAsDate(calendar.getSubmittedValue());
@@ -374,9 +467,10 @@
date = calendar.getAsDate(calendar.getValue());
//Date submittedValue = null;
}
-
+
if (date != null) {
- return ScriptUtils.toScript(formatDate(date));
+ return ScriptUtils.toScript(formatSelectedDate(date));
+ //TODO KAA Add ServerTime Processing;
}
return ScriptUtils.toScript(null);
@@ -392,5 +486,17 @@
return result;
}
-
+
+ public static Object formatSelectedDate(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)));
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.HOUR_OF_DAY)));
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.MINUTE)));
+ result.addParameter(new Integer(0));
+ return result;
+ }
}
Added: branches/3.1.x/ui/calendar/src/main/java/org/richfaces/renderkit/html/iconimages/CalendarSeparator.java
===================================================================
--- branches/3.1.x/ui/calendar/src/main/java/org/richfaces/renderkit/html/iconimages/CalendarSeparator.java (rev 0)
+++ branches/3.1.x/ui/calendar/src/main/java/org/richfaces/renderkit/html/iconimages/CalendarSeparator.java 2007-12-04 18:51:39 UTC (rev 4471)
@@ -0,0 +1,117 @@
+/**
+ * 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.html.iconimages;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.util.Date;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.GifRenderer;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.util.HtmlColor;
+import org.ajax4jsf.util.Zipper2;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author Siarhej Chalipau
+ *
+ */
+public class CalendarSeparator extends Java2Dresource {
+ private final static Dimension DIMENSIONS = new Dimension(1, 15);
+ private final static String COLOR_SKIN_PARAM = "headerTextColor";
+ private final static String DEFAULT_HTML_COLOR = "#FFFFFF";
+
+ public CalendarSeparator() {
+ setRenderer(new GifRenderer());
+ setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
+ }
+
+ public Dimension getDimensions(FacesContext facesContext, Object data) {
+ return DIMENSIONS;
+ }
+
+ protected Dimension getDimensions(ResourceContext resourceContext) {
+ return DIMENSIONS;
+ }
+
+ protected Object getDataToStore(FacesContext context, Object data) {
+ Skin skin = SkinFactory.getInstance().getSkin(context);
+ Skin defaultSkin = SkinFactory.getInstance().getDefaultSkin(context);
+
+ byte [] ret = new byte[3];
+ Color color = null;
+ Zipper2 zipper = new Zipper2(ret);
+
+ String htmlColor = (String) skin.getParameter(context, COLOR_SKIN_PARAM);
+ if (null == htmlColor || "".equals(htmlColor))
+ htmlColor = (String) defaultSkin.getParameter(context, COLOR_SKIN_PARAM);
+
+ if (htmlColor == null) {
+ htmlColor = DEFAULT_HTML_COLOR;
+ }
+
+ color = HtmlColor.decode(htmlColor);
+
+ zipper.addColor(color);
+
+ return ret;
+ }
+
+ protected void paint(ResourceContext context, Graphics2D g2d) {
+ Color color = (Color)restoreData(context);
+
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
+ g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
+ g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
+ g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+
+ g2d.setColor(color);
+ //TODO hans, need to be optimized
+ for (int i = 0;i < DIMENSIONS.getHeight(); i += 2 ) {
+ g2d.drawLine(0, i, 0, i);
+ }
+ }
+
+ protected Object deserializeData(byte[] objectArray) {
+ if (objectArray == null) {
+ return null;
+ }
+
+ Zipper2 zipper = new Zipper2(objectArray);
+
+ return zipper.nextColor();
+ }
+
+ public boolean isCacheable() {
+ return true;
+ }
+}
Modified: branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss
===================================================================
--- branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss 2007-12-04 18:39:29 UTC (rev 4470)
+++ branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss 2007-12-04 18:51:39 UTC (rev 4471)
@@ -3,6 +3,7 @@
xmlns:u='http:/jsf.exadel.com/template/util'
xmlns="http://www.w3.org/1999/xhtml" >
<f:verbatim><![CDATA[
+
.rich-calendar-exterior{
border : 1px solid;
}
@@ -20,11 +21,15 @@
border-bottom : 1px solid;
}
-.rich-cell-size{
+.rich-calendar-cell-size{
width : 25px;
height : 22px;
}
+.rich-calendar-cell-div{
+ overflow: hidden;
+}
+
.rich-calendar-cell{
border-bottom : 1px solid;
border-right : 1px solid;
@@ -36,7 +41,7 @@
.rich-calendar-tool{
vertical-align : middle;
text-align : center;
- width : 25px;
+ width : 20px;
height : 22px;
}
@@ -70,9 +75,8 @@
}
.rich-calendar-toolfooter{
-
- padding : 0px 7px 0px 7px;
height : 22px;
+ padding : 1px 2px 1px 1px;
}
.rich-calendar-footer-optional{
@@ -85,7 +89,28 @@
border-top : 1px solid;
border-right : 0px solid;
}
- ]]>
+
+.rich-calendar-spinner-input {
+ border: 0px;
+ padding: 0px 0px 0px 3px;
+ background: none transparent scroll repeat 0% 0%;
+}
+
+.rich-calendar-spinner-input-container {
+ background-position: left top;
+ background-repeat: repeat-x;
+ border: 1px solid;
+}
+
+.rich-calendar-spinner-buttons {
+ border-width: 1px;
+ border-style: solid;
+ background-position: left top;
+ background-repeat: repeat-x;
+ font-size: 0px;
+}
+
+]]>
</f:verbatim>
<u:selector name=".rich-calendar-exterior">
@@ -132,6 +157,7 @@
<u:style name="font-family" skin="headerFamilyFont"/>
<u:style name="font-weight" skin="headerWeightFont"/>
<u:style name="color" skin="headerTextColor"/>
+ <u:style name="white-space" value="nowrap"/>
</u:selector>
<u:selector name=".rich-calendar-days">
@@ -189,8 +215,34 @@
<u:style name="background" skin="additionalBackgroundColor"/>
<u:style name="font-size" skin="generalSizeFont"/>
<u:style name="font-family" skin="generalFamilyFont"/>
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.iconimages.CalendarSeparator" />
+ </u:style>
+ <u:style name="background-repeat" value="no-repeat" />
+ <u:style name="background-position" value="right center" />
</u:selector>
+
+ <u:selector name=".rich-calendar-tool-btn">
+ <u:style name="cursor" value="pointer"/>
+ <u:style name="padding" value="2px 3px 2px 3px"/>
+ <u:style name="white-space" value="nowrap"/>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-tool-btn-hover">
+ <u:style name="background" skin="calendarWeekBackgroundColor"/>
+ <u:style name="border" value="1px solid"/>
+ <u:style name="border-color" skin="tableBackgroundColor"/>
+ <u:style name="border-right-color" skin="panelBorderColor"/>
+ <u:style name="border-bottom-color" skin="panelBorderColor"/>
+ <u:style name="padding" value="1px 2px 1px 2px"/>
+ </u:selector>
+ <u:selector name=".rich-calendar-tool-btn-press">
+ <u:style name="border-color" skin="panelBorderColor"/>
+ <u:style name="border-right-color" skin="tableBackgroundColor"/>
+ <u:style name="border-bottom-color" skin="tableBackgroundColor"/>
+ </u:selector>
+
<u:selector name=".rich-calendar-footer-optional">
<u:style name="border-top-color" skin="panelBorderColor"/>
<u:style name="border-right-color" skin="panelBorderColor"/>
@@ -206,11 +258,135 @@
<u:style name="font-size" skin="generalSizeFont"/>
<u:style name="font-family" skin="generalFamilyFont"/>
</u:selector>
-
+
+ <u:selector name=".rich-calendar-tool-close">
+ <u:style name="padding" value="2px 2px 2px 4px"/>
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.iconimages.CalendarSeparator" />
+ </u:style>
+ <u:style name="background-repeat" value="no-repeat" />
+ <u:style name="background-position" value="left center" />
+ </u:selector>
+
<u:selector name=".rich-calendar-button">
<u:style name="cursor" value="pointer"/>
<u:style name="vertical-align" value="middle"/>
</u:selector>
-}
-
+
+ <u:selector name=".rich-calendar-time-shadow">
+ <u:style name="background" skin="tableBackgroundColor"/>
+ <u:style name="opacity" value="0.5"/>
+ <u:style name="filter" value="alpha(opacity=50)"/>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-time-layout">
+ <u:style name="background" skin="additionalBackgroundColor"/>
+ <u:style name="border" value="1px solid"/>
+ <u:style name="border-color" skin="panelBorderColor"/>
+ <u:style name="position" value="relative"/>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-time-layout-container">
+ </u:selector>
+
+ <u:selector name=".rich-calendar-time-layout, .rich-calendar-time-layout input">
+ <u:style name="font-size" skin="generalSizeFont"/>
+ <u:style name="font-family" skin="generalFamilyFont"/>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-time-layout-fields">
+ <u:style name="padding" value="7px 7px 5px 7px"/>
+ <u:style name="white-space" value="nowrap"/>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-time-layout-cancel">
+ <u:style name="padding" value="0px 7px 7px 1px"/>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-time-layout-ok">
+ <u:style name="padding" value="0px 1px 7px 7px"/>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-time-btn">
+ <u:style name="width" value="45px"/>
+ <u:style name="border" value="1px solid"/>
+ <u:style name="border-color" skin="tableBackgroundColor"/>
+ <u:style name="border-right-color" skin="panelBorderColor"/>
+ <u:style name="border-bottom-color" skin="panelBorderColor"/>
+ <u:style name="text-align" value="center"/>
+ <u:style name="padding" value="2px"/>
+ <u:style name="white-space" value="nowrap"/>
+ <u:style name="text-align" value="center"/>
+ <u:style name="cursor" value="pointer"/>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-time-btn-press">
+ <u:style name="border" value="1px solid"/>
+ <u:style name="border-color" skin="panelBorderColor"/>
+ <u:style name="border-right-color" skin="tableBackgroundColor"/>
+ <u:style name="border-bottom-color" skin="tableBackgroundColor"/>
+ <u:style name="background-color" skin="calendarWeekBackgroundColor"/>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-time-input">
+ <u:style name="width" value="22px"/>
+ <u:style name="margin" value="0px 2px"/>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-spinner-up">
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.images.buttons.SpinnerButtonUp" />
+ </u:style>
+
+ <u:style name="height" value="7px" />
+ <u:style name="width" value="14px" />
+ <u:style name="margin" value="0px 1px 1px 0px" />
+ </u:selector>
+
+ <u:selector name=".rich-calendar-spinner-down">
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.images.buttons.SpinnerButtonDown" />
+ </u:style>
+
+ <u:style name="height" value="7px"/>
+ <u:style name="width" value="14px"/>
+ <u:style name="margin" value="0px 1px 1px 0px" />
+ </u:selector>
+
+ <u:selector name=".rich-calendar-spinner-pressed">
+ <u:style name="margin" value="1px 0px 0px 1px" />
+ </u:selector>
+
+ <u:selector name=".rich-calendar-spinner-buttons">
+ <u:style name="background-color" skin="headerBackgroundColor" />
+ <u:style name="border-color" skin="headerBackgroundColor" />
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.images.background.SpinnerButtonGradient" />
+ </u:style>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-spinner-input">
+ <u:style name="font-size" skin="buttonSizeFont"/>
+ <u:style name="font-family" skin="buttonFamilyFont"/>
+
+ <u:style name="width" value="18px"/>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-spinner-input-container">
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.images.background.SpinnerFieldGradient" />
+ </u:style>
+ <u:style name="background-color" skin="controlBackgroundColor" />
+ <u:style name="border-color" skin="panelBorderColor" />
+ <u:style name="border-bottom-color" skin="subBorderColor" />
+ <u:style name="border-right-color" skin="subBorderColor" />
+ </u:selector>
+
+ <u:selector name=".rich-calendar-time-layout-shadow">
+ <u:style name="background-color" skin="shadowBackgroundColor" />
+ <u:style name="opacity" value="0.3" />
+ <u:style name="filter" value="alpha(opacity=30)"/>
+ <u:style name="position" value="absolute"/>
+ </u:selector>
+
</f:template>
Added: branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/JQuerySpinBtn.js
===================================================================
--- branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/JQuerySpinBtn.js (rev 0)
+++ branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/JQuerySpinBtn.js 2007-12-04 18:51:39 UTC (rev 4471)
@@ -0,0 +1,270 @@
+/* SpinButton control
+ *
+ * Adds bells and whistles to any ordinary textbox to
+ * make it look and feel like a SpinButton Control.
+ *
+ * Originally written by George Adamson, Software Unity (george.jquery at softwareunity.com) August 2006.
+ * - Added min/max options
+ * - Added step size option
+ * - Added bigStep (page up/down) option
+ *
+ * Modifications made by Mark Gibson, (mgibson at designlinks.net) September 2006:
+ * - Converted to jQuery plugin
+ * - Allow limited or unlimited min/max values
+ * - Allow custom class names, and add class to input element
+ * - Removed global vars
+ * - Reset (to original or through config) when invalid value entered
+ * - Repeat whilst holding mouse button down (with initial pause, like keyboard repeat)
+ * - Support mouse wheel in Firefox
+ * - Fix double click in IE
+ * - Refactored some code and renamed some vars
+ *
+ * Tested in IE6, Opera9, Firefox 1.5
+ * v1.0 11 Aug 2006 - George Adamson - First release
+ * v1.1 Aug 2006 - George Adamson - Minor enhancements
+ * v1.2 27 Sep 2006 - Mark Gibson - Major enhancements
+ * v1.3a 28 Sep 2006 - George Adamson - Minor enhancements
+ * rf1.3a 15 Nov 2007 - Pavel Yaschenko - some changes
+
+ Sample usage:
+
+ // Create group of settings to initialise spinbutton(s). (Optional)
+ var myOptions = {
+ min: 0, // Set lower limit.
+ max: 100, // Set upper limit.
+ step: 1, // Set increment size.
+ spinClass: mySpinBtnClass, // CSS class to style the spinbutton. (Class also specifies url of the up/down button image.)
+ upClass: mySpinUpClass, // CSS class for style when mouse over up button.
+ downClass: mySpinDnClass // CSS class for style when mouse over down button.
+ }
+
+ $(document).ready(function(){
+
+ // Initialise INPUT element(s) as SpinButtons: (passing options if desired)
+ $("#myInputElement").SpinButton(myOptions);
+
+ });
+
+ */
+var sbjQuery = oldJQuery;
+sbjQuery.fn.SpinButton = function(cfg){
+ return this.each(function(){
+
+ // Apply specified options or defaults:
+ // (Ought to refactor this some day to use $.extend() instead)
+ this.spinCfg = {
+ //min: cfg && cfg.min ? Number(cfg.min) : null,
+ //max: cfg && cfg.max ? Number(cfg.max) : null,
+ min: cfg && !isNaN(parseFloat(cfg.min)) ? Number(cfg.min) : null, // Fixes bug with min:0
+ max: cfg && !isNaN(parseFloat(cfg.max)) ? Number(cfg.max) : null,
+ step: cfg && cfg.step ? Number(cfg.step) : 1,
+ page: cfg && cfg.page ? Number(cfg.page) : 10,
+ upClass: cfg && cfg.upClass ? cfg.upClass : 'up',
+ downClass: cfg && cfg.downClass ? cfg.downClass : 'down',
+ reset: cfg && cfg.reset ? cfg.reset : this.value,
+ delay: cfg && cfg.delay ? Number(cfg.delay) : 500,
+ interval: cfg && cfg.interval ? Number(cfg.interval) : 100,
+ _btn_width: 20,
+ _btn_height: 12,
+ _direction: null,
+ _delay: null,
+ _repeat: null,
+
+ digits: cfg && cfg.digits ? Number(cfg.digits) : 1
+ };
+
+ this.adjustValue = function(i){
+ var v = this.value.toLowerCase();
+ if (v=="am")
+ {
+ this.value="PM";
+ return;
+ }
+ else if (v=="pm") {
+ this.value="AM";
+ return;
+ }
+ v = (isNaN(this.value) ? this.spinCfg.reset : Number(this.value)) + Number(i);
+ if (this.spinCfg.min !== null) v = (v<this.spinCfg.min ? (this.spinCfg.max != null ? this.spinCfg.max : this.spinCfg.min) : v);
+ if (this.spinCfg.max !== null) v = (v>this.spinCfg.max ? (this.spinCfg.min != null ? this.spinCfg.min : this.spinCfg.max) : v);
+
+ var value = String(v);
+ while (value.length<this.spinCfg.digits) value="0"+value;
+
+ this.value = value;
+ };
+
+ sbjQuery(this)
+// .addClass(cfg && cfg.spinClass ? cfg.spinClass : 'spin-button')
+//
+// .mousemove(function(e){
+// // Determine which button mouse is over, or not (spin direction):
+// var x = e.pageX || e.x;
+// var y = e.pageY || e.y;
+// var el = e.target || e.srcElement;
+// var direction =
+// (x > coord(el,'offsetLeft') + el.offsetWidth - this.spinCfg._btn_width)
+// ? ((y < coord(el,'offsetTop') + this.spinCfg._btn_height) ? 1 : -1) : 0;
+//
+// if (direction !== this.spinCfg._direction) {
+// // Style up/down buttons:
+// switch(direction){
+// case 1: // Up arrow:
+// sbjQuery(this).removeClass(this.spinCfg.downClass).addClass(this.spinCfg.upClass);
+// break;
+// case -1: // Down arrow:
+// sbjQuery(this).removeClass(this.spinCfg.upClass).addClass(this.spinCfg.downClass);
+// break;
+// default: // Mouse is elsewhere in the textbox
+// sbjQuery(this).removeClass(this.spinCfg.upClass).removeClass(this.spinCfg.downClass);
+// }
+//
+// // Set spin direction:
+// this.spinCfg._direction = direction;
+// }
+// })
+//
+// .mouseout(function(){
+// // Reset up/down buttons to their normal appearance when mouse moves away:
+// sbjQuery(this).removeClass(this.spinCfg.upClass).removeClass(this.spinCfg.downClass);
+// this.spinCfg._direction = null;
+// })
+
+// .mousedown(function(e){
+// if (this.spinCfg._direction != 0) {
+// // Respond to click on one of the buttons:
+// var self = this;
+// var adjust = function() {
+// self.adjustValue(self.spinCfg._direction * self.spinCfg.step);
+// };
+//
+// adjust();
+//
+// // Initial delay before repeating adjustment
+// self.spinCfg._delay = window.setTimeout(function() {
+// adjust();
+// // Repeat adjust at regular intervals
+// self.spinCfg._repeat = window.setInterval(adjust, self.spinCfg.interval);
+// }, self.spinCfg.delay);
+// }
+// })
+//
+// .mouseup(function(e){
+// // Cancel repeating adjustment
+// window.clearInterval(this.spinCfg._repeat);
+// window.clearTimeout(this.spinCfg._delay);
+// })
+//
+// .dblclick(function(e) {
+// if (sbjQuery.browser.msie)
+// this.adjustValue(this.spinCfg._direction * this.spinCfg.step);
+// })
+
+ .keydown(function(e){
+ // Respond to up/down arrow keys.
+ switch(e.keyCode){
+ case 38: this.adjustValue(this.spinCfg.step); break; // Up
+ case 40: this.adjustValue(-this.spinCfg.step); break; // Down
+ case 33: this.adjustValue(this.spinCfg.page); break; // PageUp
+ case 34: this.adjustValue(-this.spinCfg.page); break; // PageDown
+ }
+ })
+
+ .bind("mousewheel", function(e){
+ // Respond to mouse wheel in IE. (It returns up/dn motion in multiples of 120)
+ if (e.wheelDelta >= 120)
+ this.adjustValue(this.spinCfg.step);
+ else if (e.wheelDelta <= -120)
+ this.adjustValue(-this.spinCfg.step);
+
+ e.preventDefault();
+ })
+
+ .change(function(e){
+ this.adjustValue(0);
+ });
+
+ var self = this;
+
+ var btnUp = $(this.id + 'BtnUp');
+ sbjQuery(btnUp)
+ .mousedown(function(e){
+ // Respond to click on one of the buttons:
+ var adjust = function() {
+ self.adjustValue(self.spinCfg.step);
+ };
+
+ adjust();
+
+ // Initial delay before repeating adjustment
+ self.spinCfg._delay = window.setTimeout(function() {
+ adjust();
+ // Repeat adjust at regular intervals
+ self.spinCfg._repeat = window.setInterval(adjust, self.spinCfg.interval);
+ }, self.spinCfg.delay);
+ })
+
+ .mouseup(function(e){
+ // Cancel repeating adjustment
+ window.clearInterval(self.spinCfg._repeat);
+ window.clearTimeout(self.spinCfg._delay);
+ })
+
+ .dblclick(function(e) {
+ if (sbjQuery.browser.msie)
+ self.adjustValue(self.spinCfg.step);
+ });
+
+ var btnDown = $(this.id + 'BtnDown');
+ sbjQuery(btnDown)
+ .mousedown(function(e){
+ // Respond to click on one of the buttons:
+ var adjust = function() {
+ self.adjustValue(-self.spinCfg.step);
+ };
+
+ adjust();
+
+ // Initial delay before repeating adjustment
+ self.spinCfg._delay = window.setTimeout(function() {
+ adjust();
+ // Repeat adjust at regular intervals
+ self.spinCfg._repeat = window.setInterval(adjust, self.spinCfg.interval);
+ }, self.spinCfg.delay);
+ })
+
+ .mouseup(function(e){
+ // Cancel repeating adjustment
+ window.clearInterval(self.spinCfg._repeat);
+ window.clearTimeout(self.spinCfg._delay);
+ })
+
+ .dblclick(function(e) {
+ if (sbjQuery.browser.msie)
+ self.adjustValue(-self.spinCfg.step);
+ });
+
+ if (this.addEventListener) {
+ // Respond to mouse wheel in Firefox
+ this.addEventListener('DOMMouseScroll', function(e) {
+ if (e.detail > 0)
+ this.adjustValue(-this.spinCfg.step);
+ else if (e.detail < 0)
+ this.adjustValue(this.spinCfg.step);
+
+ e.preventDefault();
+ }, false);
+ }
+ });
+
+ function coord(el,prop) {
+ var c = el[prop], b = document.body;
+
+ while ((el = el.offsetParent) && (el != b)) {
+ if (!sbjQuery.browser.msie || (el.currentStyle.position != 'relative'))
+ c += el[prop];
+ }
+
+ return c;
+ }
+};
Modified: branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
--- branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-12-04 18:39:29 UTC (rev 4470)
+++ branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-12-04 18:51:39 UTC (rev 4471)
@@ -133,8 +133,8 @@
els.position = originalPosition;
els.visibility = originalVisibility;
- element.style.left = ox + 'px';
- element.style.top = oy + 'px';
+ element.style.left = (ox + windowRect.left) + 'px';
+ element.style.top = (oy + windowRect.top) + 'px';
};
Richfaces.Calendar.getOffsetDimensions = function(element) {
@@ -254,80 +254,123 @@
* Date:
* d - 1-31
* dd+ - 01-31 */
-Object.extend(Date, {
- getDefaultMonthNames: function(shortNames)
- {
- return (shortNames
- ? ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
- : ['January','February','March','April','May','June','July','August','September','October','November','December']);
- },
+Richfaces.Calendar.getDefaultMonthNames = function(shortNames)
+{
+ return (shortNames
+ ? ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
+ : ['January','February','March','April','May','June','July','August','September','October','November','December']);
+};
+
+Richfaces.Calendar.parseDate = function(dateString, pattern, monthNames, monthNamesShort)
+{
+ if (!monthNames) monthNames = Richfaces.Calendar.getDefaultMonthNames();
+ if (!monthNamesShort) monthNamesShort = Richfaces.Calendar.getDefaultMonthNames(true);
- parseDate: function(dateString, pattern, monthNames, monthNamesShort)
+ var counter=1;
+ var y,m,d;
+ var a,h,min;
+ var shortLabel=false;
+
+ pattern = pattern.replace(/([.*+?^<>=!:${}()|[\]\/\\])/g, '\\$1');
+ pattern = pattern.replace(/(y+|M+|d+|a|H{1,2}|h{1,2}|m{2})/g,
+ function($1) {
+ switch ($1) {
+ case 'y' :
+ case 'yy' : y=counter; counter++; return '(\\d{2})';
+ case 'MM' : m=counter; counter++; return '(\\d{2})';
+ case 'M' : m=counter; counter++; return '(\\d{1,2})';
+ case 'd' : d=counter; counter++; return '(\\d{1,2})';
+ case 'MMM': m=counter; counter++; shortLabel=true; return '('+monthNamesShort.join('|')+')';
+ case 'a' : a=counter; counter++; return '(AM|am|PM|pm)?';
+ case 'HH' :
+ case 'hh' : h=counter; counter++; return '(\\d{2})?';
+ case 'H' :
+ case 'h' : h=counter; counter++; return '(\\d{1,2})?';
+ case 'mm' : min=counter; counter++; return '(\\d{2})?';
+ }
+ // y+,M+,d+
+ var ch = $1.charAt(0);
+ if (ch=='y') {y=counter; counter++; return '(\\d{4})'};
+ if (ch=='M') {m=counter; counter++; return '('+monthNames.join('|')+')'};
+ if (ch=='d') {d=counter; counter++; return '(\\d{2})'};
+ }
+ );
+
+ var re = new RegExp(pattern,'i');
+ var match = dateString.match(re);
+ if (match!=null)
{
- if (!monthNames) monthNames = Date.getDefaultMonthNames();
- if (!monthNamesShort) monthNamesShort = Date.getDefaultMonthNames(true);
-
- var counter=1;
- var y,m,d;
- var shortLabel=false;
-
- pattern = pattern.replace(/([.*+?^<>=!:${}()|[\]\/\\])/g, '\\$1');
- pattern = pattern.replace(/(y+|M+|d+)/g,
- function($1) {
- switch ($1) {
- case 'y' :
- case 'yy' : y=counter; counter++; return '(\\d{2})';
- case 'MM' : m=counter; counter++; return '(\\d{2})';
- case 'M' : m=counter; counter++; return '(\\d{1,2})';
- case 'd' : d=counter; counter++; return '(\\d{1,2})';
- case 'MMM': m=counter; counter++; shortLabel=true; return '('+monthNamesShort.join('|')+')';
- }
- // y+,M+,d+
- var ch = $1.charAt(0);
- if (ch=='y') {y=counter; counter++; return '(\\d{4})'};
- if (ch=='M') {m=counter; counter++; return '('+monthNames.join('|')+')'};
- if (ch=='d') {d=counter; counter++; return '(\\d{2})'};
+ var yy = parseInt(match[y],10); if (isNaN(yy)) return null; else if (yy<70) yy+=2000; else if (yy<100) yy+=1900;
+ var mm = parseInt(match[m],10); if (isNaN(mm)) mm = Richfaces.Calendar.getMonthByLabel(match[m], shortLabel ? monthNamesShort : monthNames); else if (--mm<0 || mm>11) return null;
+ var dd = parseInt(match[d],10); if (isNaN(dd) || dd<1 || dd>daysInMonth(yy, mm)) return null;
+
+ // time parsing
+ if (min!=undefined && h!=undefined)
+ {
+ var hh,mmin,aa;
+ mmin = parseInt(match[min],10); if (isNaN(mmin) || mmin<0 || mmin>59) return null;
+ hh = parseInt(match[h],10); if (isNaN(hh)) return null;
+ if (a!=undefined)
+ {
+ aa = match[a].toLowerCase();
+ if ((aa!='am' && aa!='pm') || hh<1 || hh>12) return null;
+ if (aa=='pm')
+ {
+ if (hh!=12) hh+=12;
+ } else if (hh==12) hh = 0;
}
- );
-
- var re = new RegExp(pattern,'i');
- var match = dateString.match(re);
- if (match!=null)
- {
- var yy = parseInt(match[y],10); if (isNaN(yy)) return null; else if (yy<70) yy+=2000; else if (yy<100) yy+=1900;
- var mm = parseInt(match[m],10); if (isNaN(mm)) mm = Richfaces.Calendar.getMonthByLabel(match[m], shortLabel ? monthNamesShort : monthNames); else if (--mm<0 || mm>11) return null;
- var dd = parseInt(match[d],10); if (isNaN(dd) || dd<1 || dd>daysInMonth(yy, mm)) return null;
- return new Date(yy, mm, dd);
+ else if (hh<0 || hh>23) return null;
+
+ return new Date(yy, mm, dd, hh, mmin, 0);
}
- return null;
+
+ return new Date(yy, mm, dd);
}
-});
-Object.extend(Date.prototype, {
-
- format : function(pattern, monthNames, monthNamesShort) {
- if (!monthNames) monthNames = Date.getDefaultMonthNames();
- if (!monthNamesShort) monthNamesShort = Date.getDefaultMonthNames(true);
- var d = this; var mm; var dd;
- return pattern.replace(/(y+|M+|d+)/g,
- function($1) {
- switch ($1) {
- case 'y':
- case 'yy': return str = d.getYear().toString().slice(-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;
+ return null;
+};
+
+Richfaces.Calendar.formatDate = function(date, pattern, monthNames, monthNamesShort) {
+ if (!monthNames) monthNames = Richfaces.Calendar.getDefaultMonthNames();
+ if (!monthNamesShort) monthNamesShort = Richfaces.Calendar.getDefaultMonthNames(true);
+ var mm; var dd; var hh;
+ var result = pattern.replace(/(^|[^\\yMdHhm])(y+|M+|d+|a|H{1,2}|h{1,2}|m{2})/g,
+ function($1,$2,$3) {
+ switch ($3) {
+ case 'y':
+ case 'yy': return $2+date.getYear().toString().slice(-2);
+ case 'M': return $2+(date.getMonth()+1);
+ case 'MM': return $2+((mm = date.getMonth()+1)<10 ? '0'+mm : mm);
+ case 'MMM': return $2+monthNamesShort[date.getMonth()];
+ case 'd': return $2+date.getDate();
+ case 'a' : return $2+(date.getHours()<12 ? 'AM' : 'PM');
+ case 'HH' : return $2+((hh = date.getHours())<10 ? '0'+hh : hh);
+ case 'H' : return $2+date.getHours();
+ case 'hh' : return $2+((hh = date.getHours())==0 ? '12' : (hh<10 ? '0'+hh : (hh>12 ? hh-12 : hh)));
+ case 'h' : return $2+((hh = date.getHours())==0 ? '12' : (hh>12 ? hh-12 : hh));
+ case 'mm' : return $2+((min = date.getMinutes())<10 ? '0'+min : min);
}
- );
- }
-});
+ // y+,M+,d+
+ var ch = $3.charAt(0);
+ if (ch=='y') return $2+date.getFullYear();
+ if (ch=='M') return $2+monthNames[date.getMonth()];
+ if (ch=='d') return $2+((dd = date.getDate())<10 ? '0'+dd : dd);
+ }
+ );
+ return Richfaces.Calendar.unescape(result);
+};
+Richfaces.Calendar.escape = function (str)
+{
+ return str.replace(/([yMdaHhm])/g,"\\$1");
+};
+
+Richfaces.Calendar.unescape = function (str)
+{
+ return str.replace(/\\([yMdaHhm])/g,"$1");
+};
+
+
+
function isLeapYear(year) {
return new Date(year, 1, 29).getDate()==29;
}
@@ -398,8 +441,8 @@
// headerMarkup
// footerMarkup
- // headerOptionalMarkup - user defined header (optional)
- // footerOptionalMarkup - user defined footer (optional)
+ // optionalHeaderMarkup - user defined header (optional)
+ // optionalFooterMarkup - user defined footer (optional)
// currentDate - date to show month (day not used) (mm/yyyy)
// selectedDate - selected date (mm/dd/yyyy)
@@ -409,6 +452,7 @@
// 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]
+ // showApplyButton
// POPUP description
// direction - [top-left, top-right, bottom-left, bottom-right, auto]
@@ -420,16 +464,43 @@
// "inactive" or undefined - no action (default)
// "scroll" - change current month
// "select" - change current month and select date
+ //
+ // todayControlMode - today control onclick action:
+ // "scroll"
+ // "select"
+ // "hidden"
+ // isDayEnabled - end-developer JS function
+ // dayStyleClass - end-developer JS function that provide style class for day's cells.
+ // dayCellClass - add div to day cell with class 'rich-calendar-cell-div' and add this class to TD if defined
+ // style - table style
+ // className - table class
+
+
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.datePattern) thisparams.datePattern = "MMM d, y";
+
+ this.showApplyButton = (!this.params.popup) ? false : this.params.showApplyButton;
+
+ if (this.params.showWeekDaysBar==undefined) this.params.showWeekDaysBar = true;
+ if (this.params.showWeeksBar==undefined) this.params.showWeeksBar = true;
+
+ if (!this.params.datePattern) this.params.datePattern = "MMM d, y";
+ // time
+ this.setTimeProperties();
+
// markups initialization
- if (!this.params.dayListMarkup) this.params.dayListMarkup = CalendarView.dayList;
+ if (!this.params.dayListMarkup)
+ {
+ this.params.dayListMarkup = CalendarView.dayList;
+ this.customDayListMarkup = false;
+ }
+ else
+ {
+ this.customDayListMarkup = true;
+ }
if (!this.params.weekNumberMarkup) this.params.weekNumberMarkup = CalendarView.weekNumber;
if (!this.params.weekDayMarkup) this.params.weekDayMarkup = CalendarView.weekDay;
if (!this.params.headerMarkup) this.params.headerMarkup = CalendarView.header;
@@ -443,11 +514,14 @@
this.selectedDate = this.params.selectedDate;
if (typeof this.params.boundaryDatesMode=="string") this.params.boundaryDatesMode = this.params.boundaryDatesMode.toLowerCase();
+ if (typeof this.params.todayControlMode=="string") this.todayControlMode = this.params.todayControlMode.toLowerCase();
+
+ //
+ if (typeof this.params.isDayEnabled != "function") this.params.isDayEnabled = function (context) {return true;};
+ if (typeof this.params.dayStyleClass != "function") this.params.dayStyleClass = function (context) {return "";};
this.todayDate = new Date();
- this.selectedDateElement;
-
this.firstWeekendDayNumber = 6-this.params.firstWeekDay;
this.secondWeekendDayNumber = (this.params.firstWeekDay>0 ? 7-this.params.firstWeekDay : 0);
@@ -460,6 +534,11 @@
this.POPUP_BUTTON_ID = this.id+'PopupButton';
this.INPUT_DATE_ID = this.id+'InputDate';
this.IFRAME_ID = this.id+'IFrame';
+ this.TIME_EDITOR_ID = this.id+'TimeEditor';
+ this.TIME_EDITOR_SHADOW_ID = this.id+'TimeEditorShadow';
+
+ this.TIME_EDITOR_LAYOUT_ID = this.id+'TimeEditorLayout';
+ this.TIME_EDITOR_LAYOUT_SHADOW_ID = this.id+'TimeEditorLayoutShadow';
//this.popupIntervalId=null;
@@ -469,38 +548,31 @@
this.days = [];
this.todayCellId = null;
this.todayCellColor = "";
+
+ this.selectedDateCellId = null;
+ this.selectedDateCellColor = "";
- var obj=$(id);
-
+ var popupStyles = "";
+ this.isVisible = true;
+ if (this.params.popup==true)
+ {
+ // popup mode initialisation
+ popupStyles = "display:none; position:absolute;"
+ this.isVisible = false;
+ }
+
var htmlTextHeader = (!this.params.popup ? '<input id="'+this.INPUT_DATE_ID+'" name="'+this.INPUT_DATE_ID+'" type="hidden" style="display:none" value="'+this.getSelectedDateString(this.params.datePattern)+'"/>\n' : '') +
- '<input id="'+this.id+'InputCurrentDate" name="'+this.id+'InputCurrentDate" type="hidden" style="display:none" value="'+this.getCurrentDate().format("MM/yyyy")+'"/>\n' +
- '<table border="0" cellpadding="0" cellspacing="0" class="rich-calendar-exterior"><tbody>\n';
+ '<input id="'+this.id+'InputCurrentDate" name="'+this.id+'InputCurrentDate" type="hidden" style="display:none" value="'+Richfaces.Calendar.formatDate(this.getCurrentDate(),"MM/yyyy")+'"/>\n' +
+ (this.params.popup && Richfaces.browser.isIE6 ? '<iframe src="javascript:\'\'" frameborder="0" scrolling="no" id="' + this.IFRAME_ID + '" style="display:none; position: absolute; width: 1px; height: 1px; background-color:white;">'+'</iframe>\n' : '' )+
+ '<table id="'+this.id+'" border="0" cellpadding="0" cellspacing="0" class="rich-calendar-exterior rich-calendar-popup'+(this.params.className ? ' '+this.params.className : '')+'" style="'+popupStyles+this.params.style+'"><tbody>\n';
var colspan = (this.params.showWeeksBar ? "8" : "7");
- var htmlHeaderOptional = (this.params.headerOptionalMarkup) ? '<tr><td class="rich-calendar-header-optional" colspan="'+colspan+'" id="'+this.id+'HeaderOptional"></td></tr>' : '';
- var htmlFooterOptional = (this.params.footerOptionalMarkup) ? '<tr><td class="rich-calendar-footer-optional" colspan="'+colspan+'" id="'+this.id+'FooterOptional"></td></tr>' : '';
+ var htmlHeaderOptional = (this.params.optionalHeaderMarkup) ? '<tr><td class="rich-calendar-header-optional" colspan="'+colspan+'" id="'+this.id+'HeaderOptional"></td></tr>' : '';
+ var htmlFooterOptional = (this.params.optionalFooterMarkup) ? '<tr><td class="rich-calendar-footer-optional" colspan="'+colspan+'" id="'+this.id+'FooterOptional"></td></tr>' : '';
var htmlControlsHeader = '<tr><td class="rich-calendar-header" colspan="'+colspan+'" id="'+this.id+'Header"></td></tr>';
var htmlControlsFooter = '<tr><td class="rich-calendar-footer" colspan="'+colspan+'" id="'+this.id+'Footer"></td></tr>';
var htmlTextFooter = '</tbody></table>\n'
var htmlTextIFrame = '';
- this.isVisible = true;
- if (this.params.popup==true)
- {
- // popup mode initialisation
- var e = $(this.id);
- if (e)
- {
- e.style.display='none';
- e.style.position = 'absolute';
- this.isVisible = false;
- if (Richfaces.browser.isIE6)
- {
- new Insertion.Before(obj,'<iframe src="javascript:\'\'" frameborder="0" scrolling="no" id="' + this.IFRAME_ID + '"' +
- 'style="display:none; position: absolute; width: 1px; height: 1px; background-color:white;">'+'</iframe>');
- }
- }
- }
-
// days bar creation
var styleClass;
var bottomStyleClass;
@@ -546,28 +618,196 @@
// day cells creation
for (var i=0;i<7;i++)
{
- styleClass = bottomStyleClass+"rich-cell-size rich-calendar-cell";
+ styleClass = bottomStyleClass+(!this.params.dayCellClass ? "rich-calendar-cell-size" : (!this.customDayListMarkup ? this.params.dayCellClass : ""))+" rich-calendar-cell";
if (i==this.firstWeekendDayNumber || i==this.secondWeekendDayNumber) styleClass+=" rich-calendar-holly";
if (i==6) styleClass+=" rich-right-cell";
- htmlTextWeek+='<td class="'+styleClass+'" id="'+this.DATE_ELEMENT_ID+p+'"></td>';
+ htmlTextWeek+='<td class="'+styleClass+'" id="'+this.DATE_ELEMENT_ID+p+'">'+(this.customDayListMarkup ? '<div class="rich-calendar-cell-div'+(this.params.dayCellClass ? ' '+this.params.dayCellClass : '')+'"></div>' : '')+'</td>';
p++;
}
htmlTextWeek+='</tr>';
}
+ //obj.innerHTML = htmlTextIFrame+htmlTextHeader+htmlHeaderOptional+htmlControlsHeader+htmlTextWeekDayBar+htmlTextWeek+htmlControlsFooter+htmlFooterOptional+htmlTextFooter;
+ var span=$(this.POPUP_ID);
+ new Insertion.After(span,htmlTextIFrame+htmlTextHeader+htmlHeaderOptional+htmlControlsHeader+htmlTextWeekDayBar+htmlTextWeek+htmlControlsFooter+htmlFooterOptional+htmlTextFooter);
// set content
+ var obj=$(id);
obj.component = this;
obj.richfacesComponent="richfaces:calendar";
- obj.innerHTML = htmlTextIFrame+htmlTextHeader+htmlHeaderOptional+htmlControlsHeader+htmlTextWeekDayBar+htmlTextWeek+htmlControlsFooter+htmlFooterOptional+htmlTextFooter;
if(this.params.submitFunction) this.submitFunction = this.params.submitFunction.bind(this);
this.prepareEvents();
+
+ // add onclick event handlers to input field and popup button
+ if (this.params.popup && !this.params.disabled)
+ {
+ var handler = new Function ('event', "$('"+this.id+"').component.doSwitch();").bindAsEventListener();
+ Event.observe(this.POPUP_BUTTON_ID, "click", handler, false);
+ if (!this.params.enableManualInput)
+ {
+ Event.observe(this.INPUT_DATE_ID, "click", handler, false);
+ }
+ }
+
},
+
+ updateTimeEditor: function()
+ {
+ var th=$(this.id+'TimeHours');
+ var ts=$(this.id+'TimeSign');
+ var tm=$(this.id+'TimeMinutes');
+
+ var h = this.selectedDate.getHours();
+ var m = this.selectedDate.getMinutes();
+ if (this.timeType==2)
+ {
+ var a = (h<12 ? 'AM' : 'PM');
+ ts.value = a;
+ h = (h==0 ? '12' : (h>12 ? h-12 : h));
+ }
+ th.value = (this.timeHoursDigits==2 && h<10 ? '0'+h : h);
+ tm.value = (m<10 ? '0'+m : m);
+ },
+
+ createTimeEditor: function(element)
+ {
+ var element = $(this.id);
+ var htmlBegin = '<div id="'+this.TIME_EDITOR_SHADOW_ID+'" class="rich-calendar-time-shadow" style="position:absolute; display:none;"></div><table border="0" cellpadding="0" cellspacing="0" id="'+this.TIME_EDITOR_ID+'" style="position:absolute; display:none;"><tbody><tr><td class="rich-calendar-time-layout-container" align="center"><div style="position:relative; width:100%">';
+ var htmlEndn = '</div></td></tr></tbody></table>';
+ new Insertion.After(element, htmlBegin+this.evaluateMarkup(CalendarView.timeEditor, this.calendarContext));
+ var te_shadow = $(this.TIME_EDITOR_SHADOW_ID);
+ var te = $(this.TIME_EDITOR_ID);
+ te.style.zIndex = te_shadow.style.zIndex = element.getStyle('z-index');
+
+ var th=$(this.id+'TimeHours');
+ var ts;
+ var tm=$(this.id+'TimeMinutes');
+ if (this.timeType==1)
+ {
+ sbjQuery(th).SpinButton({digits:this.timeHoursDigits,min:0,max:23});
+ }
+ else
+ {
+ sbjQuery(th).SpinButton({digits:this.timeHoursDigits,min:1,max:12});
+ ts=$(this.id+'TimeSign');
+ sbjQuery(ts).SpinButton({});
+ }
+ sbjQuery(tm).SpinButton({digits:2,min:0,max:59});
+
+ this.isTimeEditorCreated = true;
+ },
+ createSpinnerTable: function(id) {
+ return '<table cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
+ '<td class="rich-calendar-spinner-input-container">'+
+ '<input id="' + id + '" class="rich-calendar-spinner-input" type="text" />'+
+ '</td>'+
+ '<td class="rich-calendar-spinner-buttons">'+
+ '<table border="0" cellspacing="0" cellpadding="0"><tbody>'+
+ '<tr><td>'+
+ '<div id="'+id+'BtnUp" class="rich-calendar-spinner-up"'+
+ 'onmousedown="this.className=\'rich-calendar-spinner-up rich-calendar-spinner-pressed\'" '+
+ 'onmouseup="this.className=\'rich-calendar-spinner-up\'"'+
+ 'onmouseout="this.className=\'rich-calendar-spinner-up\'" />'+
+ '</td></tr>'+
+ '<tr><td>'+
+ '<div id="'+id+'BtnDown" class="rich-calendar-spinner-down"'+
+ 'onmousedown="this.className=\'rich-calendar-spinner-down rich-calendar-spinner-pressed\'" '+
+ 'onmouseup="this.className=\'rich-calendar-spinner-down\'"'+
+ 'onmouseout="this.className=\'rich-calendar-spinner-down\'" />'+
+ '</td></tr>'+
+ '</tbody></table>'+
+ '</td>'+
+ '</tr></tbody></table>';
+ },
+
+ setTimeProperties: function() {
+ this.timeType = 0;
+
+ var dateTimePattern = this.params.datePattern;
+ var pattern = [];
+ var re = /(^|[^\\yMdHhm])(y+|M+|d+|a|H{1,2}|h{1,2}|m{2})/g;
+ var r;
+ while (r = re.exec(dateTimePattern))
+ pattern.push({str:r[0],marker:r[2],pref:r[1],idx:r.index});
+
+ var datePattern = "";
+ var timePattern = "";
+
+ var digits,h,hh,m,a;
+ var id = this.id;
+
+ var getString = function (p) {
+ return (p.length==0 ? obj.marker : dateTimePattern.substring(pattern[i-1].str.length+pattern[i-1].idx, obj.idx+obj.str.length));
+ };
+
+ for (var i=0;i<pattern.length;i++)
+ {
+ var obj = pattern[i];
+ var ch = obj.marker.charAt(0);
+ if (ch=='y'||ch=='M'||ch=='d') datePattern+=getString(datePattern);
+ else if (ch=='a')
+ {
+ a=true;
+ timePattern+=getString(timePattern);
+ }
+ else if (ch=='H')
+ {
+ h=true;
+ digits=obj.marker.length;
+ timePattern+=getString(timePattern);
+ }
+ else if (ch=='h')
+ {
+ hh=true;
+ digits=obj.marker.length;
+ timePattern+=getString(timePattern);
+ }
+ else if (ch=='m')
+ {
+ m=true;
+ timePattern+=getString(timePattern);
+ }
+
+
+ }
+ this.datePattern = datePattern;
+ this.timePattern = timePattern;
+
+ var calendar = this;
+
+ this.timePatternHtml = timePattern.replace(/(^|[^\\Hhm])(H{1,2}|h{1,2}|m{2}|a)/g,
+ function($1,$2,$3) {
+ switch ($3) {
+ case 'a' : return ($2 ? '<td>'+$2+'</td>' : '')+'<td>'+calendar.createSpinnerTable(id+'TimeSign')+'</td>';//'<input class="rich-calendar-time-input" id="'+id+'TimeSign"/>';
+ case 'H' :
+ case 'HH' :
+ case 'h' :
+ case 'hh' : return ($2 ? '<td>'+$2+'</td>' : '')+'<td>'+calendar.createSpinnerTable(id+'TimeHours')+'</td>';//'<input class="rich-calendar-time-input" id="'+id+'TimeHours"/>';
+ case 'mm' : return ($2 ? '<td>'+$2+'</td>' : '')+'<td>'+calendar.createSpinnerTable(id+'TimeMinutes')+'</td>';//'<input class="rich-calendar-time-input" id="'+id+'TimeMinutes"/>';
+ }
+ }
+ );
+
+ this.timePatternHtml = '<table><tbody><tr>'+this.timePatternHtml+'</tr></tbody></table>';
+
+ if (m && h)
+ {
+ this.timeType = 1;
+ }
+ else if (m && hh && a)
+ {
+ this.timeType = 2;
+ }
+ this.timeHoursDigits = digits;
+ },
+
doCollapse: function() {
if (!this.params.popup || !this.isVisible) return;
+ if (this.isTimeEditorCreated) this.hideTimeEditor();
+
/*this.stopTimer();
this.stopPopupEvents($(this.id));
this.stopPopupEvents($(this.POPUP_ID));*/
@@ -578,9 +818,26 @@
{
Event.stopObserving(window.document, "click", this.eventOnCollapse, false);
- if (Richfaces.browser.isIE6) Element.hide(this.IFRAME_ID);
+ var iframe=null;
+ if (Richfaces.browser.isIE6) iframe = $(this.IFRAME_ID);
+ if (iframe) Element.hide(iframe);
+
Element.hide(element);
this.isVisible = false;
+
+ /*if (this.floatedToBody && this.parent)
+ {
+ if (iframe)
+ {
+ document.body.removeChild(iframe);
+ this.parent.appendChild(iframe);
+ }
+ document.body.removeChild(element);
+ this.parent.appendChild(element);
+ this.floatedToBody = false;
+ this.parent = null;
+ }*/
+
}
},
@@ -592,6 +849,17 @@
if (this.invokeEvent("expand", element))
{
+
+ var iframe=null;
+ if (Richfaces.browser.isIE6) iframe = $(this.IFRAME_ID);
+
+ /*if (!this.floatedToBody) {
+ this.parent = element.parentNode;
+ if (iframe) document.body.insertBefore(this.parent.removeChild(iframe), null);
+ document.body.insertBefore(this.parent.removeChild(element), null);
+ this.floatedToBody = true;
+ }*/
+
var base = $(this.POPUP_ID)
var baseInput = base.firstChild;
var baseButton = baseInput.nextSibling;
@@ -600,8 +868,6 @@
{
this.selectDate(baseInput.value);
}
-
- var iframe = $(this.IFRAME_ID);
/*this.setPopupEvents(e);
this.setPopupEvents(base);*/
@@ -621,14 +887,15 @@
var offsetDimBase = Richfaces.Calendar.getOffsetDimensions(base);
var offsetDimButton = Richfaces.Calendar.getOffsetDimensions(baseButton);
- var o = {left: offsetBase[0],
- top: offsetBase[1],
+ var offsetTemp = Position.realOffset(baseButton);
+ var o = {left: offsetBase[0]-offsetTemp[0],
+ top: offsetBase[1]-offsetTemp[1],
width: offsetDimBase.width,
height: (offsetDimInput && offsetDimInput.height>offsetDimButton.height ? offsetDimInput.height : offsetDimButton.height)};
Richfaces.Calendar.setElementPosition(element, o, this.params.jointPoint, this.params.direction, this.popupOffset);
- if (Richfaces.browser.isIE6)
+ if (iframe)
{
iframe.style.left = element.style.left;
iframe.style.top = element.style.top;
@@ -656,7 +923,7 @@
this.skipEventOnCollapse = false;
return true;
}
-
+
if (Event.element(e).id == this.POPUP_BUTTON_ID || (!this.params.enableManualInput && Event.element(e).id == this.INPUT_DATE_ID) ) return true;
Position.prepare();
@@ -675,7 +942,7 @@
getSelectedDateString: function(pattern) {
if (!this.selectedDate) return "";
if (!pattern) pattern = this.params.datePattern;
- return this.selectedDate.format(pattern, this.params.monthLabels, this.params.monthLabelsShort);
+ return Richfaces.Calendar.formatDate(this.selectedDate, pattern, this.params.monthLabels, this.params.monthLabelsShort);
},
getPrevYear: function() {
@@ -807,12 +1074,12 @@
if (obj)
{
var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
- if (daydata._month==0)
+ if (daydata.enabled && daydata._month==0)
{
var date=new Date(this.currentDate);
date.setDate(daydata.day);
- if (this.selectDate(date,true))
+ if (this.selectDate(date,true) && !this.showApplyButton)
{
this.doCollapse();
}
@@ -823,9 +1090,9 @@
else if (this.params.boundaryDatesMode == "select")
{
//var date = new Date(this.currentDate.getFullYear(), this.currentDate.getMonth()+daydata._month, daydata.day);
- if (this.selectDate(daydata.date))
+ if (this.selectDate(daydata.date) && !this.showApplyButton)
{
- this.doCollapse();
+ this.doCollapse();
}
}
}
@@ -838,7 +1105,7 @@
{
var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
//var date = new Date(this.currentDate.getFullYear(), this.currentDate.getMonth()+daydata._month, daydata.day);
- if (this.invokeEvent("datemouseover", obj, e, daydata.date))
+ if (this.invokeEvent("datemouseover", obj, e, daydata.date) && daydata.enabled)
{
if (daydata._month==0) Element.addClassName(obj,'rich-calendar-hover');
}
@@ -851,7 +1118,7 @@
{
var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
//var date = new Date(this.currentDate.getFullYear(), this.currentDate.getMonth()+daydata._month, daydata.day);
- if (this.invokeEvent("datemouseout", obj, e, daydata.date))
+ if (this.invokeEvent("datemouseout", obj, e, daydata.date) && daydata.enabled)
{
if (daydata._month==0) Element.removeClassName(obj,'rich-calendar-hover');
}
@@ -860,16 +1127,15 @@
load:function(daysData, isAjaxMode) {
// startDate,
- // days:array[]
+ // daysData:array[]
// {
- // data
- // enabled boolean or function
- // isEnabled function
+ // day
+ // enabled boolean
// text1: 'Meeting...',
// text2: 'Meeting...'
// tooltip
// hasTooltip
- // dayStyleClass
+ // styleClass
// }
if (!$(this.id).component) return;
@@ -881,6 +1147,12 @@
}
this.render();
+
+ if (typeof this.afterLoad=='function')
+ {
+ this.afterLoad();
+ this.afterLoad=null;
+ }
},
indexData:function(daysData, isAjaxMode) {
@@ -906,7 +1178,47 @@
return daysData;
},
+ getCellBackgroundColor: function(element)
+ {
+ var result;
+ if (Richfaces.browser.isSafari && this.params.popup && !this.isVisible)
+ {
+ // Safari 2.0 fix
+ // if [display:none] Element.getStyle() function returns null;
+ var els = $(this.id).style;
+ var originalVisibility = els.visibility;
+ var originalDisplay = els.display;
+ els.visibility = 'hidden';
+ els.display = '';
+ result = Element.getStyle(element, 'background-color').parseColor();
+ els.display = originalDisplay;
+ els.visibility = originalVisibility;
+ } else
+ {
+ result = Element.getStyle(element, 'background-color').parseColor();
+ }
+
+ return result;
+ },
+
+ clearEffect: function (element_id, effect, className)
+ {
+ if (effect)
+ {
+ effect.cancel();
+ effect=null;
+ }
+ if (element_id)
+ {
+ var e = $(element_id);
+ e.style['backgroundColor'] = '';
+ if (className) Element.removeClassName(e, className);
+ }
+ return null;
+ },
+
render:function() {
+
this.todayDate = new Date();
var currentYear = this.getCurrentYear();
@@ -979,8 +1291,7 @@
}
// render
- this.renderHeader();
- this.renderFooter();
+ this.renderHF();
this.renderHeaderOptional();
this.renderFooterOptional();
@@ -997,24 +1308,11 @@
var boundaryDatesModeFlag = (this.params.boundaryDatesMode == "scroll" || this.params.boundaryDatesMode == "select");
- if (this.highlightEffect)
- {
- this.highlightEffect.cancel();
- this.highlightEffect=null;
- }
- if (this.todayCellId)
- {
- $(this.todayCellId).style['backgroundColor'] = '';
- this.todayCellId = null;
- }
+ this.todayCellId = this.clearEffect(this.todayCellId, this.highlightEffect, "rich-calendar-today");
+ this.selectedDateCellId = this.clearEffect(this.selectedDateCellId, this.highlightEffect2, "rich-calendar-select");
//var _d=new Date();
- if (this.selectedDateElement) {
- Element.classNames(this.selectedDateElement).remove("rich-calendar-select");
- this.selectedDateElement = null;
- }
-
for (var k=1;k<7;k++)
{
//
@@ -1040,11 +1338,11 @@
element = element.nextSibling;
}
- var weekdaycounter = this.params.firstWeekDay;
+ var weekdaycounter = this.params.firstWeekDay;
+ var contentElement = null;
while (element)
{
- // TODO rich-calendar-spec class not implemented
// TODO fix start/stop event's calls
this.stopCellEvents(element);
@@ -1054,48 +1352,64 @@
dataobj.component = this;
dataobj.isCurrentMonth = (dataobj._month==0);
dataobj.weekDayNumber = weekdaycounter;
+
+ // call user function to get day state
+ if (dataobj.enabled != false) dataobj.enabled = this.params.isDayEnabled(dataobj);
+ // call user function to custom class style
+ if (!dataobj.styleClass) dataobj.customStyleClass = this.params.dayStyleClass(dataobj);
+ else
+ {
+ var styleclass = this.params.dayStyleClass(dataobj);
+ dataobj.customStyleClass = dataobj.styleClass
+ if (styleclass) dataobj.customStyleClass += " " + styleclass;
+ }
+
+ contentElement = (this.customDayListMarkup ? element.firstChild : element);
+ contentElement.innerHTML = this.evaluateMarkup(this.params.dayListMarkup, dataobj );
+
if (weekdaycounter==6) weekdaycounter=0; else weekdaycounter++;
- element.innerHTML = this.evaluateMarkup(this.params.dayListMarkup, dataobj );
// class styles
e = Element.classNames(element);
- if (dataobj._month!=0) { e.add('rich-calendar-boundary-dates'); if (boundaryDatesModeFlag) e.add('rich-calendar-btn'); else e.remove('rich-calendar-btn');}
+ // remove custom style class
+ if (element.rich && element.rich.customStyleClass)
+ {
+ element.rich.customStyleClass.split(' ').each(function(name){e.remove(name);});
+ element.rich.customStyleClass = null;
+ }
+
+ if (dataobj._month!=0)
+ {
+ e.add('rich-calendar-boundary-dates');
+ if (boundaryDatesModeFlag)
+ e.add('rich-calendar-btn');
+ else
+ e.remove('rich-calendar-btn');}
else
{
e.remove('rich-calendar-boundary-dates');
- e.add('rich-calendar-btn');
+ if (dataobj.enabled) e.add('rich-calendar-btn'); else e.remove('rich-calendar-btn');
+
+ // add custom style class
+ if (dataobj.customStyleClass)
+ {
+ e.add(dataobj.customStyleClass);
+ element.rich = {customStyleClass: dataobj.customStyleClass};
+ }
}
// TODO make some optimization with rich-calendar-today class
if (todayflag && dataobj._month==0 && dataobj.day==todaydate)
{
this.todayCellId = element.id;
-
- if (Richfaces.browser.isSafari && this.params.popup && !this.isVisible)
- {
- // Safari 2.0 fix
- // if [display:none] Element.getStyle() function returns null;
- var els = $(this.id).style;
- var originalVisibility = els.visibility;
- var originalDisplay = els.display;
- els.visibility = 'hidden';
- els.display = '';
- this.todayCellColor = Element.getStyle(element, 'background-color').parseColor();
- els.display = originalDisplay;
- els.visibility = originalVisibility;
- } else
- {
- this.todayCellColor = Element.getStyle(element, 'background-color').parseColor();
- }
+ this.todayCellColor = this.getCellBackgroundColor(element);
e.add("rich-calendar-today");
}
- else
+
+ if (selectedflag && dataobj._month==0 && dataobj.day==selecteddate)
{
- e.remove("rich-calendar-today");
- }
-
- if (selectedflag && dataobj._month==0 && dataobj.day==selecteddate) {
- this.selectedDateElement = element;
+ this.selectedDateCellId = element.id;
+ this.selectedDateCellColor = this.getCellBackgroundColor(element);
e.add("rich-calendar-select");
}
@@ -1106,10 +1420,11 @@
element=element.nextSibling;
}
}
+
//alert(new Date().getTime()-_d.getTime());
- // hack for IE 6.0 //fix 1072
- if (Richfaces.browser.isIE6)
+ // hack for IE 6.0 //fix 1072 // TODO check this bug again
+ /*if (Richfaces.browser.isIE6)
{
var element = $(this.id);
if (element)
@@ -1117,26 +1432,24 @@
element.style.width = "0px";
element.style.height = "0px";
}
- }
+ }*/
+
},
- renderHeader: function()
+
+ renderHF: function()
{
this.renderMarkup(this.params.headerMarkup, this.id+"Header", this.calendarContext);
- },
-
- renderFooter: function()
- {
this.renderMarkup(this.params.footerMarkup, this.id+"Footer", this.calendarContext);
},
renderHeaderOptional: function()
{
- this.renderMarkup(this.params.headerOptionalMarkup, this.id+"HeaderOptional", this.calendarContext);
+ this.renderMarkup(this.params.optionalHeaderMarkup, this.id+"HeaderOptional", this.calendarContext);
},
renderFooterOptional: function()
{
- this.renderMarkup(this.params.footerOptionalMarkup, this.id+"FooterOptional", this.calendarContext);
+ this.renderMarkup(this.params.optionalFooterMarkup, this.id+"FooterOptional", this.calendarContext);
},
renderMarkup: function (markup, elementId, context)
@@ -1157,7 +1470,7 @@
onUpdate: function()
{
- var formattedDate = this.getCurrentDate().format("MM/yyyy");
+ var formattedDate = Richfaces.Calendar.formatDate(this.getCurrentDate(),"MM/yyyy");
$(this.id+'InputCurrentDate').value=formattedDate;
if (this.submitFunction)
@@ -1192,12 +1505,14 @@
},
today: function(noUpdate, noHighlight) {
+
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() )
@@ -1205,28 +1520,52 @@
updateflag = true;
this.currentDate = new Date(nowyear, nowmonth, 1);
}
+
+ if (this.todayControlMode=='select')
+ {
+ noHighlight=true;
+ }
if (updateflag)
- {
+ {
if (noUpdate) this.render(); else this.onUpdate();
}
else
{
// highlight today
+
if (this.isVisible && this.todayCellId && !noHighlight)
{
- if (this.highlightEffect)
+ this.clearEffect(this.todayCellId, this.highlightEffect);
+ if (this.todayCellColor!="transparent")
{
- this.highlightEffect.cancel();
- this.highlightEffect=null;
+ this.highlightEffect = new Effect.Highlight($(this.todayCellId), {startcolor: this.todayCellColor, duration:0.3, transition: Effect.Transitions.sinoidal,
+ afterFinish: this.onHighlightFinish});
}
- var e = $(this.todayCellId);
- e.style['backgroundColor'] = '';
- this.highlightEffect = new Effect.Highlight(e, {startcolor: this.todayCellColor, duration:0.3, transition: Effect.Transitions.sinoidal,
- afterFinish: this.onHighlightFinish});
}
}
+
+ // todayControl select mode
+ if (this.todayControlMode=='select')
+ if (updateflag && !noUpdate && this.submitFunction)
+ {
+ this.afterLoad = this.selectToday;
+ }
+ else this.selectToday();
+
},
+
+ selectToday: function()
+ {
+ 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)
+ {
+ this.doCollapse();
+ }
+ }
+ },
onHighlightFinish: function (object)
{
@@ -1234,6 +1573,7 @@
},
selectDate: function(date, noUpdate, eventData) {
+
if (!eventData)
{
eventData = {event: null, element: null};
@@ -1241,16 +1581,21 @@
var oldSelectedDate = this.selectedDate;
var newSelectedDate;
+ var isDateParsed = false;
if (date)
{
- if (typeof date=='string') date = Date.parseDate(date,this.params.datePattern, this.params.monthLabels, this.params.monthLabelsShort);
+ if (typeof date=='string')
+ {
+ date = Richfaces.Calendar.parseDate(date,this.params.datePattern, this.params.monthLabels, this.params.monthLabelsShort);
+ if (date) isDateParsed = true;
+ }
newSelectedDate = date;
}
else
{
newSelectedDate = null;
}
-
+
// fire user event
var flag = true;
var isDateChanged = false;
@@ -1258,15 +1603,26 @@
{
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)
{
- field.value=this.getSelectedDateString(this.params.datePattern);
+ if (this.timeType && !isDateParsed)
+ if (oldSelectedDate!=null)
+ {
+ this.selectedDate.setHours(oldSelectedDate.getHours());
+ this.selectedDate.setMinutes(oldSelectedDate.getMinutes());
+ }
+ else
+ {
+ this.selectedDate.setHours(12);
+ }
+
+ 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())
@@ -1275,14 +1631,18 @@
{
// find cell and change style class
var e = $(this.DATE_ELEMENT_ID+(this.firstDateIndex + this.selectedDate.getDate()-1));
- if (this.selectedDateElement) Element.removeClassName(this.selectedDateElement, "rich-calendar-select");
- this.selectedDateElement = e;
+
+ this.clearEffect(this.selectedDateCellId, this.highlightEffect2, "rich-calendar-select");
+ this.selectedDateCellId = e.id;
+ this.selectedDateCellColor = this.getCellBackgroundColor(e);
Element.addClassName(e, "rich-calendar-select");
- this.renderHeader();
- this.renderFooter();
+ this.renderHF();
}
- } else {
+ else if (this.timeType!=0) this.renderHF();
+ }
+ else
+ {
// change currentDate and call this.onUpdate();
d.setDate(1);
this.currentDate = d;
@@ -1293,21 +1653,25 @@
{
this.selectedDate = null;
field.value = "";
- if (this.selectedDateElement)
+
+ this.clearEffect(this.selectedDateCellId, this.highlightEffect2, "rich-calendar-select");
+
+ if (this.selectedDateCellId)
{
- Element.removeClassName(this.selectedDateElement, "rich-calendar-select");
- this.selectedDateElement = null;
- this.renderHeader();
- this.renderFooter();
+ this.selectedDateCellId = null;
+ this.renderHF();
}
var date = new Date();
if (this.currentDate.getMonth()==date.getMonth() && this.currentDate.getFullYear()==date.getFullYear())
{
- this.renderHeader();
- this.renderFooter();
+ this.renderHF();
}
+
+ var todayControlMode = this.todayControlMode;
+ this.todayControlMode = '';
this.today(noUpdate, true);
+ this.todayControlMode = todayControlMode;
}
// call user event
@@ -1326,16 +1690,16 @@
if (this.invokeEvent("dateselect", null, null, null))
{
this.selectedDate = null;
- $(this.INPUT_DATE_ID).value = "";
- if (this.selectedDateElement)
+
+ this.selectedDateCellId = this.clearEffect(this.selectedDateCellId, this.highlightEffect2, "rich-calendar-select");
+
+ this.renderHF();
+ if (!this.showApplyButton)
{
- Element.removeClassName(this.selectedDateElement, "rich-calendar-select");
- this.selectedDateElement = null;
+ $(this.INPUT_DATE_ID).value = "";
+ this.doCollapse();
+ this.invokeEvent("dateselected", null, null, null);
}
- this.renderHeader();
- this.renderFooter();
- this.doCollapse();
- this.invokeEvent("dateselected", null, null, null);
}
},
@@ -1348,45 +1712,135 @@
this.currentDate.setDate(1);
this.onUpdate();
}
+ else
+ {
+ // highlight Selected Date
+ if (this.isVisible && this.selectedDateCellId)
+ {
+ this.clearEffect(this.selectedDateCellId, this.highlightEffect2);
+ if (this.selectedDateCellColor!="transparent")
+ {
+ this.highlightEffect2 = new Effect.Highlight($(this.selectedDateCellId), {startcolor: this.selectedDateCellColor, duration:0.3, transition: Effect.Transitions.sinoidal,
+ afterFinish: this.onHighlightFinish});
+ }
+ }
+ }
+ },
+
+ close: function(updateDate)
+ {
+ if (updateDate)
+ {
+ var field = $(this.INPUT_DATE_ID);
+ field.value=this.getSelectedDateString(this.params.datePattern);
+ }
+ this.doCollapse();
+ },
+
+ showTimeEditor: function()
+ {
+ if (this.timeType==0) return;
+ if (!this.isTimeEditorCreated) this.createTimeEditor();
+
+ var element = $(this.id);
+
+ var te = $(this.TIME_EDITOR_ID);
+ var te_shadow = $(this.TIME_EDITOR_SHADOW_ID);
+
+ /*var dim = Richfaces.Calendar.getOffsetDimensions(element);
+ te.style.width = te_shadow.style.width = dim.width + 'px';
+ te.style.height = te_shadow.style.height = dim.height + 'px';
+ te.style.left = te_shadow.style.left = element.style.left;
+ te.style.top = te_shadow.style.top = element.style.top;*/
+
+ Element.clonePosition(te, element);
+ Element.clonePosition(te_shadow, element);
+
+ this.updateTimeEditor();
+
+ te.show();
+ te_shadow.show();
+ Element.clonePosition(this.TIME_EDITOR_LAYOUT_SHADOW_ID, this.TIME_EDITOR_LAYOUT_ID, {offsetLeft: 3, offsetTop: 3});
+ },
+
+ hideTimeEditor: function(updateTime)
+ {
+ $(this.TIME_EDITOR_ID).hide();
+ $(this.TIME_EDITOR_SHADOW_ID).hide();
+
+ 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)
+ {
+ if ($(this.id+'TimeSign').value.toLowerCase()=="am")
+ {
+ if (h==12) h = 0;
+ }
+ else
+ {
+ if (h!=12) h+=12;
+ }
+ }
+ this.selectedDate.setHours(h);
+ this.renderHF();
+ }
+
+ if (this.params.popup && !this.showApplyButton && updateTime) this.close(true);
}
-
+
});
CalendarView = {};
-CalendarView.getControl = function(text, functionName) {
- var attr = {
- onclick: (functionName ? "Richfaces.getComponent('calendar',this)."+functionName+"();" : "")+"return true;",
- className: "rich-calendar-btn"
- };
+CalendarView.getControl = function(text, attributes, functionName, paramsStr) {
+ var attr = Object.extend({
+ onclick: (functionName ? "Richfaces.getComponent('calendar',this)."+functionName+"("+(paramsStr ? paramsStr : "")+");" : "")+"return true;",
+ className: "rich-calendar-btn"
+ }, attributes);
return new E('div',attr,[new T(text)]);
};
-CalendarView.getSelectedDateControl = function(text, functionName) {
- var attr = {
- onclick: "Richfaces.getComponent('calendar',this).showSelectedDate(); return true;",
- className: "rich-calendar-btn"
- };
+CalendarView.getSelectedDateControl = function(calendar) {
- var a = [new T(text)];
- if (text)
- {
- a.push(new T(" "));
- a.push(new E('a', {href: '#', onclick: "Richfaces.getComponent('calendar',this).resetSelectedDate();return true;"}, [new T('(x)')]));
- }
+ if (!calendar.selectedDate || calendar.showApplyButton) return "";
- return new E('div',attr,a);
+ var text = Richfaces.Calendar.formatDate(calendar.selectedDate,(calendar.timeType ? calendar.datePattern : calendar.params.datePattern), calendar.params.monthLabels, calendar.params.monthLabelsShort);
+
+ var markup = new E('div', {'class': 'rich-calendar-tool-btn', 'onclick': "Richfaces.getComponent('calendar',this).showSelectedDate(); return true;"}, [new ET(text)]);
+
+ return markup;
};
-CalendarView.nextYearControl = CalendarView.getControl(">>", "nextYear");
-CalendarView.previousYearControl = CalendarView.getControl("<<", "prevYear");
-CalendarView.nextMonthControl = CalendarView.getControl(">", "nextMonth");
-CalendarView.previousMonthControl = CalendarView.getControl("<", "prevMonth");
-CalendarView.currentMonthControl = function (context) { return context.calendar.getCurrentDate().format("MMMM, yyyy", context.monthLabels, context.monthLabelsShort);};
-CalendarView.todayControl = CalendarView.getControl("Today", "today");
-CalendarView.selectedDateControl = function (context) { return CalendarView.getSelectedDateControl(context.calendar.getSelectedDateString(context.calendar.params.datePattern));};
-//CalendarView.resetSelectedDateControl = function (context) { return (context.calendar.getSelectedDate() ? CalendarView.getControl("x", "resetSelectedDate") : "");};
+CalendarView.getTimeControl = function(calendar) {
+
+ if (!calendar.selectedDate || !calendar.timeType) return "";
+
+ var text = Richfaces.Calendar.formatDate(calendar.selectedDate, calendar.timePattern, calendar.params.monthLabels, calendar.params.monthLabelsShort);
+
+ var markup = new E('div', {'class': 'rich-calendar-tool-btn rich-calendar-tool-btn-hover rich-calendar-tool-btn-press', 'onclick': "Richfaces.getComponent('calendar',this).showTimeEditor();return true;",
+ 'onmouseover': "Element.removeClassName(this, 'rich-calendar-tool-btn-press');",
+ 'onmouseout' : "Element.addClassName(this, 'rich-calendar-tool-btn-press');"}, [new ET(text)]);
+ return markup;
+};
+
+CalendarView.toolButtonAttributes = {className: "rich-calendar-tool-btn", onmouseover:"this.className='rich-calendar-tool-btn rich-calendar-tool-btn-hover'", onmouseout:"this.className='rich-calendar-tool-btn'", onmousedown:"this.className='rich-calendar-tool-btn rich-calendar-tool-btn-hover rich-calendar-tool-btn-press'", onmouseup:"this.className='rich-calendar-tool-btn rich-calendar-tool-btn-hover'"};
+CalendarView.nextYearControl = CalendarView.getControl(">>", CalendarView.toolButtonAttributes, "nextYear");
+CalendarView.previousYearControl = CalendarView.getControl("<<", CalendarView.toolButtonAttributes, "prevYear");
+CalendarView.nextMonthControl = CalendarView.getControl(">", CalendarView.toolButtonAttributes, "nextMonth");
+CalendarView.previousMonthControl = CalendarView.getControl("<", CalendarView.toolButtonAttributes, "prevMonth");
+CalendarView.currentMonthControl = function (context) { return Richfaces.Calendar.formatDate(context.calendar.getCurrentDate(), "MMMM, yyyy", context.monthLabels, context.monthLabelsShort);};
+CalendarView.todayControl = function (context) { return (context.calendar.todayControlMode!='hidden' ? CalendarView.getControl("Today", CalendarView.toolButtonAttributes, "today") : "");};
+CalendarView.selectedDateControl = function (context) { return CalendarView.getSelectedDateControl(context.calendar);};
+CalendarView.timeControl = function (context) { return CalendarView.getTimeControl(context.calendar);};
+CalendarView.closeControl = CalendarView.getControl("x", CalendarView.toolButtonAttributes, "close", "false");
+CalendarView.applyControl = function (context) { return (context.calendar.showApplyButton ? CalendarView.getControl("Apply", CalendarView.toolButtonAttributes, "close", "true") : "");};
+CalendarView.cleanControl = function (context) { return (context.calendar.selectedDate ? CalendarView.getControl("Clean", CalendarView.toolButtonAttributes, "resetSelectedDate") : "");};
+CalendarView.timeEditorFields = function (context) { return context.calendar.timePatternHtml;};
+
CalendarView.header = [
new E('table',{'border': '0', 'cellpadding': '0', 'cellspacing': '0', 'width': '100%'},
[
@@ -1413,6 +1867,10 @@
new E('td',{'class': 'rich-calendar-tool'},
[
new ET(function (context) { return Richfaces.evalMacro("nextYearControl", context)})
+ ]),
+ new E('td',{'class': 'rich-calendar-tool rich-calendar-tool-close'},
+ [
+ new ET(function (context) { return Richfaces.evalMacro("closeControl", context)})
])
])
])
@@ -1426,23 +1884,69 @@
[
new E('tr',{},
[
- /*new E('td',{'class': 'rich-calendar-toolfooter'},
+ new E('td',{'class': 'rich-calendar-toolfooter', 'style':function(context){return (this.isEmpty ? 'display:none;' : '');}},
[
- new ET(function (context) { return Richfaces.evalMacro("resetSelectedDateControl", context)})
- ]),*/
- new E('td',{'class': 'rich-calendar-toolfooter', 'style': 'white-space:nowrap'},
- [
new ET(function (context) { return Richfaces.evalMacro("selectedDateControl", context)})
]),
- new E('td',{'class': 'rich-calendar-toolfooter', 'align': 'right'},
+ new E('td',{'class': 'rich-calendar-toolfooter', 'style':function(context){return (this.isEmpty ? 'display:none;' : '');}},
[
+ new ET(function (context) { return Richfaces.evalMacro("cleanControl", context)})
+ ]),
+ new E('td',{'class': 'rich-calendar-toolfooter', 'style':function(context){return (this.isEmpty ? 'display:none;' : '');}},
+ [
+ new ET(function (context) { return Richfaces.evalMacro("timeControl", context)})
+ ]),
+ new E('td',{'width': '100%'}, []),
+ new E('td',{'class': 'rich-calendar-toolfooter', 'style':function(context){return (this.isEmpty ? 'display:none;' : '')+(!context.calendar.showApplyButton ? 'background-image:none;' : '');}},
+ [
new ET(function (context) { return Richfaces.evalMacro("todayControl", context)})
+ ]),
+ new E('td',{'class': 'rich-calendar-toolfooter', 'style':function(context){return (this.isEmpty ? 'display:none;' : '')+'background-image:none;';}},
+ [
+ new ET(function (context) { return Richfaces.evalMacro("applyControl", context)})
])
])
])
]
)];
+CalendarView.timeEditor = [
+
+ new E('div',{'id': function(context){return context.calendar.TIME_EDITOR_LAYOUT_SHADOW_ID}, 'class': 'rich-calendar-time-layout-shadow'},null),
+
+ new E('table',{'id': function(context){return context.calendar.TIME_EDITOR_LAYOUT_ID}, 'border': '0', 'cellpadding': '0', 'cellspacing': '0', 'class': 'rich-calendar-time-layout'},
+ [
+ new E('tbody',{},
+ [
+ new E('tr',{},
+ [
+ new E('td',{'class': 'rich-calendar-time-layout-fields', 'colspan': '2', 'align': 'center'},
+ [
+ new ET(function (context) { return Richfaces.evalMacro("timeEditorFields", context)})
+ ])
+ ]),
+ new E('tr',{},
+ [
+ new E('td',{'class': 'rich-calendar-time-layout-ok'},
+ [
+ new E('div',{'class': 'rich-calendar-time-btn', 'style': 'float:right;', 'onmousedown': "Element.addClassName(this, 'rich-calendar-time-btn-press');", 'onmouseout': "Element.removeClassName(this, 'rich-calendar-time-btn-press');", 'onmouseup': "Element.removeClassName(this, 'rich-calendar-time-btn-press');", 'onclick': function(context){return "$('"+context.calendar.id+"').component.hideTimeEditor(true)";}},
+ [
+ new T('Ok')
+ ])
+ ])
+ ,
+ new E('td',{'class': 'rich-calendar-time-layout-cancel'},
+ [
+ new E('div',{'class': 'rich-calendar-time-btn', 'style': 'float:left;', 'onmousedown': "Element.addClassName(this, 'rich-calendar-time-btn-press');", 'onmouseout': "Element.removeClassName(this, 'rich-calendar-time-btn-press');", 'onmouseup': "Element.removeClassName(this, 'rich-calendar-time-btn-press');", 'onclick': function(context){return "$('"+context.calendar.id+"').component.hideTimeEditor(false)";}},
+ [
+ new T('Cancel')
+ ])
+ ])
+ ])
+ ])
+ ]
+ )];
+
CalendarView.dayList = [new ET(function (context) { return context.day})];
CalendarView.weekNumber = [new ET(function (context) { return context.weekNumber})];
CalendarView.weekDay = [new ET(function (context) { return context.weekDayLabelShort})];
@@ -1462,7 +1966,11 @@
nextMonthControl: CalendarView.nextMonthControl,
previousMonthControl: CalendarView.previousMonthControl,
currentMonthControl: CalendarView.currentMonthControl,
+ selectedDateControl: CalendarView.selectedDateControl,
+ cleanControl: CalendarView.cleanControl,
+ timeControl: CalendarView.timeControl,
todayControl: CalendarView.todayControl,
- selectedDateControl: CalendarView.selectedDateControl
- //resetSelectedDateControl: CalendarView.resetSelectedDateControl,
+ closeControl: CalendarView.closeControl,
+ applyControl: CalendarView.applyControl,
+ timeEditorFields: CalendarView.timeEditorFields
});
\ No newline at end of file
Modified: branches/3.1.x/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
--- branches/3.1.x/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-12-04 18:39:29 UTC (rev 4470)
+++ branches/3.1.x/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-12-04 18:51:39 UTC (rev 4471)
@@ -9,107 +9,14 @@
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/events.js,/org/richfaces/renderkit/html/scripts/utils.js,/org/richfaces/renderkit/html/scripts/json/json-dom.js,/org/richfaces/renderkit/html/scripts/scriptaculous/effects.js,/org/richfaces/renderkit/html/scripts/calendar.js</h:scripts>
+ <h:scripts>new org.ajax4jsf.javascript.PrototypeScript(),new org.ajax4jsf.javascript.AjaxScript(),/org/richfaces/renderkit/html/scripts/events.js,/org/richfaces/renderkit/html/scripts/utils.js,/org/richfaces/renderkit/html/scripts/json/json-dom.js,/org/richfaces/renderkit/html/scripts/scriptaculous/effects.js,/org/richfaces/renderkit/html/scripts/jquery/jquery.js,/org/richfaces/renderkit/html/scripts/jquery/jquery.js,/org/richfaces/renderkit/html/scripts/JQuerySpinBtn.js,/org/richfaces/renderkit/html/scripts/calendar.js</h:scripts>
<h:styles>/org/richfaces/renderkit/html/css/calendar.xcss</h:styles>
- <div id="#{clientId}"
- style="z-index: #{component.attributes['zindex']}; #{component.attributes['style']}"
- class="rich-calendar-popup #{component.attributes['styleClass']}"
- x:passThruWithExclusions="value,name,type,id,styleClass,class,style">
- <script
- type="text/javascript">
- new Calendar('#{clientId}', {
-
- <jsp:scriptlet>/*<![CDATA[*/
- String mode = (String) component.getAttributes().get("mode");
- if(org.richfaces.component.UICalendar.AJAX_MODE.equals(mode)){
- /*]]>*/</jsp:scriptlet>
-
- submitFunction: <jsp:scriptlet>/*<![CDATA[*/writeSubmitFunction(context, component);/*]]>*/</jsp:scriptlet>,
-
- <jsp:scriptlet>/*<![CDATA[*/
- }
- /*]]>*/</jsp:scriptlet>
-
- dayListTableId: '#{clientId}Day',
- weekNumberBarId: '#{clientId}WeekNum',
- weekDayBarId: '#{clientId}WeekDay',
- currentDate: #{this:getCurrentDate(context, component)},
- selectedDate: #{this:getSelectedDate(context, component)},
- datePattern: '#{component.datePattern}',
- jointPoint: '#{component.jointPoint}',
- direction: '#{component.direction}',
- toolTipMode:'#{component.toolTipMode}',
- boundaryDatesMode:'#{component.boundaryDatesMode}',
- popup: #{component.popup},
- enableManualInput: #{component.attributes['enableManualInput']},
- showInput: #{component.attributes['showInput']},
- disabled: #{component.disabled},
- ajaxSingle: #{component.attributes['ajaxSingle']},
- verticalOffset:'#{component.verticalOffset}',
- horizontalOffset: '#{component.horizontalOffset}',
- <f:call name="writeSymbols" />,
- firstWeekDay: #{this:getFirstWeekDay(context, component)},
- minDaysInFirstWeek: #{this:getMinDaysInFirstWeek(context, component)}
-
- <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="ondatemouseover" /></f:call>
- <f:call name="writeEventHandlerFunction"><f:parameter value="ondatemouseout" /></f:call>
- <f:call name="writeEventHandlerFunction"><f:parameter value="onexpand" /></f:call>
- <f:call name="writeEventHandlerFunction"><f:parameter value="oncollapse" /></f:call>
- <f:call name="writeEventHandlerFunction"><f:parameter value="oncurrentdateselect" /></f:call>
-
- <jsp:scriptlet> /*<![CDATA[*/
- if (component.getFacet("optionalHeader")!= null&& component.getFacet("optionalHeader").isRendered()){
- /*]]>*/ </jsp:scriptlet>
- ,headerOptionalMarkup: [new E('b',{},
- <jsp:scriptlet> /*<![CDATA[*/
- writeMarkupScriptBody(context, component.getFacet("optionalHeader"), false);
- /*]]>*/ </jsp:scriptlet>
- )]
- <jsp:scriptlet> /*<![CDATA[*/
- }
- /*]]>*/ </jsp:scriptlet>
-
- <jsp:scriptlet> /*<![CDATA[*/
- if (component.getFacet("optionalFooter")!= null&& component.getFacet("optionalFooter").isRendered()){
- /*]]>*/ </jsp:scriptlet>
- ,footerOptionalMarkup: [new E('b',{},
- <jsp:scriptlet> /*<![CDATA[*/
- writeMarkupScriptBody(context, component.getFacet("optionalFooter"), false);
- /*]]>*/ </jsp:scriptlet>
- )]
- <jsp:scriptlet> /*<![CDATA[*/
- }
- /*]]>*/ </jsp:scriptlet>
-
- <jsp:scriptlet>/*<![CDATA[*/
- if (component.getChildCount() != 0) {
- /*]]>*/</jsp:scriptlet>
- ,dayListMarkup:
- <jsp:scriptlet>/*<![CDATA[*/
- writeMarkupScriptBody(context, component, true);
- }
- /*]]>*/</jsp:scriptlet>
-
- <f:call name="writeFacetMarkupScriptBody"><f:parameter value="weekDay" /></f:call>
- <f:call name="writeFacetMarkupScriptBody"><f:parameter value="weekNumber" /></f:call>
- <f:call name="writeFacetMarkupScriptBody"><f:parameter value="header" /></f:call>
- <f:call name="writeFacetMarkupScriptBody"><f:parameter value="footer" /></f:call>
-
- }).load(
- <jsp:scriptlet>/*<![CDATA[*/
- writePreloadBody(context, component);
- /*]]>*/</jsp:scriptlet>
- );
- </script></div>
-
<f:call name="addPopupToAjaxRendered" />
-
- <span id="#{clientId}Popup">
- <jsp:scriptlet>
+
+ <span id="#{clientId}Popup"
+ x:passThruWithExclusions="value,name,type,id,styleClass,class,style"> <jsp:scriptlet>
<![CDATA[
boolean popup = getUtils().isBooleanAttribute(component, "popup");
if (!popup) {
@@ -117,29 +24,23 @@
} else {
boolean disabled = getUtils().isBooleanAttribute(component, "disabled");
boolean showInput = getUtils().isBooleanAttribute(component, "showInput");
- boolean manualInput = getUtils().isBooleanAttribute(component, "enableManualInput");
- String onfieldclick =null;
+ String onfieldclick =null;
String type="text";
- if(!manualInput){
- variables.setVariable("manualInput",new String("readonly"));
- onfieldclick = "$('"+clientId+"').component.doSwitch();";
- }
-
if (!showInput){
type="hidden";
}
- variables.setVariable("onfieldclick",onfieldclick);
variables.setVariable("type",type);
variables.setVariable("disabled",new Boolean(disabled));
]]>
- </jsp:scriptlet>
- <f:resource name="org.richfaces.renderkit.html.iconimages.CalendarIcon" var="icon"/>
- <f:resource name="org.richfaces.renderkit.html.iconimages.DisabledCalendarIcon" var="disabledIcon"/>
- <input id="#{clientId}InputDate" name="#{clientId}InputDate"
+ </jsp:scriptlet> <f:resource
+ name="org.richfaces.renderkit.html.iconimages.CalendarIcon" var="icon" />
+ <f:resource
+ name="org.richfaces.renderkit.html.iconimages.DisabledCalendarIcon"
+ var="disabledIcon" /> <input id="#{clientId}InputDate"
+ name="#{clientId}InputDate"
value="#{this:getInputValue(context,component)}" type="#{type}"
- readonly="#{manualInput}"
disabled="#{disabled}"
accesskey="#{component.attributes['accesskey']}"
maxlength="#{component.attributes['maxlength']}"
@@ -147,7 +48,7 @@
onselect="#{component.attributes['oninputselect']}"
onfocus="#{component.attributes['oninputfocus']}"
onblur="#{component.attributes['oninputblur']}"
- onclick="#{onfieldclick} #{component.attributes['oninputclick']}"
+ onclick="#{component.attributes['oninputclick']}"
onkeypress="#{component.attributes['oninputkeypress']}"
onkeydown="#{component.attributes['oninputkeydown']}"
onkeyup="#{component.attributes['oninputkeyup']}"
@@ -155,8 +56,16 @@
style="vertical-align: middle; #{component.attributes['inputStyle']}"
class="rich-calendar-input #{component.attributes['inputClass']}"
tabindex="#{component.attributes['tabindex']}">
- </input>
<jsp:scriptlet>
+ <![CDATA[
+ boolean manualInput = getUtils().isBooleanAttribute(component, "enableManualInput");
+ if(!manualInput){
+ getUtils().writeAttribute(writer, "readonly", "readonly");
+ }
+ ]]>
+ </jsp:scriptlet>
+
+ </input> <jsp:scriptlet>
<![CDATA[
String buttonIcon = org.richfaces.component.util.ViewUtil.getResourceURL((String) component.getAttributes().get("buttonIcon"),context);
String buttonIconDisabled = org.richfaces.component.util.ViewUtil.getResourceURL((String) component.getAttributes().get("buttonIconDisabled"),context);
@@ -166,18 +75,16 @@
variables.setVariable("buttonIcon",buttonIcon);
if(buttonLabel==null || buttonLabel.length()==0){
]]>
- </jsp:scriptlet>
- <img id="#{clientId}PopupButton" class="rich-calendar-button #{component.attributes['buttonClass']}"
+ </jsp:scriptlet> <img id="#{clientId}PopupButton"
+ class="rich-calendar-button #{component.attributes['buttonClass']}"
accesskey="#{component.attributes['accesskey']}"
- name="#{clientId}"
style="vertical-align: middle"
tabindex="#{component.attributes['tabindex']}">
-
- <jsp:scriptlet>
+ <jsp:scriptlet>
<![CDATA[
if(!disabled){
- getUtils().writeAttribute(writer, "onclick", "$('"+clientId+"').component.doSwitch();");
+ //getUtils().writeAttribute(writer, "onclick", "$('"+clientId+"').component.doSwitch();");
if(buttonIcon==null){
getUtils().writeAttribute(writer, "src", variables.getVariable("icon"));
}
@@ -187,7 +94,7 @@
}
else{
- getUtils().writeAttribute(writer, "onclick", null);
+ //getUtils().writeAttribute(writer, "onclick", null);
if(buttonIconDisabled==null){
getUtils().writeAttribute(writer, "src", variables.getVariable("disabledIcon"));
}
@@ -196,35 +103,105 @@
}
}
]]>
- </jsp:scriptlet>
-
- </img>
- <jsp:scriptlet>
+ </jsp:scriptlet> </img> <jsp:scriptlet>
<![CDATA[
}
else{
]]>
</jsp:scriptlet>
- <button
- type="button"
- id="#{clientId}PopupButton"
- name="#{clientId}"
- onclick="$('#{clientId}').component.doSwitch();return true; #{component.attributes['oninputclick']}"
+ <button type="button" id="#{clientId}PopupButton" name="#{clientId}PopupButton"
style="vertical-align: middle"
class="rich-calendar-button #{component.attributes['buttonClass']}"
- tabindex="#{component.attributes['tabindex']}"
- disabled="#{disabled}">
- #{buttonLabel}
- </button>
- <jsp:scriptlet>
+ tabindex="#{component.attributes['tabindex']}" disabled="#{disabled}">
+ #{buttonLabel}</button>
+ <jsp:scriptlet>
<![CDATA[
}
]]>
- </jsp:scriptlet>
-
- <jsp:scriptlet>
+ </jsp:scriptlet> <jsp:scriptlet>
<![CDATA[
}
]]>
</jsp:scriptlet> </span>
+ <f:call name="dayCellClass" />
+ <script type="text/javascript">
+ new Calendar('#{clientId}', {
+
+ <jsp:scriptlet>/*<![CDATA[*/
+ String mode = (String) component.getAttributes().get("mode");
+ if(org.richfaces.component.UICalendar.AJAX_MODE.equals(mode)){
+ /*]]>*/</jsp:scriptlet>
+
+ submitFunction: <jsp:scriptlet>/*<![CDATA[*/writeSubmitFunction(context, component);/*]]>*/</jsp:scriptlet>,
+
+ <jsp:scriptlet>/*<![CDATA[*/
+ }
+ /*]]>*/</jsp:scriptlet>
+
+ dayListTableId: '#{clientId}Day',
+ weekNumberBarId: '#{clientId}WeekNum',
+ weekDayBarId: '#{clientId}WeekDay',
+ currentDate: #{this:getCurrentDate(context, component)},
+ selectedDate: #{this:getSelectedDate(context, component)},
+ datePattern: '#{component.datePattern}',
+ jointPoint: '#{component.jointPoint}',
+ direction: '#{component.direction}',
+ toolTipMode:'#{component.toolTipMode}',
+ boundaryDatesMode:'#{component.boundaryDatesMode}',
+ popup: #{component.popup},
+ enableManualInput: #{component.attributes['enableManualInput']},
+ showInput: #{component.attributes['showInput']},
+ disabled: #{component.disabled},
+ ajaxSingle: #{component.attributes['ajaxSingle']},
+ verticalOffset:#{component.verticalOffset},
+ horizontalOffset: #{component.horizontalOffset},
+ style:'z-index: #{component.attributes["zindex"]}; #{component.attributes["style"]}',
+ firstWeekDay: #{this:getFirstWeekDay(context, component)},
+ minDaysInFirstWeek: #{this:getMinDaysInFirstWeek(context, component)},
+ todayControlMode:'#{component.attributes["todayControlMode"]}',
+ showScrollerBar:#{component.attributes['showScrollerBar']},
+ showWeeksBar:#{component.attributes['showWeeksBar']},
+ showWeekDaysBar:#{component.attributes['showWeekDaysBar']},
+ showApplyButton:#{component.attributes['showApplyButton']}
+
+
+
+ <f:call name="writeClass"/>
+ <f:call name="writeDayCellClass"/>
+ <f:call name="writeDayStyleClass"/>
+ <f:call name="writeIsDayEnabled"/>
+ <f:call name="writeSymbols" />
+
+
+ <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="ondatemouseover" /></f:call>
+ <f:call name="writeEventHandlerFunction"><f:parameter value="ondatemouseout" /></f:call>
+ <f:call name="writeEventHandlerFunction"><f:parameter value="onexpand" /></f:call>
+ <f:call name="writeEventHandlerFunction"><f:parameter value="oncollapse" /></f:call>
+ <f:call name="writeEventHandlerFunction"><f:parameter value="oncurrentdateselect" /></f:call>
+
+ <jsp:scriptlet>/*<![CDATA[*/
+ if (component.getChildCount() != 0) {
+ /*]]>*/</jsp:scriptlet>
+ ,\n dayListMarkup:
+ <jsp:scriptlet>/*<![CDATA[*/
+ writeMarkupScriptBody(context, component, true);
+ }
+ /*]]>*/</jsp:scriptlet>
+
+ <f:call name="writeOptionalFacetMarkupScriptBody"><f:parameter value="optionalHeader" /></f:call>
+ <f:call name="writeOptionalFacetMarkupScriptBody"><f:parameter value="optionalFooter" /></f:call>
+
+ <f:call name="writeFacetMarkupScriptBody"><f:parameter value="weekDay" /></f:call>
+ <f:call name="writeFacetMarkupScriptBody"><f:parameter value="weekNumber" /></f:call>
+ <f:call name="writeFacetMarkupScriptBody"><f:parameter value="header" /></f:call>
+ <f:call name="writeFacetMarkupScriptBody"><f:parameter value="footer" /></f:call>
+
+ }).load(
+ <jsp:scriptlet>/*<![CDATA[*/
+ writePreloadBody(context, component);
+ /*]]>*/</jsp:scriptlet>
+ );
+ </script>
</f:root>
More information about the richfaces-svn-commits
mailing list