Author: pyaschenko
Date: 2007-12-11 12:16:02 -0500 (Tue, 11 Dec 2007)
New Revision: 4727
Modified:
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
Log:
RF-1582
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 2007-12-11
17:13:51 UTC (rev 4726)
+++
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-12-11
17:16:02 UTC (rev 4727)
@@ -207,6 +207,58 @@
return {left:windowOffset.left, top:windowOffset.top, right:
windowDim.width+windowOffset.left, bottom: windowDim.height+windowOffset.top};
};
+Richfaces.Calendar.clonePosition = function (elements, source)
+{
+ if (!elements.length) elements = [elements];
+ var offset = Position.cumulativeOffset(source);
+ offset = {left:offset[0], top:offset[1]};
+ var offsetTemp;
+ if (source.style.position!='absolute')
+ {
+ offsetTemp = Position.realOffset(source);
+ offset.left -= offsetTemp.left;
+ offset.top -= offsetTemp.top;
+ offsetTemp = Richfaces.Calendar.getWindowScrollOffset();
+ offset.left += offsetTemp.left;
+ offset.top += offsetTemp.top;
+ }
+
+ for (var i=0;i<elements.length;i++)
+ {
+ offsetTemp = Richfaces.Calendar.getParentOffset(elements[i]);
+ elements[i].style.left = (offset.left - offsetTemp.left) + 'px';
+ elements[i].style.top = (offset.top - offsetTemp.top) + 'px';
+ }
+ return offset;
+};
+
+Richfaces.Calendar.getParentOffset = function(element)
+{
+ var offset = {left:0,top:0};
+ var els = element.style;
+ if (els.display!='none')
+ {
+ if (element.offsetParent && element.offsetParent!=document.body)
+ offset = Position.cumulativeOffset(element.offsetParent);
+ }
+ else
+ {
+ var originalVisibility = els.visibility;
+ var originalPosition = els.position;
+ var originalDisplay = els.display;
+ els.visibility = 'hidden';
+ els.position = 'absolute';
+ els.display = '';
+ if (element.offsetParent && element.offsetParent!=document.body)
+ offset = Position.cumulativeOffset(element.offsetParent);
+ els.display = originalDisplay;
+ els.position = originalPosition;
+ els.visibility = originalVisibility;
+ }
+
+ return offset;
+};
+
Richfaces.Calendar.joinArray = function(array, begin, end, separator)
{
var value = '';
@@ -698,7 +750,9 @@
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);
- te.style.zIndex = te_shadow.style.zIndex = element.getStyle('z-index');
+ var zindex = element.getStyle('z-index');
+ te_shadow.style.zIndex = zindex;
+ te.style.zIndex = parseInt(zindex,10)+1;
var th=$(this.id+'TimeHours');
var ts;
@@ -947,8 +1001,8 @@
if (Event.element(e).id == this.POPUP_BUTTON_ID || (!this.params.enableManualInput
&& Event.element(e).id == this.INPUT_DATE_ID) ) return true;
- Position.prepare();
- if (Position.withinIncludingScrolloffsets($(this.id), Event.pointerX(e),
Event.pointerY(e))) return true;
+ //Position.prepare();
+ if (Position.within($(this.id), Event.pointerX(e), Event.pointerY(e))) return true;
this.doCollapse();
return true;
@@ -1633,15 +1687,20 @@
if (this.selectedDate!=null)
{
if (this.timeType && !isDateParsed)
+ {
if (oldSelectedDate!=null)
{
this.selectedDate.setHours(oldSelectedDate.getHours());
this.selectedDate.setMinutes(oldSelectedDate.getMinutes());
+
}
else
{
this.selectedDate.setHours(12);
+ this.selectedDate.setMinutes(0);
}
+ this.selectedDate.setSeconds(0);
+ }
if (!this.showApplyButton)
field.value=this.getSelectedDateString(this.params.datePattern);
@@ -1771,16 +1830,14 @@
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';
- te.style.left = te_shadow.style.left = element.style.left;
- te.style.top = te_shadow.style.top = element.style.top;
- //Element.clonePosition(te, element);
- //Element.clonePosition(te_shadow, element);
+ Richfaces.Calendar.clonePosition([te,te_shadow], element);
this.updateTimeEditor();
+ te_shadow.show();
te.show();
- te_shadow.show();
+
Element.clonePosition(this.TIME_EDITOR_LAYOUT_SHADOW_ID, this.TIME_EDITOR_LAYOUT_ID,
{offsetLeft: 3, offsetTop: 3});
},
@@ -1857,7 +1914,7 @@
CalendarView.todayControl = function (context) { return
(context.calendar.todayControlMode!='hidden' ?
CalendarView.getControl("Today", CalendarView.toolButtonAttributes,
"today") : "");};
CalendarView.selectedDateControl = function (context) { return
CalendarView.getSelectedDateControl(context.calendar);};
CalendarView.timeControl = function (context) { return
CalendarView.getTimeControl(context.calendar);};
-CalendarView.closeControl = CalendarView.getControl("x",
CalendarView.toolButtonAttributes, "close", "false");
+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.timeEditorFields = function (context) { return
context.calendar.timePatternHtml;};
@@ -1889,7 +1946,7 @@
[
new ET(function (context) { return Richfaces.evalMacro("nextYearControl",
context)})
]),
- new E('td',{'class': 'rich-calendar-tool
rich-calendar-tool-close'},
+ new E('td',{'class': 'rich-calendar-tool
rich-calendar-tool-close', 'style':function(context){return (this.isEmpty ?
'display:none;' : '');}},
[
new ET(function (context) { return Richfaces.evalMacro("closeControl",
context)})
])