Author: pyaschenko
Date: 2007-07-20 08:55:55 -0400 (Fri, 20 Jul 2007)
New Revision: 1734
Modified:
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
Log:
Modified:
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
---
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-07-20
12:30:34 UTC (rev 1733)
+++
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-07-20
12:55:55 UTC (rev 1734)
@@ -132,8 +132,8 @@
// showWeekDaysBar - show WeekDays Bar [default value is true]
// showWeeksBar - show Weeks numbers bar [default value is true]
- // headerHtml - user defined header (optional)
- // footeHtml - user defined footer (optional)
+ // headerOptionalMarkup - user defined header (optional)
+ // footerOptionalMarkup - user defined footer (optional)
// direction - [top-left, top-right, bottom-left, bottom-right, auto]
// jointPoint
@@ -172,10 +172,10 @@
'<input id="'+this.id+'InputCurrentDate"
name="'+this.id+'InputCurrentDate" type="hidden"
value="'+this.getCurrentDate().format("MM/y")+'"/>\n'
+
'<table border="0" cellpadding="0"
cellspacing="0" class="calendar_exterior"><tbody>\n';
var colspan = (this.params.showWeeksBar ? "8" : "7");
- var htmlHeaderOptional = (this.params.headerHtml &&
this.params.headerHtml!='') ? '<tr><td
class="calendar_header"
colspan="'+colspan+'">'+this.params.headerHtml+'</td></tr>'
: '';
- var htmlFooterOptional = (this.params.footerHtml &&
this.params.footerHtml!='') ? '<tr><td
class="calendar_footer"
colspan="'+colspan+'">'+this.params.footerHtml+'</td></tr>'
: '';
- var htmlControlsHeader = '<tr><td colspan="'+colspan+'"
id="'+this.id+':header"></td></tr>'
- var htmlControlsFooter = '<tr><td colspan="'+colspan+'"
id="'+this.id+':footer"></td></tr>'
+ var htmlHeaderOptional = (this.params.headerOptionalMarkup) ? '<tr><td
class="calendar_header" colspan="'+colspan+'"
id="'+this.id+'HeaderOptional"></td></tr>' :
'';
+ var htmlFooterOptional = (this.params.footerOptionalMarkup) ? '<tr><td
class="calendar_footer" colspan="'+colspan+'"
id="'+this.id+'FooterOptional"></td></tr>' :
'';
+ var htmlControlsHeader = (Calendar.header) ? '<tr><td
colspan="'+colspan+'"
id="'+this.id+'Header"></td></tr>' : '';
+ var htmlControlsFooter = (Calendar.footer) ? '<tr><td
colspan="'+colspan+'"
id="'+this.id+'Footer"></td></tr>' : '';
var htmlTextFooter = '</tbody></table>\n';
// days bar creation
@@ -189,7 +189,7 @@
var weekDayCounter = this.params.firstWeekDay;
for (var i=0;i<7;i++)
{
- var weekDayHtml = this.params.weekDayMarkup( {weekDayLabel:
this.params.weekDayLabels[weekDayCounter], weekDayNumber:weekDayCounter,
componentId:this.getWeekDayComponentId(i)} );
+ var weekDayHtml = this.evaluateMarkup(this.params.weekDayMarkup, {weekDayLabel:
this.params.weekDayLabels[weekDayCounter], weekDayNumber:weekDayCounter,
componentId:this.getWeekDayComponentId(i)} );
if (weekDayCounter==6) weekDayCounter=0; else weekDayCounter++;
styleClass = (i==this.firstWeekendDayNumber || i==this.secondWeekendDayNumber ?
"Weekendclass" : "calendar_days");
@@ -208,7 +208,7 @@
htmlTextWeek+='<tr
id="'+this.params.weekNumberBarId+k+'">';
if (this.params.showWeeksBar)
{
- var weekNumberHtml = this.params.weekNumberMarkup( {weekNumber: k,
componentId:this.getWeekNumberComponentId(k-1)} );
+ var weekNumberHtml = this.evaluateMarkup(this.params.weekNumberMarkup, {weekNumber:
k, componentId:this.getWeekNumberComponentId(k-1)} );
htmlTextWeek+='<td
class="calendar_week">'+weekNumberHtml+'</td>';
}
@@ -481,6 +481,8 @@
// render
this.renderHeader();
this.renderFooter();
+ this.renderHeaderOptional();
+ this.renderFooterOptional();
//days render
p=0;
@@ -513,7 +515,7 @@
wn=1;
weekflag=false;
}
- element.innerHTML = this.params.weekNumberMarkup( {weekNumber: wn++,
componentId:this.getWeekNumberComponentId(k-1)} );
+ element.innerHTML = this.evaluateMarkup(this.params.weekNumberMarkup, {weekNumber:
wn++, componentId:this.getWeekNumberComponentId(k-1)} );
if (k==1&&wn>52) wn=1;
element = element.nextSibling;
}
@@ -526,7 +528,7 @@
element.data=dataobj.day;
dataobj.componentId=this.getDateComponentId(p);
- element.innerHTML = this.params.dayListMarkup( dataobj );
+ element.innerHTML = this.evaluateMarkup(this.params.dayListMarkup, dataobj );
// class styles
e = Element.classNames(element);
@@ -549,22 +551,40 @@
},
renderHeader: function()
{
- var header = $(this.id+":header");
- if (header)
- {
- header.innerHTML = Calendar.header.getContent(this.calendarContext);
- }
+ this.renderMarkup(Calendar.header, this.id+"Header", this.calendarContext);
},
renderFooter: function()
{
- var footer = $(this.id+":footer");
- if (footer)
- {
- footer.innerHTML = Calendar.footer.getContent(this.calendarContext);
- }
+ this.renderMarkup(Calendar.footer, this.id+"Footer", this.calendarContext);
},
+
+ renderHeaderOptional: function()
+ {
+ this.renderMarkup(this.params.headerOptionalMarkup, this.id+"HeaderOptional",
this.calendarContext);
+ },
+
+ renderFooterOptional: function()
+ {
+ this.renderMarkup(this.params.footerOptionalMarkup, this.id+"FooterOptional",
this.calendarContext);
+ },
+ renderMarkup: function (markup, elementId, context)
+ {
+ if (!markup) return;
+
+ var e = $(elementId);
+ if (!e) return;
+
+ e.innerHTML = markup.invoke('getContent', context).join('');
+ },
+
+ evaluateMarkup: function(markup, context)
+ {
+ if (!markup) return "";
+ return markup.invoke('getContent', context).join('');
+ },
+
onUpdate: function()
{
var formattedDate = this.getCurrentDate().format("MM/y");
@@ -677,7 +697,7 @@
};
-Calendar.header =
+Calendar.header = [
new E('table',{'border': '0', 'cellpadding':
'0', 'cellspacing': '0', 'width': '100%'},
[
new E('tbody',{},
@@ -707,9 +727,9 @@
])
])
]
- );
+ )];
-Calendar.footer =
+Calendar.footer = [
new E('table',{'border': '0', 'cellpadding':
'0', 'cellspacing': '0', 'width': '100%'},
[
new E('tbody',{},
@@ -731,7 +751,7 @@
])
])
]
- );
+ )];
CalendarContext = Class.create();
Modified: trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
---
trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-07-20
12:30:34 UTC (rev 1733)
+++
trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-07-20
12:55:55 UTC (rev 1734)
@@ -32,8 +32,8 @@
monthLabelsShort: ['Jan', 'Feb', 'Mar', 'Apr',
'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
'Nov', 'Dec'],
firstWeekDay: 0,
minDaysInFirstWeek: 4,
- headerHtml: '<b>User defined header</b>',
- footerHtml: 'User defined footer',
+ headerOptionalMarkup: [new E('b',{},[new T('User defined
header')])],
+ footerOptionalMarkup: [new E('b',{},[new T('User defined
header')])],
dayListMarkup:
<jsp:scriptlet>/*<![CDATA[*/
if (component.getChildCount() != 0) {