Author: pyaschenko
Date: 2007-12-11 12:11:21 -0500 (Tue, 11 Dec 2007)
New Revision: 4725
Modified:
branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
Log:
RF-1582
Modified:
branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
---
branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-12-11
16:51:26 UTC (rev 4724)
+++
branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-12-11
17:11:21 UTC (rev 4725)
@@ -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,26 +1830,12 @@
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';
+
+ Richfaces.Calendar.clonePosition([te,te_shadow], element);
- //Element.clonePosition(te, element);
- //Element.clonePosition(te_shadow, element);
-
this.updateTimeEditor();
- te_shadow.style.visibility = 'hidden';
te_shadow.show();
-
- te_shadow.style.left = '0px';
- te_shadow.style.top = '0px';
-
- var o1 = element.cumulativeOffset();
- var o2 = te_shadow.cumulativeOffset();
-
- te.style.left = te_shadow.style.left = (o1[0] - o2[0]) + 'px';
- te.style.top = te_shadow.style.top = (o1[1] - o2[1]) + 'px';
-
- te_shadow.style.visibility = '';
-
te.show();
Element.clonePosition(this.TIME_EDITOR_LAYOUT_SHADOW_ID, this.TIME_EDITOR_LAYOUT_ID,
{offsetLeft: 3, offsetTop: 3});
@@ -1869,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;};
@@ -1901,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)})
])