Author: pyaschenko
Date: 2008-10-03 12:40:37 -0400 (Fri, 03 Oct 2008)
New Revision: 10666
Modified:
trunk/ui/calendar/src/main/config/component/calendar.xml
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
Log:
https://jira.jboss.org/jira/browse/RF-4001
also readonly attribute has been added
Modified: trunk/ui/calendar/src/main/config/component/calendar.xml
===================================================================
--- trunk/ui/calendar/src/main/config/component/calendar.xml 2008-10-03 15:55:25 UTC (rev
10665)
+++ trunk/ui/calendar/src/main/config/component/calendar.xml 2008-10-03 16:40:37 UTC (rev
10666)
@@ -151,6 +151,15 @@
<defaultvalue>false</defaultvalue>
</property>
<property>
+ <name>readonly</name>
+ <classname>boolean</classname>
+ <description>
+ If "true". Date and time are not selectable. In
+ "popup" mode input is disabled and button is enabled. Default value
is "false".
+ </description>
+ <defaultvalue>false</defaultvalue>
+ </property>
+ <property>
<name>jointPoint</name>
<classname>java.lang.String</classname>
<description>
Modified:
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss
===================================================================
---
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss 2008-10-03
15:55:25 UTC (rev 10665)
+++
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss 2008-10-03
16:40:37 UTC (rev 10666)
@@ -228,6 +228,11 @@
<u:style name="white-space" value="nowrap"/>
</u:selector>
+ <u:selector name=".rich-calendar-tool-btn-disabled">
+ <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-color"
skin="calendarWeekBackgroundColor"/>
<u:style name="color" skin="generalTextColor"/>
Modified:
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
---
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2008-10-03
15:55:25 UTC (rev 10665)
+++
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2008-10-03
16:40:37 UTC (rev 10666)
@@ -570,6 +570,9 @@
// style - table style
// className - table class
+ // disabled
+ // readonly
+
//var _d = new Date();
this.id = id;
@@ -610,7 +613,6 @@
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 "";};
@@ -678,13 +680,7 @@
var htmlTextWeekDayBar='';
var context;
-// TODO (version 3.3.0): remove onmouse over/up/out/down css classes and onclick
listeners if component disabled
-// var eventsStr = "";
-// if (!this.params.disabled) {
-// eventsStr = 'onclick="'+tempStr+'eventCellOnClick(event,
this);" onmouseover="'+tempStr+'eventCellOnMouseOver(event, this);"
onmouseout="'+tempStr+'eventCellOnMouseOut(event, this);"';
-// }
-
- var eventsStr = 'onclick="'+tempStr+'eventCellOnClick(event,
this);" onmouseover="'+tempStr+'eventCellOnMouseOver(event, this);"
onmouseout="'+tempStr+'eventCellOnMouseOut(event, this);"';
+ var eventsStr = this.params.disabled || this.params.readonly ? '' :
'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+'">';
@@ -1654,7 +1650,7 @@
if (dataobj._month!=0)
{
classNames+=' rich-calendar-boundary-dates';
- if (boundaryDatesModeFlag)
+ if (!this.params.disabled && !this.params.readonly &&
boundaryDatesModeFlag)
{
classNames+=' rich-calendar-btn';
}
@@ -1674,7 +1670,7 @@
this.selectedDateCellColor = this.getCellBackgroundColor(element);
classNames+=" rich-calendar-select";
}
- else if (dataobj.enabled) classNames+=' rich-calendar-btn';
+ else if (!this.params.disabled && !this.params.readonly &&
dataobj.enabled) classNames+=' rich-calendar-btn';
// add custom style class
if (dataobj.customStyleClass)
@@ -1839,7 +1835,7 @@
}
// todayControl select mode
- if (this.todayControlMode=='select')
+ if (this.todayControlMode=='select' && !this.params.disabled
&& !this.params.readonly)
if (updateflag && !noUpdate && this.submitFunction)
{
this.afterLoad = this.selectToday;
@@ -1923,7 +1919,7 @@
// find cell and change style class
var e = $(this.DATE_ELEMENT_ID+(this.firstDateIndex +
this.selectedDate.getDate()-1));
- this.clearEffect(this.selectedDateCellId, this.highlightEffect2,
"rich-calendar-select", "rich-calendar-btn");
+ this.clearEffect(this.selectedDateCellId, this.highlightEffect2,
"rich-calendar-select", (this.params.disabled || this.params.readonly ? null :
"rich-calendar-btn"));
this.selectedDateCellId = e.id;
this.selectedDateCellColor = this.getCellBackgroundColor(e);
@@ -1947,7 +1943,7 @@
{
this.selectedDate = null;
- this.clearEffect(this.selectedDateCellId, this.highlightEffect2,
"rich-calendar-select", "rich-calendar-btn");
+ this.clearEffect(this.selectedDateCellId, this.highlightEffect2,
"rich-calendar-select", (this.params.disabled || this.params.readonly ? null :
"rich-calendar-btn"));
if (this.selectedDateCellId)
{
@@ -1989,7 +1985,7 @@
this.selectedDate = null;
this.invokeEvent("dateselected", null, null, null);
- this.selectedDateCellId = this.clearEffect(this.selectedDateCellId,
this.highlightEffect2, "rich-calendar-select", "rich-calendar-btn");
+ this.selectedDateCellId = this.clearEffect(this.selectedDateCellId,
this.highlightEffect2, "rich-calendar-select", (this.params.disabled ||
this.params.readonly ? null : "rich-calendar-btn"));
this.renderHF();
if (!this.showApplyButton)
@@ -2143,9 +2139,7 @@
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)]);
};
@@ -2154,13 +2148,10 @@
if (!calendar.selectedDate || calendar.showApplyButton) return "";
var text = Richfaces.Calendar.formatDate(calendar.selectedDate,(calendar.timeType ?
calendar.datePattern : calendar.params.datePattern), calendar.params.monthLabels,
calendar.params.monthLabelsShort);
-// TODO: version: 3.3.0
-// var onclick ="";
-// if(!calendar.params.disabled) {
-// onclick = "Richfaces.getComponent('calendar',this).showSelectedDate();
return true;"
-// }
var onclick = "Richfaces.getComponent('calendar',this).showSelectedDate();
return true;"
- var markup = new E('div', {'class': 'rich-calendar-tool-btn',
'onclick': onclick}, [new ET(text)]);
+ var markup = ( calendar.params.disabled ?
+ new E('div', {'class': 'rich-calendar-tool-btn-disabled'},
[new ET(text)]) :
+ new E('div', {'class': 'rich-calendar-tool-btn',
'onclick': onclick}, [new ET(text)]) );
return markup;
};
@@ -2170,17 +2161,13 @@
if (!calendar.selectedDate || !calendar.timeType) return "";
var text = Richfaces.Calendar.formatDate(calendar.selectedDate, calendar.timePattern,
calendar.params.monthLabels, calendar.params.monthLabelsShort);
-
+
var onmouseover = "Element.removeClassName(this,
'rich-calendar-tool-btn-press');";
var onmouseout = "Element.addClassName(this,
'rich-calendar-tool-btn-press');";
var onclick =
"Richfaces.getComponent('calendar',this).showTimeEditor();return
true;";
-// TODO: version: 3.3.0
-// if(!calendar.params.disabled) {
-// onmouseover = "Element.removeClassName(this,
'rich-calendar-tool-btn-press');";
-// onmouseout = "Element.addClassName(this,
'rich-calendar-tool-btn-press');";
-// onclick =
"Richfaces.getComponent('calendar',this).showTimeEditor();return
true;";
-// }
- var markup = new E('div', {'class': 'rich-calendar-tool-btn
rich-calendar-tool-btn-hover rich-calendar-tool-btn-press', 'onclick':
onclick,
+ var markup = calendar.params.disabled || calendar.params.readonly ?
+ new E('div', {'class': 'rich-calendar-tool-btn-disabled'},
[new ET(text)]) :
+ new E('div', {'class': 'rich-calendar-tool-btn
rich-calendar-tool-btn-hover rich-calendar-tool-btn-press', 'onclick':
onclick,
'onmouseover': + onmouseover ,
'onmouseout' : + onmouseout}, [new ET(text)]);
@@ -2188,48 +2175,36 @@
};
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");
-//TODO: version: 3.3.0
-//CalendarView.clearAttributesIfDisabled = function (calendar, attributes){
-// var disabled = calendar.params.disabled;
-// if (disabled && attributes) {
-// attributes.onmouseup = "";
-// attributes.onmousedown = "";
-// attributes.onmouseover = "";
-// attributes.onmouseout = "";
-// attributes.onclick = "";
-// }
-// return attributes;
-//}
-
+CalendarView.nextYearControl = function (context) {
+ return (!context.calendar.params.disabled ?
CalendarView.getControl(">>", CalendarView.toolButtonAttributes,
"nextYear") : "");
+};
+CalendarView.previousYearControl = function (context) {
+ return (!context.calendar.params.disabled ?
CalendarView.getControl("<<", CalendarView.toolButtonAttributes,
"prevYear") : "");
+};
+CalendarView.nextMonthControl = function (context) {
+ return (!context.calendar.params.disabled ? CalendarView.getControl(">",
CalendarView.toolButtonAttributes, "nextMonth") : "");
+};
+CalendarView.previousMonthControl = function (context) {
+ return (!context.calendar.params.disabled ? CalendarView.getControl("<",
CalendarView.toolButtonAttributes, "prevMonth") : "");
+};
CalendarView.currentMonthControl = function (context) {
-// TODO: version: 3.3.0
-// var attributes =
CalendarView.clearAttributesIfDisabled(context.calendar,CalendarView.toolButtonAttributes);
- return
CalendarView.getControl(Richfaces.Calendar.formatDate(context.calendar.getCurrentDate(),
"MMMM, yyyy", context.monthLabels, context.monthLabelsShort),
CalendarView.toolButtonAttributes, "showDateEditor");
+ var text = Richfaces.Calendar.formatDate(context.calendar.getCurrentDate(), "MMMM,
yyyy", context.monthLabels, context.monthLabelsShort);
+ var markup = context.calendar.params.disabled ?
+ new E('div',{className: "rich-calendar-tool-btn-disabled"},[new
T(text)]) :
+ CalendarView.getControl(text, CalendarView.toolButtonAttributes,
"showDateEditor");
+ return markup;
};
CalendarView.todayControl = function (context) {
-// TODO: version: 3.3.0
-// var attributes =
CalendarView.clearAttributesIfDisabled(context.calendar,CalendarView.toolButtonAttributes);
- return (context.calendar.todayControlMode!='hidden' ?
CalendarView.getControl(context.controlLabels.today, CalendarView.toolButtonAttributes,
"today") : "");
+ return (!context.calendar.params.disabled &&
context.calendar.todayControlMode!='hidden' ?
CalendarView.getControl(context.controlLabels.today, CalendarView.toolButtonAttributes,
"today") : "");
};
-
CalendarView.closeControl = function (context) {
-// TODO: version: 3.3.0
-// var attributes =
CalendarView.clearAttributesIfDisabled(context.calendar,CalendarView.toolButtonAttributes);
return (context.calendar.params.popup ?
CalendarView.getControl(context.controlLabels.close, CalendarView.toolButtonAttributes,
"close", "false") : "");
};
CalendarView.applyControl = function (context) {
-// TODO: version: 3.3.0
-// var attributes =
CalendarView.clearAttributesIfDisabled(context.calendar,CalendarView.toolButtonAttributes);
- return (context.calendar.showApplyButton ?
CalendarView.getControl(context.controlLabels.apply, CalendarView.toolButtonAttributes,
"close", "true") : "");
+ return (!context.calendar.params.disabled && !context.calendar.params.readonly
&& context.calendar.showApplyButton ?
CalendarView.getControl(context.controlLabels.apply, CalendarView.toolButtonAttributes,
"close", "true") : "");
};
CalendarView.cleanControl = function (context) {
-// TODO: version: 3.3.0
-// var attributes =
CalendarView.clearAttributesIfDisabled(context.calendar,CalendarView.toolButtonAttributes);
- return (context.calendar.selectedDate ?
CalendarView.getControl(context.controlLabels.clean, CalendarView.toolButtonAttributes,
"resetSelectedDate") : "");
+ return (!context.calendar.params.disabled && !context.calendar.params.readonly
&& context.calendar.selectedDate ?
CalendarView.getControl(context.controlLabels.clean, CalendarView.toolButtonAttributes,
"resetSelectedDate") : "");
};
CalendarView.selectedDateControl = function (context) { return
CalendarView.getSelectedDateControl(context.calendar);};
@@ -2291,8 +2266,8 @@
[
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 E('td',{'class': 'rich-calendar-toolfooter',
'style': 'background-image:none;', 'width': '100%'}, []),
+ new E('td',{'class': 'rich-calendar-toolfooter',
'style':function(context){return (this.isEmpty ? 'display:none;' :
'')+(context.calendar.params.disabled || context.calendar.params.readonly ||
!context.calendar.showApplyButton ? 'background-image:none;' : '');}},
[
new ET(function (context) { return Richfaces.evalMacro("todayControl",
context)})
]),
@@ -2359,27 +2334,6 @@
this.weekDayLabels=calendar.params.weekDayLabels;
this.weekDayLabelsShort=calendar.params.weekDayLabelsShort;
this.controlLabels=calendar.params.labels;
-
-// TODO: remove onmouse over/up/out/down css classes and onclick listeners if component
disabled (version 3.3.0)
-// if (this.nextYearControl) {
-// var attrs = this.nextYearControl.attrs;
-// CalendarView.clearAttributesIfDisabled(this.calendar, attrs);
-// }
-//
-// if (this.previousYearControl) {
-// var attrs = this.previousYearControl.attrs;
-// CalendarView.clearAttributesIfDisabled(this.calendar, attrs);
-// }
-//
-// if (this.previousMonthControl) {
-// var attrs = this.previousMonthControl.attrs;
-// CalendarView.clearAttributesIfDisabled(this.calendar, attrs);
-// }
-//
-// if (this.nextMonthControl) {
-// var attrs = this.nextMonthControl.attrs;
-// CalendarView.clearAttributesIfDisabled(this.calendar, attrs);
-// }
},
nextYearControl: CalendarView.nextYearControl,
previousYearControl: CalendarView.previousYearControl,
Modified: trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
--- trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2008-10-03
15:55:25 UTC (rev 10665)
+++ trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2008-10-03
16:40:37 UTC (rev 10666)
@@ -72,7 +72,8 @@
<jsp:scriptlet>
<![CDATA[
boolean manualInput = getUtils().isBooleanAttribute(component,
"enableManualInput");
- if(!manualInput){
+ boolean readonly = getUtils().isBooleanAttribute(component, "readonly");
+ if(!manualInput || readonly){
getUtils().writeAttribute(writer, "readonly", "readonly");
}
]]>
@@ -177,6 +178,7 @@
enableManualInput: #{component.attributes['enableManualInput']},
showInput: #{component.attributes['showInput']},
disabled: #{component.disabled},
+ readonly: #{component.attributes['readonly']},
ajaxSingle: #{component.attributes['ajaxSingle']},
verticalOffset:#{component.verticalOffset},
horizontalOffset: #{component.horizontalOffset},