[richfaces-svn-commits] JBoss Rich Faces SVN: r5311 - in branches/3.1.x/ui/calendar/src/main: resources/org/richfaces/renderkit/html/css and 2 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Fri Jan 11 11:32:51 EST 2008
Author: akushunin
Date: 2008-01-11 11:32:50 -0500 (Fri, 11 Jan 2008)
New Revision: 5311
Modified:
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:
RF-1461, RF-1725
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 2008-01-11 15:59:48 UTC (rev 5310)
+++ branches/3.1.x/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2008-01-11 16:32:50 UTC (rev 5311)
@@ -33,6 +33,8 @@
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
import java.util.Set;
import javax.faces.component.UIComponent;
@@ -73,8 +75,11 @@
protected static final String MARKUP_SUFFIX = "Markup";
- private final static Log log = LogFactory.getLog(CalendarRendererBase.class);
+ public static final String CALENDAR_BUNDLE = "org.richfaces.renderkit.calendar";
+ private final static Log log = LogFactory
+ .getLog(CalendarRendererBase.class);
+
/*
* (non-Javadoc)
*
@@ -518,4 +523,80 @@
result.addParameter(new Integer(0));
return result;
}
+
+ public void writeStringsFromBundle(ResourceBundle bundle1, ResourceBundle bundle2, String name,
+ ResponseWriter writer) throws IOException {
+
+ String label = null;
+ try {
+ if(null != bundle1){
+ label = bundle1.getString("RICH_CALENDAR_" + name.toUpperCase() + "_LABEL");
+ }
+
+ } catch (MissingResourceException e) {
+ // Current key wasn't found in application bundle, use CALENDAR_BUNDLE
+ try {
+
+ if(null != bundle2){
+ label = bundle2.getString("RICH_CALENDAR_" + name.toUpperCase() + "_LABEL");
+ }
+ } catch (MissingResourceException exc) {
+ // Current key wasn't found, use default, ignore this exception.
+ }
+ }
+ writeStringFoundInBundle(name, label, writer);
+
+ }
+
+ public void writeStringFoundInBundle(String name, String value, ResponseWriter writer) throws IOException {
+ if(null!=value){
+ if (!("close").equals(name.toLowerCase())) {
+ writer.writeText(name.toLowerCase() + ":'" + value + "', ",null);
+ } else {
+ writer.writeText("close:'" + value + "'", null);
+ }
+ }else{
+ if (!("close").equals(name.toLowerCase())) {
+ writer.writeText(name.toLowerCase() + ":'" + name + "', ",null);
+ } else {
+ writer.writeText("close:'x'", null);
+ }
+ }
+
+ }
+
+ public void writeLabels(FacesContext context, UICalendar calendar)
+ throws IOException {
+
+ ResourceBundle bundle1 = null;
+ ResourceBundle bundle2 = null;
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ String messageBundle = context.getApplication().getMessageBundle();
+ Object locale = calendar.getLocale();
+ if (null != messageBundle) {
+ bundle1 = ResourceBundle.getBundle(messageBundle, calendar.getAsLocale(locale), loader);
+ }
+ try {
+ bundle2 = ResourceBundle.getBundle(CALENDAR_BUNDLE, calendar.getAsLocale(locale), loader);
+
+ } catch (MissingResourceException e) {
+ //No external bundle was found, ignore this exception.
+ }
+
+ ResponseWriter writer = context.getResponseWriter();
+ writer.writeText(",\n labels:{", null);
+ if (null != bundle1 || null != bundle2) {
+ writeStringsFromBundle(bundle1, bundle2, "Apply", writer);
+ writeStringsFromBundle(bundle1, bundle2, "Today", writer);
+ writeStringsFromBundle(bundle1, bundle2, "Clean", writer);
+ writeStringsFromBundle(bundle1, bundle2, "Cancel", writer);
+ writeStringsFromBundle(bundle1, bundle2, "OK", writer);
+ writeStringsFromBundle(bundle1, bundle2, "Close", writer);
+ }else{
+ // No bundles were found, use default labels.
+ writer.writeText("apply:'Apply', today:'Today', clean:'Clean', ok:'OK', cancel:'Cancel', close:'x'", null);
+ }
+ writer.writeText("}", null);
+
+ }
}
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 2008-01-11 15:59:48 UTC (rev 5310)
+++ branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss 2008-01-11 16:32:50 UTC (rev 5311)
@@ -49,6 +49,7 @@
.rich-calendar-month{
vertical-align : middle;
text-align : center;
+ height : 22px;
}
.rich-calendar-days{
@@ -140,7 +141,7 @@
<u:selector name=".rich-calendar-cell">
<u:style name="border-bottom-color" skin="panelBorderColor"/>
<u:style name="border-right-color" skin="panelBorderColor"/>
- <u:style name="background-color" skin="generalBackgroundColor"/>
+ <u:style name="background-color" skin="tableBackgroundColor"/>
<u:style name="font-size" skin="generalSizeFont"/>
<u:style name="font-family" skin="generalFamilyFont"/>
</u:selector>
@@ -273,7 +274,7 @@
<u:style name="vertical-align" value="middle"/>
</u:selector>
- <u:selector name=".rich-calendar-time-shadow">
+ <u:selector name=".rich-calendar-editor-shadow">
<u:style name="background" skin="tableBackgroundColor"/>
<u:style name="opacity" value="0.5"/>
<u:style name="filter" value="alpha(opacity=50)"/>
@@ -286,10 +287,17 @@
<u:style name="position" value="relative"/>
</u:selector>
- <u:selector name=".rich-calendar-time-layout-container">
+ <u:selector name=".rich-calendar-date-layout">
+ <u:style name="background" skin="tableBackgroundColor"/>
+ <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, .rich-calendar-time-layout input">
+ <u:selector name=".rich-calendar-editor-container">
+ </u:selector>
+
+ <u:selector name=".rich-calendar-time-layout, .rich-calendar-date-layout, .rich-calendar-time-layout input">
<u:style name="font-size" skin="generalSizeFont"/>
<u:style name="font-family" skin="generalFamilyFont"/>
</u:selector>
@@ -307,12 +315,32 @@
<u:style name="padding" value="0px 1px 7px 7px"/>
</u:selector>
+ <u:selector name=".rich-calendar-date-layout-cancel">
+ <u:style name="background" skin="additionalBackgroundColor"/>
+ <u:style name="border-top" value="1px solid"/>
+ <u:style name="border-top-color" skin="panelBorderColor"/>
+ <u:style name="padding" value="5px 5px 5px 1px"/>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-date-layout-ok">
+ <u:style name="background" skin="additionalBackgroundColor"/>
+ <u:style name="border-top" value="1px solid"/>
+ <u:style name="border-top-color" skin="panelBorderColor"/>
+ <u:style name="padding" value="5px 1px 5px 5px"/>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-date-layout-split">
+ <u:style name="border-right" value="1px solid"/>
+ <u:style name="border-right-color" skin="panelBorderColor"/>
+ </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="background" skin="additionalBackgroundColor"/>
<u:style name="text-align" value="center"/>
<u:style name="padding" value="2px"/>
<u:style name="white-space" value="nowrap"/>
@@ -382,11 +410,53 @@
<u:style name="border-right-color" skin="subBorderColor" />
</u:selector>
- <u:selector name=".rich-calendar-time-layout-shadow">
+ <u:selector name=".rich-calendar-editor-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>
+
+ <u:selector name=".rich-calendar-editor-btn">
+ <u:style name="width" value="36px" />
+ <u:style name="padding" value="2px" />
+ <u:style name="margin" value="2px" />
+ <u:style name="text-align" value="center"/>
+ <u:style name="cursor" value="pointer"/>
+ </u:selector>
+ <u:selector name=".rich-calendar-editor-btn-over">
+ <u:style name="padding" value="1px" />
+ <u:style name="border" value="1px solid"/>
+ <u:style name="border-color" skin="panelBorderColor"/>
+ <u:style name="background" skin="calendarSpecBackgroundColor"/>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-editor-btn-selected">
+ <u:style name="background-color" skin="calendarCurrentBackgroundColor" />
+ <u:style name="padding" value="2px" />
+ <u:style name="border" value="0px" />
+ <u:style name="color" skin="calendarCurrentTextColor" />
+ <u:style name="font-weight" value="bold"/>
+ <u:style name="cursor" value="default"/>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-editor-tool-over">
+ <u:style name="padding" value="1px" />
+ <u:style name="border" value="1px solid"/>
+ <u:style name="background" skin="additionalBackgroundColor"/>
+ <u:style name="border-color" skin="tableBackgroundColor"/>
+ <u:style name="border-right-color" skin="panelBorderColor"/>
+ <u:style name="border-bottom-color" skin="panelBorderColor"/>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-editor-tool-press">
+ <u:style name="padding" value="1px" />
+ <u:style name="border" value="1px solid"/>
+ <u:style name="background" skin="additionalBackgroundColor"/>
+ <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>
+
</f:template>
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 2008-01-11 15:59:48 UTC (rev 5310)
+++ branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2008-01-11 16:32:50 UTC (rev 5311)
@@ -366,7 +366,7 @@
if (ch=='d') {d=counter; counter++; return '(\\d{2})'};
}
);
-
+
var re = new RegExp(pattern,'i');
var match = dateString.match(re);
if (match!=null)
@@ -403,41 +403,42 @@
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,
+ var mm; var dd; var hh; var min;
+ var result = pattern.replace(/(\\\\|\\[yMdaHhm])|(y+|M+|d+|a|H{1,2}|h{1,2}|m{2})/g,
function($1,$2,$3) {
+ if ($2) return $2.charAt(1);
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);
+ case 'yy': return date.getYear().toString().slice(-2);
+ case 'M': return (date.getMonth()+1);
+ case 'MM': return ((mm = date.getMonth()+1)<10 ? '0'+mm : mm);
+ case 'MMM': return monthNamesShort[date.getMonth()];
+ case 'd': return date.getDate();
+ case 'a' : return (date.getHours()<12 ? 'AM' : 'PM');
+ case 'HH' : return ((hh = date.getHours())<10 ? '0'+hh : hh);
+ case 'H' : return date.getHours();
+ case 'hh' : return ((hh = date.getHours())==0 ? '12' : (hh<10 ? '0'+hh : (hh>12 ? hh-12 : hh)));
+ case 'h' : return ((hh = date.getHours())==0 ? '12' : (hh>12 ? hh-12 : hh));
+ case 'mm' : return ((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);
+ if (ch=='y') return date.getFullYear();
+ if (ch=='M') return monthNames[date.getMonth()];
+ if (ch=='d') return ((dd = date.getDate())<10 ? '0'+dd : dd);
}
);
- return Richfaces.Calendar.unescape(result);
+ return result;
};
Richfaces.Calendar.escape = function (str)
{
- return str.replace(/([yMdaHhm])/g,"\\$1");
+ return str.replace(/([yMdaHhm\\])/g,"\\$1");
};
Richfaces.Calendar.unescape = function (str)
{
- return str.replace(/\\([yMdaHhm])/g,"$1");
+ return str.replace(/\\([yMdaHhm\\])/g,"$1");
};
@@ -548,6 +549,7 @@
// style - table style
// className - table class
+ //var _d = new Date();
this.id = id;
this.params = parameters;
@@ -605,12 +607,14 @@
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.EDITOR_ID = this.id+'Editor';
+ this.EDITOR_SHADOW_ID = this.id+'EditorShadow';
this.TIME_EDITOR_LAYOUT_ID = this.id+'TimeEditorLayout';
- this.TIME_EDITOR_LAYOUT_SHADOW_ID = this.id+'TimeEditorLayoutShadow';
+ this.DATE_EDITOR_LAYOUT_ID = this.id+'DateEditorLayout';
+ this.EDITOR_LAYOUT_SHADOW_ID = this.id+'EditorLayoutShadow';
+
//this.popupIntervalId=null;
this.firstDateIndex = 0;
@@ -646,6 +650,8 @@
var bottomStyleClass;
var htmlTextWeekDayBar='';
var context;
+ var tempStr = "$('"+this.id+"').component.";
+ var eventsStr = 'onclick="'+tempStr+'eventCellOnClick(event, this);" onmouseover="'+tempStr+'eventCellOnMouseOver(event, this);" onmouseout="'+tempStr+'eventCellOnMouseOut(event, this);"';
if (this.params.showWeekDaysBar)
{
var htmlTextWeekDayBar = '<tr id="'+this.params.weekDayBarId+'">';
@@ -671,6 +677,7 @@
// week & weekNumber creation
var htmlTextWeek='';
var p=0;
+ this.dayCellClassName = [];
for (k=1;k<7;k++)
{
@@ -690,15 +697,16 @@
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+'">'+(this.customDayListMarkup ? '<div class="rich-calendar-cell-div'+(this.params.dayCellClass ? ' '+this.params.dayCellClass : '')+'"></div>' : '')+'</td>';
+ this.dayCellClassName.push(styleClass);
+ htmlTextWeek+='<td class="'+styleClass+'" id="'+this.DATE_ELEMENT_ID+p+'"'+
+ eventsStr+
+ '>'+(this.customDayListMarkup ? '<div class="rich-calendar-cell-div'+(this.params.dayCellClass ? ' '+this.params.dayCellClass : '')+'"></div>' : '')+'</td>';
p++;
}
htmlTextWeek+='</tr>';
}
- var span=$(this.POPUP_ID);
-
- var obj = span.nextSibling;
+ var obj = $(this.POPUP_ID).nextSibling;
if (this.params.popup && Richfaces.browser.isIE6)
{
do {
@@ -727,8 +735,8 @@
obj.component = this;
obj.richfacesComponent="richfaces:calendar";
+ // memory leaks fix
obj = null;
- span = null;
if(this.params.submitFunction) this.submitFunction = this.params.submitFunction.bind(this);
this.prepareEvents();
@@ -744,8 +752,84 @@
}
}
+ //alert(new Date().getTime()-_d.getTime());
+
},
+
+ dateEditorSelectYear: function(value)
+ {
+ if (this.dateEditorYearID)
+ {
+ Element.removeClassName(this.dateEditorYearID, 'rich-calendar-editor-btn-selected');
+ }
+ this.dateEditorYear = this.dateEditorStartYear + value;
+ this.dateEditorYearID = this.DATE_EDITOR_LAYOUT_ID+'Y'+value;
+ Element.addClassName(this.dateEditorYearID, 'rich-calendar-editor-btn-selected');
+ },
+
+ dateEditorSelectMonth: function(value)
+ {
+ this.dateEditorMonth = value;
+ Element.removeClassName(this.dateEditorMonthID, 'rich-calendar-editor-btn-selected');
+ this.dateEditorMonthID = this.DATE_EDITOR_LAYOUT_ID+'M'+value;
+ Element.addClassName(this.dateEditorMonthID, 'rich-calendar-editor-btn-selected');
+ },
+
+ scrollEditorYear: function(value)
+ {
+ var element = $(this.DATE_EDITOR_LAYOUT_ID+'TR');
+ if (this.dateEditorYearID)
+ {
+ Element.removeClassName(this.dateEditorYearID, 'rich-calendar-editor-btn-selected');
+ this.dateEditorYearID='';
+ }
+
+ if (!value)
+ {
+ // update month selection when open editor (value == 0)
+ if (this.dateEditorMonth != this.getCurrentMonth())
+ {
+ this.dateEditorMonth = this.getCurrentMonth();
+ Element.removeClassName(this.dateEditorMonthID, 'rich-calendar-editor-btn-selected');
+ this.dateEditorMonthID = this.DATE_EDITOR_LAYOUT_ID+'M'+this.dateEditorMonth;
+ Element.addClassName(this.dateEditorMonthID, 'rich-calendar-editor-btn-selected');
+ }
+ }
+
+ if (element)
+ {
+ var div;
+ var year = this.dateEditorStartYear = this.dateEditorStartYear+value*10;
+ for (var i=0;i<5;i++)
+ {
+ element = element.nextSibling;
+ div = element.firstChild.nextSibling.nextSibling;
+ div.firstChild.innerHTML=year;
+ if (year == this.dateEditorYear)
+ {
+ Element.addClassName(div.firstChild, 'rich-calendar-editor-btn-selected');
+ this.dateEditorYearID = div.firstChild.id;
+ }
+ div = div.nextSibling;
+ div.firstChild.innerHTML=year+5;
+ if (year+5 == this.dateEditorYear)
+ {
+ Element.addClassName(div.firstChild, 'rich-calendar-editor-btn-selected');
+ this.dateEditorYearID = div.firstChild.id;
+ }
+ year++;
+ }
+ }
+ },
+
+ updateDateEditor: function()
+ {
+ this.dateEditorYear = this.getCurrentYear();
+ this.dateEditorStartYear = this.getCurrentYear() - 4;
+ this.scrollEditorYear(0);
+ },
+
updateTimeEditor: function()
{
var th=$(this.id+'TimeHours');
@@ -764,18 +848,29 @@
tm.value = (m<10 ? '0'+m : m);
},
- createTimeEditor: function(element)
+
+ createEditor: function()
{
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 htmlBegin = '<div id="'+this.EDITOR_SHADOW_ID+'" class="rich-calendar-editor-shadow" style="position:absolute; display:none;"></div><table border="0" cellpadding="0" cellspacing="0" id="'+this.EDITOR_ID+'" style="position:absolute; display:none;"><tbody><tr><td class="rich-calendar-editor-container" align="center"><div style="position:relative; width:100%">';
+ var htmlContent = '<div id="'+this.EDITOR_LAYOUT_SHADOW_ID+'" class="rich-calendar-editor-layout-shadow"></div>';
+
var htmlEnd = '</div></td></tr></tbody></table>';
- new Insertion.After(element, htmlBegin+this.evaluateMarkup(CalendarView.timeEditor, this.calendarContext)+htmlEnd);
- var te_shadow = $(this.TIME_EDITOR_SHADOW_ID);
- var te = $(this.TIME_EDITOR_ID);
+ new Insertion.After(element, htmlBegin+htmlContent+htmlEnd);
+ //+this.evaluateMarkup(CalendarView.timeEditor, this.calendarContext)+
+ var editor_shadow = $(this.EDITOR_SHADOW_ID);
+ var editor = $(this.EDITOR_ID);
var zindex = element.getStyle('z-index');
- te_shadow.style.zIndex = zindex;
- te.style.zIndex = parseInt(zindex,10)+1;
+ editor_shadow.style.zIndex = zindex;
+ editor.style.zIndex = parseInt(zindex,10)+1;
+ this.isEditorCreated = true;
+ },
+
+ createTimeEditorLayout: function()
+ {
+ Element.insert(this.EDITOR_LAYOUT_SHADOW_ID, {after:this.evaluateMarkup(this.calendarContext.timeEditorLayout, this.calendarContext)});
+
var th=$(this.id+'TimeHours');
var ts;
var tm=$(this.id+'TimeMinutes');
@@ -791,9 +886,65 @@
}
sbjQuery(tm).SpinButton({digits:2,min:0,max:59});
- this.isTimeEditorCreated = true;
+ this.isTimeEditorLayoutCreated = true;
},
+ createDECell: function(id, value, buttonType, param, className)
+ {
+ if (buttonType==0)
+ {
+ return '<div id="'+id+'" class="rich-calendar-editor-btn'+(className ? ' '+className : '')+
+ '" onmouseover="this.className=\'rich-calendar-editor-btn rich-calendar-editor-tool-over\';" onmouseout="this.className=\'rich-calendar-editor-btn\';" onmousedown="this.className=\'rich-calendar-editor-btn rich-calendar-editor-tool-press\';" onmouseup="this.className=\'rich-calendar-editor-btn rich-calendar-editor-tool-over\';" onclick="$(\''+this.id+'\').component.scrollEditorYear('+param+');">'+value+'</div>';
+ }
+ else
+ {
+ var onclick = (buttonType==1 ? '$(\''+this.id+'\').component.dateEditorSelectMonth('+param+');':
+ '$(\''+this.id+'\').component.dateEditorSelectYear('+param+');' );
+ return '<div id="'+id+'" class="rich-calendar-editor-btn'+(className ? ' '+className : '')+
+ '" onmouseover="Element.addClassName(this, \'rich-calendar-editor-btn-over\');" onmouseout="Element.removeClassName(this,\'rich-calendar-editor-btn-over\');" onclick="'+onclick+'">'+value+'</div>';
+ }
+ },
+
+ createDateEditorLayout: function()
+ {
+ var htmlBegin = '<table id="'+this.DATE_EDITOR_LAYOUT_ID+'" class="rich-calendar-date-layout" border="0" cellpadding="0" cellspacing="0"><tbody><tr id="'+this.DATE_EDITOR_LAYOUT_ID+'TR">';
+ var htmlEnd = '</tr></tbody></table>';
+ var month = 0;
+ this.dateEditorYear = this.getCurrentYear();
+ var year = this.dateEditorStartYear = this.dateEditorYear-4;
+ var htmlContent = '<td>'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+month, this.params.monthLabelsShort[month], 1, month)+'</td>'
+ +'<td class="rich-calendar-date-layout-split">'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+(month+6), this.params.monthLabelsShort[month+6], 1, month+6)+'</td>'
+ +'<td>'+this.createDECell('','<', 0, -1)+'</td>'
+ +'<td>'+this.createDECell('','>', 0, 1)+'</td>';
+ month++;
+
+ for (var i=0;i<5;i++)
+ {
+ htmlContent+='</tr><tr><td>'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+month, this.params.monthLabelsShort[month], 1, month)+'</td>'
+ +'<td class="rich-calendar-date-layout-split">'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+(month+6), this.params.monthLabelsShort[month+6], 1, month+6)+'</td>'
+ +'<td>'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'Y'+i, year, 2, i, (i==4 ? 'rich-calendar-editor-btn-selected' : ''))+'</td>'
+ +'<td>'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'Y'+(i+5), year+5, 2, i+5)+'</td>';
+ month++;
+ year++;
+ }
+ this.dateEditorYearID = this.DATE_EDITOR_LAYOUT_ID+'Y4';
+ this.dateEditorMonth = this.getCurrentMonth();
+ this.dateEditorMonthID = this.DATE_EDITOR_LAYOUT_ID+'M'+this.dateEditorMonth;
+
+ htmlContent+='</tr><tr><td colspan="2" class="rich-calendar-date-layout-ok">'+
+ '<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="$(\''+this.id+'\').component.hideDateEditor(true);">'+this.params.labels.ok+'</div>'+
+ '</td><td colspan="2" class="rich-calendar-date-layout-cancel">'+
+ '<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="$(\''+this.id+'\').component.hideDateEditor(false);">'+this.params.labels.cancel+'</div>'+
+ '</td>';
+
+
+ Element.insert(this.EDITOR_LAYOUT_SHADOW_ID, {after:htmlBegin+htmlContent+htmlEnd});
+
+ Element.addClassName(this.dateEditorMonthID, 'rich-calendar-editor-btn-selected');
+
+ this.isDateEditorLayoutCreated = true;
+ },
+
createSpinnerTable: function(id) {
return '<table cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
'<td class="rich-calendar-spinner-input-container">'+
@@ -823,10 +974,11 @@
var dateTimePattern = this.params.datePattern;
var pattern = [];
- var re = /(^|[^\\yMdHhm])(y+|M+|d+|a|H{1,2}|h{1,2}|m{2})/g;
+ var re = /(\\\\|\\[yMdaHhm])|(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});
+ if (!r[1])
+ pattern.push({str:r[0],marker:r[2],idx:r.index});
var datePattern = "";
var timePattern = "";
@@ -873,20 +1025,21 @@
var calendar = this;
- this.timePatternHtml = timePattern.replace(/(^|[^\\Hhm])(H{1,2}|h{1,2}|m{2}|a)/g,
+ this.timePatternHtml = timePattern.replace(/(\\\\|\\[yMdaHhm])|(H{1,2}|h{1,2}|m{2}|a)/g,
function($1,$2,$3) {
+ if ($2) return $2.charAt(1);
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 'a' : return '</td><td>'+calendar.createSpinnerTable(id+'TimeSign')+'</td><td>';
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"/>';
+ case 'hh' : return '</td><td>'+calendar.createSpinnerTable(id+'TimeHours')+'</td><td>';
+ case 'mm' : return '</td><td>'+calendar.createSpinnerTable(id+'TimeMinutes')+'</td><td>';
}
}
);
- this.timePatternHtml = '<table><tbody><tr>'+this.timePatternHtml+'</tr></tbody></table>';
+ this.timePatternHtml = '<table border="0" cellpadding="0"><tbody><tr><td>'+this.timePatternHtml+'</td></tr></tbody></table>';
if (m && h)
{
@@ -902,12 +1055,8 @@
doCollapse: function() {
if (!this.params.popup || !this.isVisible) return;
- if (this.isTimeEditorCreated) this.hideTimeEditor();
+ if (this.isEditorVisible) this.hideEditor();
- /*this.stopTimer();
- this.stopPopupEvents($(this.id));
- this.stopPopupEvents($(this.POPUP_ID));*/
-
var element = $(this.id);
if (this.invokeEvent("collapse", element))
@@ -921,19 +1070,6 @@
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;
- }*/
-
}
},
@@ -950,13 +1086,6 @@
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;
@@ -966,9 +1095,6 @@
this.selectDate(baseInput.value);
}
- /*this.setPopupEvents(e);
- this.setPopupEvents(base);*/
-
//rect calculation
var offsetBase = Position.cumulativeOffset(baseButton);
@@ -1082,52 +1208,9 @@
},
prepareEvents: function() {
- this.eventCellOnClick = this.eventCellOnClick.bindAsEventListener(this);
- this.eventCellOnMouseOver = this.eventCellOnMouseOver.bindAsEventListener(this);
- this.eventCellOnMouseOut = this.eventCellOnMouseOut.bindAsEventListener(this);
this.eventOnCollapse = this.eventOnCollapse.bindAsEventListener(this);
- //this.eventOnMouseOver = this.eventOnMouseOver.bindAsEventListener(this);
- //this.eventOnMouseOut = this.eventOnMouseOut.bindAsEventListener(this);
},
-/* setPopupEvents: function(obj) {
- Event.observe(obj, "mouseover", this.eventOnMouseOver, false);
- Event.observe(obj, "mouseout", this.eventOnMouseOut, false);
- },
-
- stopPopupEvents: function(obj) {
- Event.stopObserving(obj, "mouseover", this.eventOnMouseOver, false);
- Event.stopObserving(obj, "mouseout", this.eventOnMouseOut, false);
- },
- *
- stopTimer: function()
- {
- if (this.popupIntervalId!=null)
- {
- clearTimeout(this.popupIntervalId);
- this.popupIntervalId=null;
- }
- },
-
- eventOnMouseOver: function(e) {
- this.stopTimer();
- },
-
- eventOnMouseOut: function(e) {
- if (this.popupIntervalId==null) this.popupIntervalId = setTimeout('$("'+this.id+'").component.doCollapse()',400);
- },*/
-
- setCellEvents: function(obj) {
- Event.observe(obj, "click", this.eventCellOnClick, false);
- Event.observe(obj, "mouseover", this.eventCellOnMouseOver, false);
- Event.observe(obj, "mouseout", this.eventCellOnMouseOut, false);
- },
- stopCellEvents: function(obj) {
- Event.stopObserving(obj, "click", this.eventCellOnClick, false);
- Event.stopObserving(obj, "mouseover", this.eventCellOnMouseOver, false);
- Event.stopObserving(obj, "mouseout", this.eventCellOnMouseOut, false);
- },
-
invokeEvent: function(eventName, element, event, date) {
var eventFunction = this.params['on'+eventName];
var result;
@@ -1166,59 +1249,44 @@
return result;
},
- eventCellOnClick: function (e) {
- var obj = Event.findElementByAttr(e, "TD", "id", this.DATE_ELEMENT_ID, true);
- if (obj)
+ eventCellOnClick: function (e, obj) {
+ var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
+ if (daydata.enabled && daydata._month==0)
{
- var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
- if (daydata.enabled && daydata._month==0)
+ var date=new Date(this.currentDate);
+ date.setDate(daydata.day);
+
+ if (this.selectDate(date,true) && !this.showApplyButton)
{
- var date=new Date(this.currentDate);
- date.setDate(daydata.day);
+ this.doCollapse();
+ }
- if (this.selectDate(date,true) && !this.showApplyButton)
+ } else {
+ if (this.params.boundaryDatesMode == "scroll")
+ if (daydata._month==-1) this.prevMonth(); else this.nextMonth();
+ else if (this.params.boundaryDatesMode == "select")
+ {
+ if (this.selectDate(daydata.date) && !this.showApplyButton)
{
- this.doCollapse();
+ this.doCollapse();
}
-
- } else {
- if (this.params.boundaryDatesMode == "scroll")
- if (daydata._month==-1) this.prevMonth(); else this.nextMonth();
- 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) && !this.showApplyButton)
- {
- this.doCollapse();
- }
- }
}
}
},
- eventCellOnMouseOver: function (e) {
- var obj = Event.findElementByAttr(e, "TD", "id", this.DATE_ELEMENT_ID, true);
- if (obj)
+ eventCellOnMouseOver: function (e, obj) {
+ var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
+ if (this.invokeEvent("datemouseover", obj, e, daydata.date) && daydata.enabled)
{
- 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) && daydata.enabled)
- {
- if (daydata._month==0 && obj.id!=this.selectedDateCellId && obj.id!=this.todayCellId) Element.addClassName(obj,'rich-calendar-hover');
- }
+ if (daydata._month==0 && obj.id!=this.selectedDateCellId && obj.id!=this.todayCellId) Element.addClassName(obj,'rich-calendar-hover');
}
},
- eventCellOnMouseOut: function (e) {
- var obj = Event.findElementByAttr(e, "TD", "id", this.DATE_ELEMENT_ID, true);
- if (obj)
+ eventCellOnMouseOut: function (e, obj) {
+ var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
+ if (this.invokeEvent("datemouseout", obj, e, daydata.date) && daydata.enabled)
{
- 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) && daydata.enabled)
- {
- if (daydata._month==0 && obj.id!=this.selectedDateCellId && obj.id!=this.todayCellId) Element.removeClassName(obj,'rich-calendar-hover');
- }
+ if (daydata._month==0 && obj.id!=this.selectedDateCellId && obj.id!=this.todayCellId) Element.removeClassName(obj,'rich-calendar-hover');
}
},
@@ -1235,7 +1303,7 @@
// styleClass
// }
- if (!$(this.id).component) return;
+ //if (!$(this.id).component) return;
if (daysData) {
this.daysData = this.indexData(daysData, isAjaxMode);
@@ -1316,7 +1384,7 @@
},
render:function() {
-
+ //var _d=new Date();
this.todayDate = new Date();
var currentYear = this.getCurrentYear();
@@ -1406,8 +1474,8 @@
var boundaryDatesModeFlag = (this.params.boundaryDatesMode == "scroll" || this.params.boundaryDatesMode == "select");
- this.todayCellId = this.clearEffect(this.todayCellId, this.highlightEffect, "rich-calendar-today");
- this.selectedDateCellId = this.clearEffect(this.selectedDateCellId, this.highlightEffect2, "rich-calendar-select", "rich-calendar-btn");
+ this.todayCellId = this.clearEffect(this.todayCellId, this.highlightEffect);
+ this.selectedDateCellId = this.clearEffect(this.selectedDateCellId, this.highlightEffect2);
//var _d=new Date();
var obj = $(this.params.weekNumberBarId+"1");
@@ -1440,9 +1508,6 @@
while (element)
{
- // TODO fix start/stop event's calls
- this.stopCellEvents(element);
-
dataobj.elementId=element.id;
dataobj.date=new Date(currentYear, currentMonth+dataobj._month, dataobj.day);
dataobj.weekNumber = weeknumber;
@@ -1457,7 +1522,7 @@
else
{
var styleclass = this.params.dayStyleClass(dataobj);
- dataobj.customStyleClass = dataobj.styleClass
+ dataobj.customStyleClass = dataobj.styleClass;
if (styleclass) dataobj.customStyleClass += " " + styleclass;
}
@@ -1466,58 +1531,48 @@
if (weekdaycounter==6) weekdaycounter=0; else weekdaycounter++;
+ var classNames = this.dayCellClassName[p];
+
// class styles
- e = Element.classNames(element);
- // 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');
+ classNames+=' rich-calendar-boundary-dates';
if (boundaryDatesModeFlag)
- e.add('rich-calendar-btn');
- else
- e.remove('rich-calendar-btn');}
+ {
+ classNames+=' rich-calendar-btn';
+ }
+ }
else
{
- e.remove('rich-calendar-boundary-dates');
- if (dataobj.enabled) e.add('rich-calendar-btn'); else e.remove('rich-calendar-btn');
+ if (todayflag && dataobj.day==todaydate)
+ {
+ this.todayCellId = element.id;
+ this.todayCellColor = this.getCellBackgroundColor(element);
+ classNames+=" rich-calendar-today";
+ }
+
+ if (selectedflag && dataobj.day==selecteddate)
+ {
+ this.selectedDateCellId = element.id;
+ this.selectedDateCellColor = this.getCellBackgroundColor(element);
+ classNames+=" rich-calendar-select";
+ }
+ else if (dataobj.enabled) classNames+=' rich-calendar-btn';
// add custom style class
if (dataobj.customStyleClass)
{
- e.add(dataobj.customStyleClass);
- element.rich = {customStyleClass: dataobj.customStyleClass};
+ classNames+=' '+dataobj.customStyleClass;
}
}
+ element.className = classNames;
- // TODO make some optimization with rich-calendar-today class
- if (todayflag && dataobj._month==0 && dataobj.day==todaydate)
- {
- this.todayCellId = element.id;
- this.todayCellColor = this.getCellBackgroundColor(element);
- e.add("rich-calendar-today");
- }
-
- if (selectedflag && dataobj._month==0 && dataobj.day==selecteddate)
- {
- this.selectedDateCellId = element.id;
- this.selectedDateCellColor = this.getCellBackgroundColor(element);
- e.remove("rich-calendar-btn");
- e.add("rich-calendar-select");
- }
-
- this.setCellEvents(element);
p++;
dataobj = this.days[p];
element=element.nextSibling;
}
- obj = obj.nextSibling;
+ obj = obj.nextSibling;
}
//alert(new Date().getTime()-_d.getTime());
@@ -1532,7 +1587,6 @@
element.style.height = "0px";
}
}*/
-
},
renderHF: function()
@@ -1579,22 +1633,34 @@
},
nextMonth: function() {
- this.changeCurrentDate(0,1);
+ this.changeCurrentDateOffset(0,1);
},
prevMonth: function() {
- this.changeCurrentDate(0,-1);
+ this.changeCurrentDateOffset(0,-1);
},
nextYear: function() {
- this.changeCurrentDate(1,0);
+ this.changeCurrentDateOffset(1,0);
},
prevYear: function() {
- this.changeCurrentDate(-1,0);
+ this.changeCurrentDateOffset(-1,0);
},
- changeCurrentDate: function(yearOffset, monthOffset) {
+ changeCurrentDate: function(year, month) {
+ if (this.getCurrentMonth()!=month || this.getCurrentYear()!=year)
+ {
+ var date = new Date(year, month,1);
+ if (this.invokeEvent("currentdateselect", $(this.id), null, date))
+ {
+ this.currentDate = date;
+ this.onUpdate();
+ }
+ }
+ },
+
+ changeCurrentDateOffset: function(yearOffset, monthOffset) {
var date = new Date(this.currentDate.getFullYear()+yearOffset, this.currentDate.getMonth()+monthOffset,1);
if (this.invokeEvent("currentdateselect", $(this.id), null, date))
{
@@ -1602,7 +1668,7 @@
this.onUpdate();
}
},
-
+
today: function(noUpdate, noHighlight) {
var now = new Date();
@@ -1844,35 +1910,51 @@
this.doCollapse();
},
+ setEditorPosition: function (element, editor, shadow)
+ {
+ element;
+
+ var dim = Richfaces.Calendar.getOffsetDimensions(element);
+ editor.style.width = shadow.style.width = dim.width + 'px';
+ editor.style.height = shadow.style.height = dim.height + 'px';
+
+ Richfaces.Calendar.clonePosition([editor,shadow], element);
+ },
+
showTimeEditor: function()
{
if (this.timeType==0) return;
- if (!this.isTimeEditorCreated) this.createTimeEditor();
+ if (!this.isEditorCreated) this.createEditor();
+ if (!this.isTimeEditorLayoutCreated) this.createTimeEditorLayout();
- var element = $(this.id);
+ $(this.TIME_EDITOR_LAYOUT_ID).show();
- var te = $(this.TIME_EDITOR_ID);
- var te_shadow = $(this.TIME_EDITOR_SHADOW_ID);
+ var editor = $(this.EDITOR_ID);
+ var editor_shadow = $(this.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';
+ this.setEditorPosition($(this.id), editor, editor_shadow);
- Richfaces.Calendar.clonePosition([te,te_shadow], element);
-
this.updateTimeEditor();
- te_shadow.show();
- te.show();
+ editor_shadow.show();
+ editor.show();
- Element.clonePosition(this.TIME_EDITOR_LAYOUT_SHADOW_ID, this.TIME_EDITOR_LAYOUT_ID, {offsetLeft: 3, offsetTop: 3});
+ Element.clonePosition(this.EDITOR_LAYOUT_SHADOW_ID, this.TIME_EDITOR_LAYOUT_ID, {offsetLeft: 3, offsetTop: 3});
+ this.isEditorVisible = true;
},
+
+ hideEditor: function()
+ {
+ if (this.isTimeEditorLayoutCreated) $(this.TIME_EDITOR_LAYOUT_ID).hide();
+ if (this.isDateEditorLayoutCreated) $(this.DATE_EDITOR_LAYOUT_ID).hide();
+ $(this.EDITOR_ID).hide();
+ $(this.EDITOR_SHADOW_ID).hide();
+ this.isEditorVisible = false;
+ },
hideTimeEditor: function(updateTime)
{
- $(this.TIME_EDITOR_ID).hide();
- $(this.TIME_EDITOR_SHADOW_ID).hide();
-
+ this.hideEditor();
if (updateTime && this.selectedDate)
{
var m = parseInt($(this.id+'TimeMinutes').value,10);
@@ -1894,6 +1976,36 @@
}
if (this.params.popup && !this.showApplyButton && updateTime) this.close(true);
+ },
+
+ showDateEditor: function()
+ {
+ if (!this.isEditorCreated) this.createEditor();
+ if (!this.isDateEditorLayoutCreated) this.createDateEditorLayout();
+ else this.updateDateEditor();
+
+ $(this.DATE_EDITOR_LAYOUT_ID).show();
+
+ var editor = $(this.EDITOR_ID);
+ var editor_shadow = $(this.EDITOR_SHADOW_ID);
+
+ this.setEditorPosition($(this.id), editor, editor_shadow);
+
+ editor_shadow.show();
+ editor.show();
+
+ Element.clonePosition(this.EDITOR_LAYOUT_SHADOW_ID, this.DATE_EDITOR_LAYOUT_ID, {offsetLeft: 3, offsetTop: 3});
+
+ this.isEditorVisible = true;
+ },
+
+ hideDateEditor: function(updateCurrentDate)
+ {
+ this.hideEditor();
+ if (updateCurrentDate)
+ {
+ this.changeCurrentDate(this.dateEditorYear, this.dateEditorMonth);
+ }
}
});
@@ -1937,13 +2049,13 @@
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.currentMonthControl = function (context) { return CalendarView.getControl(Richfaces.Calendar.formatDate(context.calendar.getCurrentDate(), "MMMM, yyyy", context.monthLabels, context.monthLabelsShort), CalendarView.toolButtonAttributes, "showDateEditor");};
+CalendarView.todayControl = function (context) { return (context.calendar.todayControlMode!='hidden' ? CalendarView.getControl(context.controlLabels.today, CalendarView.toolButtonAttributes, "today") : "");};
CalendarView.selectedDateControl = function (context) { return CalendarView.getSelectedDateControl(context.calendar);};
CalendarView.timeControl = function (context) { return CalendarView.getTimeControl(context.calendar);};
-CalendarView.closeControl = function (context) { return (context.calendar.params.popup ? 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.closeControl = function (context) { return (context.calendar.params.popup ? CalendarView.getControl(context.controlLabels.close, CalendarView.toolButtonAttributes, "close", "false") : "");};
+CalendarView.applyControl = function (context) { return (context.calendar.showApplyButton ? CalendarView.getControl(context.controlLabels.apply, CalendarView.toolButtonAttributes, "close", "true") : "");};
+CalendarView.cleanControl = function (context) { return (context.calendar.selectedDate ? CalendarView.getControl(context.controlLabels.clean, CalendarView.toolButtonAttributes, "resetSelectedDate") : "");};
CalendarView.timeEditorFields = function (context) { return context.calendar.timePatternHtml;};
CalendarView.header = [
@@ -1964,7 +2076,7 @@
new E('td',{'class': 'rich-calendar-month'},
[
new ET(function (context) { return Richfaces.evalMacro("currentMonthControl", context)})
- ]),
+ ]),
new E('td',{'class': 'rich-calendar-tool'},
[
new ET(function (context) { return Richfaces.evalMacro("nextMonthControl", context)})
@@ -2015,10 +2127,8 @@
]
)];
-CalendarView.timeEditor = [
+CalendarView.timeEditorLayout = [
- 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',{},
@@ -2036,7 +2146,7 @@
[
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 ET(function (context) { return context.controlLabels.ok; })
])
])
,
@@ -2044,7 +2154,7 @@
[
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')
+ new ET(function (context) { return context.controlLabels.cancel; })
])
])
])
@@ -2064,6 +2174,7 @@
this.monthLabelsShort=calendar.params.monthLabelsShort;
this.weekDayLabels=calendar.params.weekDayLabels;
this.weekDayLabelsShort=calendar.params.weekDayLabelsShort;
+ this.controlLabels=calendar.params.labels;
},
nextYearControl: CalendarView.nextYearControl,
@@ -2077,5 +2188,6 @@
todayControl: CalendarView.todayControl,
closeControl: CalendarView.closeControl,
applyControl: CalendarView.applyControl,
- timeEditorFields: CalendarView.timeEditorFields
+ timeEditorFields: CalendarView.timeEditorFields,
+ timeEditorLayout: CalendarView.timeEditorLayout
});
\ 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 2008-01-11 15:59:48 UTC (rev 5310)
+++ branches/3.1.x/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2008-01-11 16:32:50 UTC (rev 5311)
@@ -12,7 +12,7 @@
<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>
-
+
<f:call name="addPopupToAjaxRendered" />
<span id="#{clientId}Popup"
@@ -50,7 +50,7 @@
<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}"
@@ -188,16 +188,15 @@
showWeeksBar:#{component.attributes['showWeeksBar']},
showWeekDaysBar:#{component.attributes['showWeekDaysBar']},
showApplyButton:#{component.attributes['showApplyButton']}
+
+ <f:call name="writeLabels" />
-
-
<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>
More information about the richfaces-svn-commits
mailing list