Author: pyaschenko
Date: 2007-07-31 12:47:40 -0400 (Tue, 31 Jul 2007)
New Revision: 1960
Modified:
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/json/json-dom.js
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js
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 events added
InputSelectedDate field fixes
Date parsing fixes
Modified:
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/json/json-dom.js
===================================================================
---
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/json/json-dom.js 2007-07-31
16:05:01 UTC (rev 1959)
+++
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/json/json-dom.js 2007-07-31
16:47:40 UTC (rev 1960)
@@ -65,9 +65,9 @@
if (typeof attrValue == "function")
attrValue = attrValue(context);
-
- if (attrValue)
- html += "
"+(i=='className'?'class':i)+'="'+this.xmlEscape(attrValue)+'"';
+
+ if (attrValue)
+ html += "
"+(i=='className'?'class':i)+'="'+this.xmlEscape(attrValue)+'"';
}
if(inner == "") html+= "/>";
else html+= ">"+inner+"</"+this.tag+">";
Modified:
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js
===================================================================
---
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js 2007-07-31
16:05:01 UTC (rev 1959)
+++
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js 2007-07-31
16:47:40 UTC (rev 1960)
@@ -146,12 +146,12 @@
return value;
}
-Richfaces.invokeOnComponent = function(componentType, element, functionName)
+Richfaces.invokeOnComponent = function(componentType, element, functionName, event)
{
var attribute="richfacesComponent";
while (element.parentNode) {
if (element[attribute] && element[attribute]==componentType)
- return element.component[functionName]();
+ return element.component[functionName](event);
else
element = element.parentNode;
}
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-31
16:05:01 UTC (rev 1959)
+++
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-07-31
16:47:40 UTC (rev 1960)
@@ -358,7 +358,7 @@
// POPUP description
// direction - [top-left, top-right, bottom-left, bottom-right, auto]
- // jointPoint - [top-left, top-right, bottom-left, bottom-right, auto]
+ // jointPoint - [top-left, top-right, bottom-left, bottom-right]
// popup - true
// userClasses - inputClass, inputDisabledClass, inputInvalidClass, buttonClass,
buttonDisabledClass
// id+PopupButton, id+PopupInput,
@@ -368,7 +368,6 @@
this.params = parameters;
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";
// markups initialization
@@ -394,9 +393,11 @@
this.DATE_ELEMENT_ID = this.params.dayListTableId+'Cell';
this.POPUP_ID = this.id+'Popup';
this.POPUP_BUTTON_ID = this.id+'PopupButton';
- this.POPUP_INPUT_ID = this.id+'PopupInput';
+ this.INPUT_DATE_ID = this.id+'InputDate';
this.IFRAME_ID = this.id+'IFrame';
+ //this.popupIntervalId=null;
+
this.firstDateIndex = 0;
this.daysData = {startDate:null, days:[]};
@@ -404,7 +405,7 @@
var obj=$(id);
- var htmlTextHeader = '<input id="'+this.id+'InputSelectedDate"
name="'+this.id+'InputSelectedDate" type="hidden"
style="display:none"
value="'+this.getSelectedDateString(this.params.datePattern)+'"/>\n'
+
+ var htmlTextHeader = (!this.params.popup ? '<input
id="'+this.INPUT_DATE_ID+'"
name="'+this.INPUT_DATE_ID+'" type="hidden"
style="display:none"
value="'+this.getSelectedDateString(this.params.datePattern)+'"/>\n'
: '') +
'<input id="'+this.id+'InputCurrentDate"
name="'+this.id+'InputCurrentDate" type="hidden"
style="display:none"
value="'+this.getCurrentDate().format("MM/y")+'"/>\n'
+
'<table border="0" cellpadding="0"
cellspacing="0" class="calendar_exterior"><tbody>\n';
var colspan = (this.params.showWeeksBar ? "8" : "7");
@@ -495,6 +496,10 @@
doCollapse: function() {
if (!this.params.popup || !this.isVisible) return;
+ /*this.stopTimer();
+ this.stopPopupEvents($(this.id));
+ this.stopPopupEvents($(this.POPUP_ID));*/
+
if (Richfaces.browser.isIE6) Element.hide(this.IFRAME_ID);
Element.hide(this.id);
this.isVisible = false;
@@ -502,8 +507,8 @@
doExpand: function() {
if (!this.params.popup || this.isVisible) return;
-
- var field = $(this.POPUP_INPUT_ID);
+
+ var field = $(this.INPUT_DATE_ID);
if (field && field.value!=undefined)
{
this.selectDate(field.value, true);
@@ -512,6 +517,12 @@
var base = $(this.POPUP_ID);
var e = $(this.id);
var iframe = $(this.IFRAME_ID);
+
+ var a = this;
+ setTimeout(function () { Event.observe(window.document, "click",
a.eventOnCollapse, false); }, 50);
+
+ /*this.setPopupEvents(e);
+ this.setPopupEvents(base);*/
Richfaces.Calendar.setElementPosition(e, base, this.params.jointPoint,
this.params.direction);
if (Richfaces.browser.isIE6)
@@ -523,9 +534,11 @@
iframe.style.height = edim.height+'px';
Element.show(iframe);
}
+
Element.show(e);
this.isVisible = true;
+
},
doSwitch: function() {
@@ -599,8 +612,45 @@
this.eventCellOnClick = this.eventCellOnClick.bindAsEventListener(this);
this.eventCellOnMouseOver = this.eventCellOnMouseOver.bindAsEventListener(this);
this.eventCellOnMouseOut = this.eventCellOnMouseOut.bindAsEventListener(this);
+ this.eventOnCollapse = this.eventOnCollapse.bindAsEventListener(this);
+ //this.eventOnMouseOver = this.eventOnMouseOver.bindAsEventListener(this);
+ //this.eventOnMouseOut = this.eventOnMouseOut.bindAsEventListener(this);
},
+ eventOnCollapse: function (e) {
+ Position.prepare();
+ if (Position.withinIncludingScrolloffsets($(this.id), Event.pointerX(e),
Event.pointerY(e))) return;
+ Event.stopObserving(window.document, "click", this.eventOnCollapse, false);
+ this.doCollapse();
+ },
+
+/* setPopupEvents: function(obj) {
+ Event.observe(obj, "mouseover", this.eventOnMouseOver, false);
+ Event.observe(obj, "mouseout", this.eventOnMouseOut, false);
+ },
+
+ stopPopupEvents: function(obj) {
+ Event.stopObserving(obj, "mouseover", this.eventOnMouseOver, false);
+ Event.stopObserving(obj, "mouseout", this.eventOnMouseOut, false);
+ },
+ *
+ stopTimer: function()
+ {
+ if (this.popupIntervalId!=null)
+ {
+ clearTimeout(this.popupIntervalId);
+ this.popupIntervalId=null;
+ }
+ },
+
+ eventOnMouseOver: function(e) {
+ this.stopTimer();
+ },
+
+ eventOnMouseOut: function(e) {
+ if (this.popupIntervalId==null) this.popupIntervalId =
setTimeout('$("'+this.id+'").component.doCollapse()',400);
+ },*/
+
setCellEvents: function(obj) {
Event.observe(obj, "click", this.eventCellOnClick, false);
Event.observe(obj, "mouseover", this.eventCellOnMouseOver, false);
@@ -610,7 +660,7 @@
Event.stopObserving(obj, "click", this.eventCellOnClick, false);
Event.stopObserving(obj, "mouseover", this.eventCellOnMouseOver, false);
Event.stopObserving(obj, "mouseout", this.eventCellOnMouseOut, false);
- },
+ },
eventCellOnClick: function (e) {
var obj = Event.findElementByAttr(e, "TD", "id",
this.DATE_ELEMENT_ID, true);
@@ -625,17 +675,13 @@
this.selectedDateElement = obj;
Element.addClassName(obj, "Selecteddayclass");
- $(this.id+'InputSelectedDate').value=this.getSelectedDateString(this.params.datePattern);
+ $(this.INPUT_DATE_ID).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();
- }
+ if (this.params.popup) this.doCollapse();
+
} else {
if (daydata._month==-1) this.prevMonth(); else this.nextMonth();
}
@@ -952,36 +998,50 @@
{
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;
- }
}
}
- if (this.selectedDateElement) Element.removeClassName(this.selectedDateElement,
"Selecteddayclass");
- this.selectedDate=null;
- this.today(noUpdate);
+
+ if (this.selectedDate!=null)
+ {
+ 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;
+ }
+ }
+ else
+ {
+ if (this.selectedDateElement) Element.removeClassName(this.selectedDateElement,
"Selecteddayclass");
+ this.selectedDate=null;
+ this.today(noUpdate);
+ }
}
});
+/*CalendarEventContainer = {};
+CalendarEventContainer.invokeToday = function (e)
+{
+ alert("today");
+ //Richfaces.invokeOnComponent('richfaces:calendar',this,'today',e);
+ return false;
+};*/
+
CalendarView = {};
-
CalendarView.getControl = function(text, functionName) {
var attr = {
onclick: (functionName ?
"Richfaces.invokeOnComponent('richfaces:calendar',this,'"+functionName+"');"
: "")+"return false;"
};
-
+
return new E('span',attr,[new T(text)]);
};
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-31
16:05:01 UTC (rev 1959)
+++
trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-07-31
16:47:40 UTC (rev 1960)
@@ -36,7 +36,7 @@
firstWeekDay: #{this:getFirstWeekDay(context, component)},
minDaysInFirstWeek: #{this:getMinDaysInFirstWeek(context, component)},
headerOptionalMarkup: [new E('b',{},[new T('User defined
header')])],
- footerOptionalMarkup: [new E('b',{},[new T('User defined
header')])],
+ footerOptionalMarkup: [new E('b',{},[new T('User defined
footer')])],
<jsp:scriptlet>/*<![CDATA[*/
if (component.getChildCount() != 0) {
/*]]>*/</jsp:scriptlet>
@@ -67,7 +67,7 @@
id="#{clientId}Popup"
<input
x:passThruWithExclusions="name"
- id="#{clientId}PopupInput"
+ id="#{clientId}InputDate"
value="#{this:getInputValue(context,component)}"
type="text"
readonly="#{component.attributes['readonly']}"
@@ -86,7 +86,7 @@
<button id="#{clientId}PopupButton"
accesskey="#{component.attributes['accesskey']}"
name="#{clientId}"
- onclick="$(this.form.id+':calendar').component.doSwitch();"
+ onclick="$(this.form.id+':calendar').component.doExpand();"
style="#{component.attributes['style']}"
tabindex="#{component.attributes['tabindex']}"