}
return result;
}
private void renderScriptsAndStyles(FacesContext context, UIComponent component) throws IOException {
Calendar calendar = ((Calendar) component);
String clientId = component.getClientId(context);
ScriptBuilder sb = new ScriptBuilder();
String onchange = calendar.getOnchange();
if (onchange != null && onchange.length() > 0) {
sb.append("O$('").append(clientId).append("').onchange = " + // todo: refactor passing events into passing them as a single JSON param to the initialization function
"function(event) {").append(onchange).append("};\n");
}
String onPeriodChange = calendar.getOnperiodchange();
if (onPeriodChange != null && onPeriodChange.length() > 0) {
sb.append("O$('").append(clientId).append("').onperiodchange = " +
"function(event) {").append(onPeriodChange).append("};\n");
}
TimeZone timeZone = (calendar.getTimeZone() != null)
? calendar.getTimeZone()
: TimeZone.getDefault();
String selectedDateParam = null;
Date selectedDate = (Date) calendar.getValue();
if (selectedDate != null) {
selectedDateParam = DataUtil.formatDateForJs(selectedDate, timeZone);
}
Date todayDate = java.util.Calendar.getInstance().getTime();
String todayDateStr = DataUtil.formatDateForJs(todayDate, timeZone);
String focusedClassStr;
if (calendar.getAttributes().get(HIDE_DEFAULT_FOCUS_KEY) == null)
focusedClassStr = Rendering.getFocusedClass(context, calendar);
else
focusedClassStr = Styles.getCSSClass(context, calendar, calendar.getFocusedStyle(), StyleGroup.selectedStyleGroup(), calendar.getFocusedClass(), getDefaultClass());
Script rangesArray = getJSDateRangesArray(context, calendar);
sb.initScript(context, calendar, "O$.Calendar._init",
selectedDateParam,
todayDateStr,
Rendering.getRolloverClass(context, calendar),
calendar.isFocusable(),
focusedClassStr,
getStyleClassesWithFont(context, calendar.getDayStyle(), calendar.getDayClass(), DEFAULT_DAY_CLASS, calendar),
new StyleParam(calendar, "rolloverDay", DEFAULT_ROLLOVER_DAY_CLASS, StyleGroup.rolloverStyleGroup()),
new StyleParam(calendar, "inactiveMonthDay", DEFAULT_INACTIVE_MONTH_DAY_CLASS, StyleGroup.regularStyleGroup(3)),
new StyleParam(calendar, "rolloverInactiveMonthDay", DEFAULT_ROLLOVER_INACTIVE_MONTH_DAY_CLASS, StyleGroup.rolloverStyleGroup(3)),
Styles.getCSSClass_dontCascade(context, component, calendar.getSelectedDayStyle(), StyleGroup.selectedStyleGroup(), calendar.getSelectedDayClass(), DefaultStyles.getDefaultSelectionStyle()),
new StyleParam(calendar, "rolloverSelectedDay", DEFAULT_ROLLOVER_SELECTED_DAY_CLASS, StyleGroup.selectedStyleGroup(1)),
new StyleParam(calendar, "today", DEFAULT_TODAY_CLASS, StyleGroup.regularStyleGroup(5)),
new StyleParam(calendar, "rolloverToday", DEFAULT_ROLLOVER_TODAY_CLASS, StyleGroup.rolloverStyleGroup(5)),
new StyleParam(calendar, "weekendDay", DEFAULT_WEEKEND_DAY_CLASS, StyleGroup.regularStyleGroup(2)),
new StyleParam(calendar, "rolloverWeekendDay", DEFAULT_ROLLOVER_WEEKEND_DAY_CLASS, StyleGroup.rolloverStyleGroup(2)),
new StyleParam(calendar, "disabledDay", DEFAULT_DISABLED_DAY_CLASS, StyleGroup.rolloverStyleGroup(2)),
new StyleParam(calendar, "rolloverDisabledDay", DEFAULT_ROLLOVER_DISABLED_DAY_CLASS, StyleGroup.rolloverStyleGroup()),
calendar.getFirstDayOfWeek() - 1, // in JS Date object first day is less by one that in corresponding Java object
getStyleClassesWithFont(context, calendar.getHeaderStyle(), calendar.getHeaderClass(), DEFAULT_HEADER_CLASS, calendar),
rangesArray,
calendar.isShowFooter(),
calendar.getLocale().toString(),
calendar.isRequired(),
calendar.isDisabled(),
isAuxiliaryTagsRenderedInFooter(calendar),
clientId + VALUE_HOLDER_SUFFIX,
Rendering.convertToString(context, calendar, calendar.getValue()),
clientId + BODY_SUFFIX
);
Styles.renderStyleClasses(context, calendar);
Rendering.renderInitScript(context, sb,