Author: pyaschenko
Date: 2007-07-29 12:47:44 -0400 (Sun, 29 Jul 2007)
New Revision: 1911
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:
popup mode updates
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-29
16:41:01 UTC (rev 1910)
+++
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-07-29
16:47:44 UTC (rev 1911)
@@ -433,7 +433,7 @@
var htmlTextIFrame = '';
this.isVisible = true;
- //if (this.params.popup==true)
+ if (this.params.popup==true)
{
// popup mode initialisation
var e = $(this.id);
@@ -441,10 +441,8 @@
{
e.style.display='none';
e.style.position = 'absolute';
- //e.style.left="0px";
- //e.style.top="0px";
this.isVisible = false;
- //if (Richfaces.browser.isIE6)
+ 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>');
@@ -510,36 +508,36 @@
},
doCollapse: function() {
- if (/*!this.params.popup || */!this.isVisible) return;
+ if (!this.params.popup || !this.isVisible) return;
- Element.hide(this.IFRAME_ID);
+ if (Richfaces.browser.isIE6) Element.hide(this.IFRAME_ID);
Element.hide(this.id);
this.isVisible = false;
},
doExpand: function() {
- if (/*!this.params.popup || */this.isVisible) return;
+ if (!this.params.popup || this.isVisible) return;
var field = $(this.POPUP_INPUT_ID);
-/* if (field)
+ if (field && field.value!=undefined)
{
- var date = Date.parseDate(field.value, this.params.datePattern,
this.params.monthLabels, this.params.monthLabelsShort);
- this.selectedDate = Date.parseDate(field.value, this.params.datePattern,
this.params.monthLabels, this.params.monthLabelsShort);
- if (this.selectedDate==null) this.currebn
- }*/
+ this.selectDate(field.value, true);
+ }
var base = $(this.POPUP_ID);
var e = $(this.id);
var iframe = $(this.IFRAME_ID);
Richfaces.Calendar.setElementPosition(e, base, this.params.jointPoint,
this.params.direction);
- iframe.style.left = e.style.left;
- iframe.style.top = e.style.top;
- var edim = Richfaces.Calendar.getOffsetDimensions(e);
- iframe.style.width = edim.width+'px';
- iframe.style.height = edim.height+'px';
-
- Element.show(iframe);
+ if (Richfaces.browser.isIE6)
+ {
+ iframe.style.left = e.style.left;
+ iframe.style.top = e.style.top;
+ var edim = Richfaces.Calendar.getOffsetDimensions(e);
+ iframe.style.width = edim.width+'px';
+ iframe.style.height = edim.height+'px';
+ Element.show(iframe);
+ }
Element.show(e);
this.isVisible = true;
@@ -645,6 +643,14 @@
$(this.id+'InputSelectedDate').value=this.getSelectedDateString(this.params.datePattern);
this.renderHeader();
this.renderFooter();
+
+ // popup mode
+ if (this.params.popup)
+ {
+ var field = $(this.POPUP_INPUT_ID);
+ if (field && field.value!=undefined)
field.value=$(this.id+'InputSelectedDate').value;
+ this.doCollapse();
+ }
} else {
if (daydata._month==-1) this.prevMonth(); else this.nextMonth();
}
@@ -931,7 +937,7 @@
this.onUpdate();
},
- today: function() {
+ today: function(noUpdate) {
var now = new Date();
var nowyear = now.getFullYear();
var nowmonth = now.getMonth();
@@ -946,37 +952,39 @@
this.currentDate = new Date(nowyear, nowmonth, 1);
}
- if (updateflag) this.onUpdate();
+ if (updateflag) if (noUpdate) this.render; else this.onUpdate();
},
help: function() {
alert("Calendar help");
},
- selectDate: function(date) {
+ selectDate: function(date, noUpdate) {
if (date)
{
- if (typeof date=='string') date = Date.parseDate(date,this.params.datePattern,
this.params.monthLabels, this.params.monthLabelsShort)
- if (this.selectedDate && this.selectedDate == date) return;
- this.selectedDate = date;
- }
-
- if (this.selectedDate)
- {
- var d = new Date(this.selectedDate);
- d.setDate(1);
- if (d.getMonth()==this.currentDate.getMonth() &&
d.getFullYear()==this.currentDate.getFullYear())
+ if (typeof date=='string') date = Date.parseDate(date,this.params.datePattern,
this.params.monthLabels, this.params.monthLabelsShort);
+ if (date!=null)
{
- // find cell and call onklick event
- var e = $(this.DATE_ELEMENT_ID+(this.firstDateIndex +
this.selectedDate.getDate()-1));
- if (e) Richfaces.createEvent ('click', e).fire();
- } else {
- // change currentDate and call this.onUpdate();
- this.currentDate = d;
- this.onUpdate();
-
+ if (this.selectedDate!=null &&
this.selectedDate.toLocaleDateString()==date.toLocaleDateString()) return;
+ this.selectedDate = date;
+ var d = new Date(this.selectedDate);
+ d.setDate(1);
+ if (d.getMonth()==this.currentDate.getMonth() &&
d.getFullYear()==this.currentDate.getFullYear())
+ {
+ // find cell and call onklick event
+ var e = $(this.DATE_ELEMENT_ID+(this.firstDateIndex +
this.selectedDate.getDate()-1));
+ if (e) Richfaces.createEvent ('click', e).fire();
+ return;
+ } else {
+ // change currentDate and call this.onUpdate();
+ this.currentDate = d;
+ if (noUpdate) this.render(); else this.onUpdate();
+ return;
+ }
}
}
+ this.selectedDate=null;
+ this.today(noUpdate);
}
});
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-29
16:41:01 UTC (rev 1910)
+++
trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-07-29
16:47:44 UTC (rev 1911)
@@ -30,7 +30,7 @@
datePattern: '#{component.datePattern}',
jointPoint: '#{component.jointPoint}',
direction: '#{component.direction}',
- popup: '#{component.popup}',
+ popup: #{component.popup},
<f:call name="writeSymbols" />,
firstWeekDay: #{this:getFirstWeekDay(context, component)},
minDaysInFirstWeek: #{this:getMinDaysInFirstWeek(context, component)},
@@ -60,11 +60,11 @@
boolean popup = getUtils().isBooleanAttribute(component, "popup");
if (popup) {]]>
</jsp:scriptlet>
- <span
+ <span
id="#{clientId}Popup"
<input
x:passThruWithExclusions="name"
- id="#{clientId}Input"
+ id="#{clientId}PopupInput"
value="#{this:getInputValue(context,component)}"
type="text"
readonly="#{component.attributes['readonly']}"