* @param headElements the list of head elements to include for this control
*/
protected void addCalendarOptions(List<Element> headElements) {
String fieldId = getId();
JsScript script = new JsScript();
script.setId(fieldId + "-js-setup");
// Note: the setup script is recreated and checked if it is contained in
// the headElement. This check cater for when the field is used by another
// Control using the fly-weight pattern eg. FormTable.
if (!headElements.contains(script)) {
// Script must be executed as soon as browser dom is ready
script.setExecuteOnDomReady(true);
HtmlStringBuffer buffer = new HtmlStringBuffer(150);
buffer.append("Event.observe('").append(fieldId).append("-button").append("', 'click', function(){");
buffer.append(" calendar = new CalendarDateSelect($('").append(fieldId).append("'), {");
buffer.append(" minute_interval: 1, popup_by: '").append(fieldId).append("-button").append("',");
buffer.append(" embedded: false,");
buffer.append(" footer: false,");
buffer.append(" buttons: ").append(isShowTime()).append(",");
buffer.append(" time: ").append(isShowTime() ? "'mixed'," : "false,");
buffer.append(" formatValue: '").append(getCalendarPattern()).append("',");
buffer.append(" year_range: [").append(getMinimumYear()).append(",").append(getMaximumYear()).append("]");
buffer.append(" });");
buffer.append("});");
script.setContent(buffer.toString());
headElements.add(script);
}
}