Author: pyaschenko
Date: 2007-07-20 12:08:25 -0400 (Fri, 20 Jul 2007)
New Revision: 1749
Modified:
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
Log:
macrodefinitions improvements
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
15:41:04 UTC (rev 1748)
+++
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-07-20
16:08:25 UTC (rev 1749)
@@ -123,6 +123,10 @@
// dayListMarkup - day cell markup
// weekNumberMarkup - week number cell markup
// weekDayMarkup - week day cell markup
+ // headerMarkup
+ // footerMarkup
+ // headerOptionalMarkup - user defined header (optional)
+ // footerOptionalMarkup - user defined footer (optional)
// currentDate - date to show month (day not used) (mm/yyyy)
// selectedDate - selected date (mm/dd/yyyy)
@@ -132,9 +136,6 @@
// showWeekDaysBar - show WeekDays Bar [default value is true]
// showWeeksBar - show Weeks numbers bar [default value is true]
- // headerOptionalMarkup - user defined header (optional)
- // footerOptionalMarkup - user defined footer (optional)
-
// direction - [top-left, top-right, bottom-left, bottom-right, auto]
// jointPoint
// popup - true
@@ -147,8 +148,15 @@
if (!this.params.showWeekDaysBar) this.params.showWeekDaysBar = true;
if (!this.params.showWeeksBar) this.params.showWeeksBar = true;
if (this.params.monthLabels) this.params.monthLabels.push(this.params.monthLabels[0]);
- if (!this.params.datePattern) this.params.datePattern = "MMM d, y"
+ if (!this.params.datePattern) this.params.datePattern = "MMM d, y";
+ // markups initialization
+ if (!this.params.dayListMarkup) this.params.dayListMarkup = CalendarView.dayList;
+ 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;
+ if (!this.params.footerMarkup) this.params.footerMarkup = CalendarView.footer;
+
this.currentDate = this.params.currentDate ? this.params.currentDate : new Date();
this.selectedDate = this.params.selectedDate;
@@ -174,8 +182,8 @@
var colspan = (this.params.showWeeksBar ? "8" : "7");
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 htmlControlsHeader = '<tr><td colspan="'+colspan+'"
id="'+this.id+'Header"></td></tr>';
+ var htmlControlsFooter = '<tr><td colspan="'+colspan+'"
id="'+this.id+'Footer"></td></tr>';
var htmlTextFooter = '</tbody></table>\n';
// days bar creation
@@ -551,12 +559,12 @@
},
renderHeader: function()
{
- this.renderMarkup(Calendar.header, this.id+"Header", this.calendarContext);
+ this.renderMarkup(this.params.headerMarkup, this.id+"Header",
this.calendarContext);
},
renderFooter: function()
{
- this.renderMarkup(Calendar.footer, this.id+"Footer", this.calendarContext);
+ this.renderMarkup(this.params.footerMarkup, this.id+"Footer",
this.calendarContext);
},
renderHeaderOptional: function()
@@ -640,64 +648,26 @@
});
-Calendar.getDayView = function(context) {
- return Richfaces.evalSimpleMacro("day", context);
-};
+CalendarView = {};
-Calendar.getWeekNumberView = function(context) {
- return Richfaces.evalSimpleMacro("weekNumber", context);
-};
-
-Calendar.getWeekDayView = function(context) {
- return Richfaces.evalSimpleMacro("weekDayLabel", context);
-};
-
-Calendar.getControl = function(context, attributes, text, functionName) {
+CalendarView.getControl = function(text, functionName) {
var attr = {
onclick: (functionName ?
"Richfaces.invokeOnComponent('richfaces:calendar',this,'"+functionName+"');"
: "")+"return false;",
- width: "100%"
};
- if (attributes) {
- Object.extend(attr, attributes);
- }
- return new E('div',attr,[new T(text)]);
+ return new E('span',attr,[new T(text)]);
};
-Calendar.nextYearControl = function(context) {
- //return Calendar.getControl(context, null, ">>
"+context.calendar.getNextYear(), "nextYear");
- return Calendar.getControl(context, null, "��", "nextYear");
-};
-Calendar.previousYearControl = function(context) {
- //return Calendar.getControl(context, null, context.calendar.getPrevYear()+"
<<", "prevYear");
- return Calendar.getControl(context, null, "��", "prevYear");
-};
-Calendar.nextMonthControl = function(context) {
- //return Calendar.getControl(context, null, ">
"+context.calendar.getNextMonth(true), "nextMonth");
- return Calendar.getControl(context, null, "�", "nextMonth");
-};
-Calendar.previousMonthControl = function(context) {
- //return Calendar.getControl(context, null, context.calendar.getPrevMonth(true)+"
<", "prevMonth");
- return Calendar.getControl(context, null, "�", "prevMonth");
-};
-Calendar.currentMonthControl = function(context) {
- var value =context.calendar.getCurrentDate().format("MMMM, y",
context.monthLabels, context.monthLabelsShort);
- return value;
-};
-Calendar.todayControl = function(context) {
- return Calendar.getControl(context, null, "Today", "today");
-};
-Calendar.selectedDateControl = function(context) {
- var value = Calendar.getControl(context, null,
context.calendar.getSelectedDateString(context.calendar.params.datePattern),
"prevMonth");
- return value;
-};
-Calendar.helpControl = function(context)
-{
- return Calendar.getControl(context, null, "Help", "help");
-};
+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, y", context.monthLabels,
context.monthLabelsShort);};
+CalendarView.todayControl = CalendarView.getControl("Today",
"today");
+CalendarView.selectedDateControl = function (context) { return
CalendarView.getControl(context.calendar.getSelectedDateString(context.calendar.params.datePattern),
"prevMonth");};
+CalendarView.helpControl = CalendarView.getControl("Help", "help");
-
-Calendar.header = [
+CalendarView.header = [
new E('table',{'border': '0', 'cellpadding':
'0', 'cellspacing': '0', 'width': '100%'},
[
new E('tbody',{},
@@ -729,7 +699,7 @@
]
)];
-Calendar.footer = [
+CalendarView.footer = [
new E('table',{'border': '0', 'cellpadding':
'0', 'cellspacing': '0', 'width': '100%'},
[
new E('tbody',{},
@@ -738,22 +708,25 @@
[
new E('td',{'class': 'calendar_toolfooter', 'style':
'white-space:nowrap'},
[
- new ET(function (context) { return
Richfaces.evalMacro("Calendar.selectedDateControl", context)})
+ new ET(function (context) { return
Richfaces.evalMacro("selectedDateControl", context)})
]),
new E('td',{'class': 'calendar_toolfooter calendar_btn',
'width': '100%'},
[
- new ET(function (context) { return
Richfaces.evalMacro("Calendar.helpControl", context)})
+ new ET(function (context) { return Richfaces.evalMacro("helpControl",
context)})
]),
new E('td',{'class': 'calendar_toolfooter calendar_btn',
'align': 'right'},
[
- new ET(function (context) { return
Richfaces.evalMacro("Calendar.todayControl", context)})
+ new ET(function (context) { return Richfaces.evalMacro("todayControl",
context)})
])
])
])
]
)];
-
+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.weekDayLabel})];
+
CalendarContext = Class.create();
Object.extend(CalendarContext.prototype, {
initialize: function(calendar) {
@@ -762,12 +735,12 @@
this.monthLabelsShort=calendar.params.monthLabelsShort;
},
- nextYearControl: Calendar.nextYearControl,
- previousYearControl: Calendar.previousYearControl,
- nextMonthControl: Calendar.nextMonthControl,
- previousMonthControl: Calendar.previousMonthControl,
- currentMonthControl: Calendar.currentMonthControl,
- todayControl: Calendar.todayControl,
- selectedDateControl: Calendar.selectedDateControl,
- helpControl: Calendar.helpControl,
+ nextYearControl: CalendarView.nextYearControl,
+ previousYearControl: CalendarView.previousYearControl,
+ nextMonthControl: CalendarView.nextMonthControl,
+ previousMonthControl: CalendarView.previousMonthControl,
+ currentMonthControl: CalendarView.currentMonthControl,
+ todayControl: CalendarView.todayControl,
+ selectedDateControl: CalendarView.selectedDateControl,
+ helpControl: CalendarView.helpControl
});
\ No newline at end of file