if (tickerTapeAttributes.getRefreshAttributes() != null ) {
require(WidgetScriptModules.BASE_AJAX, protocol, attributes);
}
// If this widget contains feed, render the controller.
FeedAttributes feedAttributes = tickerTapeAttributes.getFeedAttributes();
String separatorId = null;
if (feedAttributes != null) {
// Apply the separator
Styles separatorStyles = feedAttributes.getStyles();
if (separatorStyles != null) {
separatorStyles = separatorStyles.getNestedStyles(PseudoElements.MCS_ITEM);
if (separatorStyles != null) {
separatorStyles = separatorStyles.getNestedStyles(PseudoElements.MCS_BETWEEN);
if (separatorStyles != null) {
/* If the <feed> element contains styles specified for the
* ::mcs-item::mcs-between pseudo-element, render the separator.
*
* The rendered markup will look like:
* <span id="xxx">
* <span style="xxx"> *** </span>
* </span>
*/
// First, create a span element which would act as a placeholder
// for the actual content of the separator.
Element placeholderSpan = getCurrentBuffer(protocol).openStyledElement("span",
StylingFactory.getDefaultInstance()
.createInheritedStyles(
protocol.getMarinerPageContext().getStylingEngine()
.getStyles(), DisplayKeywords.NONE));
separatorId = protocol.getMarinerPageContext().generateUniqueFCID();
placeholderSpan.setAttribute("id", separatorId);
// Now, create a span element which would hold styles, and the actual
// separator content.
Element contentSpan = getCurrentBuffer(protocol).openStyledElement("span",
separatorStyles);
// Copy the content of the separator, if there's any.
StyleValue separatorContent = separatorStyles.getPropertyValues()
.getSpecifiedValue(StylePropertyDetails.CONTENT);
if (separatorContent != null) {
((DOMProtocol)protocol).getInserter().insert(contentSpan, separatorContent);
}
// Close the content span.
getCurrentBuffer(protocol).closeElement("span");
// Close the placeholder span.
getCurrentBuffer(protocol).closeElement("span");
}
}
}
}
RefreshAttributes refreshAttributes = ((TickerTapeAttributes) attributes)
.getRefreshAttributes();
// Read ticker-tape properties out of style attributes.
StylesExtractor styles = createStylesExtractor(protocol, attributes.getStyles());
// Prepare Javascript content.
StringWriter scriptWriter = new StringWriter();
scriptWriter.write(createJavaScriptWidgetRegistrationOpening(attributes.getId()));
addCreatedWidgetId(attributes.getId());
scriptWriter.write("new Widget.TickerTape(" + createJavaScriptString(attributes.getId()) + ", {");
// Render scroll type: scroll, slide or alternating.
scriptWriter.write("style:" + createJavaScriptString(styles.getMarqueeStyle()) + ",");
scriptWriter.write("focusable:" + createJavaScriptString(styles.getFocusStyle()) + ",");
// Render scroll attributes: direction, FPS & CPS.
scriptWriter.write("scroll:{");
scriptWriter.write("direction:" + createJavaScriptString(styles.getMarqueeDirection()) + ",");
scriptWriter.write("framesPerSecond:" + styles.getFrameRate() + ",");
scriptWriter.write("charsPerSecond:" + styles.getMarqueeSpeed());
scriptWriter.write("}");
// Render refresh attributes: URL & interval.
if (refreshAttributes != null) {
scriptWriter.write(",refresh:{");
scriptWriter.write("url:" + createJavaScriptString(refreshAttributes.getSrc()) + ",");
scriptWriter.write("interval:" + createJavaScriptString(refreshAttributes.getInterval()));
scriptWriter.write("}");
}
int repetitions = styles.getMarqueeRepetitions();
scriptWriter.write(",repetitions:" + ((repetitions != Integer.MAX_VALUE) ?
Integer.toString(repetitions) : createJavaScriptString("infinite")));
// Render closing parentheses.
scriptWriter.write("})");
scriptWriter.write(createJavaScriptWidgetRegistrationClosure());
scriptWriter.write(";");
// Render the item template outside Carousel content.
if (itemTemplateOutputBuffer != null) {
getCurrentBuffer(protocol).transferContentsFrom(itemTemplateOutputBuffer);
itemTemplateOutputBuffer = null;
}
// If this widget contains feed, render the controller.
if (feedAttributes != null) {
// The controller class is defined in the vfc-ticker JavaScript
// library, so we need to add the requirement here.
require(ElementDefaultRenderer.WIDGET_TICKER, protocol, attributes);
scriptWriter.write("Ticker.createTickerTapeController({tickerTape:Widget.getInstance(" +
createJavaScriptString(attributes.getId()) + ")");
if (feedAttributes.getChannel() != null) {
scriptWriter.write(", channel:" + createJavaScriptString(feedAttributes.getChannel()));
}
if (feedAttributes.getItemDisplay() != null) {
scriptWriter.write(", itemDisplayId:" + createJavaScriptString(feedAttributes.getItemDisplay()));
}
if (separatorId != null) {
scriptWriter.write(", separatorId:" + createJavaScriptString(separatorId));
}