if (!isWidgetSupported(protocol)) {
// Fallback behaviour
return;
}
FieldExpanderContext context = getCurrentContext();
// Close outstanding <div> element.
DOMOutputBuffer currentBuffer = getCurrentBuffer(protocol);
closeDivElement(protocol);
Styles styles = attributes.getStyles();
StyleValue unfoldon = styles.getPropertyValues().getSpecifiedValue(StylePropertyDetails.MCS_TOGGLE_EVENT);
StyleValue initial_state = styles.getPropertyValues().getSpecifiedValue(StylePropertyDetails.MCS_INITIAL_STATE);
// Create instances of styles extractors.
StylesExtractor stylesExtractor =
createStylesExtractor(protocol, attributes.getStyles());
StylesExtractor disappearStylesExtractor =
createStylesExtractor(protocol, attributes.getStyles());
disappearStylesExtractor.setPseudoClass(StatefulPseudoClasses.MCS_CONCEALED);
StylesExtractor unfoldedStylesExtractor =
createStylesExtractor(protocol, attributes.getStyles());
unfoldedStylesExtractor.setPseudoClass(StatefulPseudoClasses.MCS_UNFOLDED);
stylesExtractor.setProtocol(protocol);
unfoldedStylesExtractor.setProtocol(protocol);
disappearStylesExtractor.setProtocol(protocol);
stylesExtractor.getJavaScriptStyles();
unfoldedStylesExtractor.getJavaScriptStyles();
StringBuffer textToScript = new StringBuffer(150);
textToScript.append("Widget.register(");
textToScript.append(createJavaScriptString(attributes.getId()));
textToScript.append(",new Widget.FieldExpander(");
textToScript.append(createJavaScriptString(attributes.getId()));
textToScript.append(", {");
textToScript.append(" delay: ");
textToScript.append(stylesExtractor.getTransitionInterval());
textToScript.append(", ").append(getDisappearableOptions(disappearStylesExtractor));
textToScript.append(", ").append(getAppearableOptions(stylesExtractor));
textToScript.append(", unfoldedStyle: ");
textToScript.append(unfoldedStylesExtractor.getJavaScriptStyles());
if (unfoldon != null) {
textToScript.append(", unfoldon: ");
textToScript.append(createJavaScriptString(unfoldon.getStandardCSS()));
}
if (initial_state != null) {
textToScript.append(", initial_state: ");
textToScript.append(createJavaScriptString(initial_state.getStandardCSS()));
}
if (context.getSummaryElementId() != null) {
textToScript.append(", ftElementId: ");
textToScript.append(createJavaScriptString(context.getSummaryElementId()));
}
if (context.getDetailsElementId() != null) {
textToScript.append(", fdElementId: ");
textToScript.append(createJavaScriptString(context.getDetailsElementId()));
}
if (context.getSummaryFieldId() != null) {
textToScript.append(", primFieldId: ");
textToScript.append(createJavaScriptString(context.getSummaryFieldId()));
}
if (context.getFoldedMarkerId() != null) {
textToScript.append(", foldedSpanId: ");
textToScript.append(createJavaScriptString(context.getFoldedMarkerId()));
}
if (context.getUnfoldedMarkerId() != null) {
textToScript.append(", unfoldedSpanId: ");
textToScript.append(createJavaScriptString(context.getUnfoldedMarkerId()));
}
textToScript.append("}));");