require(WidgetScriptModules.BASE_AJAX, protocol, attributes);
}
closeDivElement(protocol);
FoldingItemContext foldingItemContext = getCurrentContext();
DOMOutputBuffer currentBuffer = getCurrentBuffer(protocol);
String textToScript;
String textLoadAttr = "";
LoadAttributes loadAttributes = ((FoldingItemAttributes) attributes)
.getLoadAttributes();
if (loadAttributes != null) {
textLoadAttr = ", load_src: " + createJavaScriptString(loadAttributes.getSrc())
+ ", load_when: " + createJavaScriptString(loadAttributes.getWhen());
}
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.getJavaScriptStyles();
unfoldedStylesExtractor.getJavaScriptStyles();
StringBuffer textBuffer = new StringBuffer("Widget.register(")
.append(createJavaScriptString(attributes.getId()))
.append(",new Widget.FoldingItem(")
.append(createJavaScriptString(attributes.getId()))
.append(", {")
.append("delay: ").append(stylesExtractor.getTransitionInterval())
.append(", ").append(getDisappearableOptions(disappearStylesExtractor))
.append(", ").append(getAppearableOptions(stylesExtractor))
// This part of code is used to apply unfolded style for the widget:folding-item
// element. As this is not required in the functional spec, the code is commented.
// In the future, if there'll be a requirement to specify unfolded styles
// for the widget:folding-item element, just uncomment this line and it'll work.
//+ ", unfoldedElementStyle: " + unfoldedStylesExtractor.getJavaScriptStyles()
.append(", unfoldedFtElementStyle: ").append(foldingItemContext.getSummaryUnfoldedStyles())
.append(", ftElementId: ")
.append(createJavaScriptString(foldingItemContext.getSummaryElementId()))
.append(", fdElementId: ")
.append(createJavaScriptString(foldingItemContext.getDetailsElementId()))
.append(", foldedSpanId: ")
.append(createJavaScriptString(foldingItemContext.getFoldedMarkerId()))
.append(", unfoldedSpanId: ")
.append(createJavaScriptString(foldingItemContext.getUnfoldedMarkerId()))
.append(((unfoldon == null) ? ""
: ", unfoldon: "+ createJavaScriptString(unfoldon.getStandardCSS())))
.append(((initial_state == null) ? ""
: ", initial_state: "+ createJavaScriptString(initial_state.getStandardCSS())))
.append(textLoadAttr).append("}));");