// CACHE THIS RH - comment or remove when complete
request.element.isStatic = 0;
// load Resources
Application.ADF.scripts.loadResources("Bootstrap,JQuery,PixelCogParallax,cswParallaxTextblockCSS");
// exit if all we're doing is detecting required resources
if ( Request.RenderState.RenderMode EQ "getResources" )
exit;
if ( NOT structKeyExists(attributes,'elementinfo') )
exit;
//WriteDump(var=attributes,expand=false);
//WriteDump(var=attributes.elementinfo.elementdata,expand=false);
// Set the element ID
elementID = request.element.id;
// Get Records from the ElementData structure
elementData = Attributes.ElementInfo.ElementData;
items = ArrayNew(1);
// Get Records from the Element as an Array of Structures
if ( StructKeyExists(elementData, 'PropertyValues') AND ArrayLen(elementData.PropertyValues) )
items = elementData.PropertyValues;
totalItems = ArrayLen(items);
// Get the RenderHandler MetaData
rhMetadata = Attributes.ElementInfo.RenderHandlerMetaData;
widgetData = StructNew();
requireInitialWidgetData = false;
// Set the Field Names for Render Handler Metadata to WidgetData conversion
mdOptionsFieldName = "WidgetOptions";
/* Verify the Widget Custom Medadata Form and Render Handler Binding */
/* Look at the ElementInfo struct and the Caller Struct verify the metadata form is bound and we have some saved data */
mdBindingIsValid = Application.ADF.widgets.verifyRenderHandlerMetadata(rhCaller=Variables.Caller,metadataFields=mdOptionsFieldName,rhElementInfo=Attributes.ElementInfo,requireMetadata=requireInitialWidgetData);
if ( mdBindingIsValid )
{
// Get the widgetData from the bound Metadata Form with a "WidgetOptions" field
widgetData = Application.ADF.widgets.getWidgetConfigData(customMetdata=rhMetadata,configFieldName=mdOptionsFieldName);
}
/* PARSE [Theme] */
themeClass = "";
if ( StructKeyExists(widgetData,"Theme") )
themeClass = TRIM(widgetData.Theme);
/* PARSE [Overlay_Color] */
overlayColorClass = "";
if ( StructKeyExists(widgetData,"Overlay_Color") )
overlayColorClass = Application.ADF.widgets.buildClassValue(classStr=overlayColorClass,newClass=widgetData.Overlay_Color);
/* PARSE [Title_Tag] */
titleTag = "H2";
if ( StructKeyExists(widgetData,"Title_Tag") )
titleTag = TRIM(widgetData.Title_Tag);
/* PARSE [Title_Align] */
titleAlignClass = "";
if ( StructKeyExists(widgetData,"Title_Align") )
titleAlignClass = Application.ADF.widgets.buildClassValue(classStr=titleAlignClass,newClass=widgetData.Title_Align);
/* PARSE [Title_Align] */
titleColorClass = "";
if ( StructKeyExists(widgetData,"Title_Color") )
titleColorClass = Application.ADF.widgets.buildClassValue(classStr=titleColorClass,newClass=widgetData.Title_Color);
/* PARSE [Description_Align] */
descAlignClass = "";
if ( StructKeyExists(widgetData,"Description_Align") )
descAlignClass = Application.ADF.widgets.buildClassValue(classStr=descAlignClass,newClass=widgetData.Description_Align);
/* PARSE [Description_Color] */
descColorClass = "";
if ( StructKeyExists(widgetData,"Description_Color") )
descColorClass = Application.ADF.widgets.buildClassValue(classStr=descColorClass,newClass=widgetData.Description_Color);
/* PARSE [Button_Style] and [Button_Size] */
btnStyleClass = ""; // This default value must be empty string
btnSizeClass = "";
if ( StructKeyExists(widgetData,"Button_Style") )
{
/* PARSE [Button_Style] */
btnStyleClass = Application.ADF.widgets.buildClassValue(classStr="",newClass=widgetData.Button_Style);
/* PARSE [Button_Size] - Button Style is defined */
if ( StructKeyExists(widgetData,"Button_Size") AND widgetData.Button_Style NEQ "none" )
btnSizeClass = Application.ADF.widgets.buildClassValue(classStr="",newClass=widgetData.Button_Size);
}
/* PARSE [Button_Align] */
btnAlignClass = "";
if ( StructKeyExists(widgetData,"Button_Align") )
btnAlignClass = Application.ADF.widgets.buildClassValue(classStr=btnAlignClass,newClass=widgetData.Button_Align);
itemCSS = "";
itemJS = "";
cswParallaxTextblockCSS = "";
cswParallaxTextblockJS = "";
// PARSE ImageURL Data
imgURL = "";
if ( StructKeyExists(items[itm].values,'ImageURL') AND isStruct(items[itm].values.ImageURL) )
{
// assume CommonSpot image field is used and structure is passed
imgURL = items[itm].values.ImageURL.ResolvedURL.ServerRelative;
}
else
{
// assume img url string is passed
imgURL = items[itm].values.ImageURL;
}
// PARSE LinkURL Data
linkURL = application.ADF.csData.parseCSURL(str=items[itm].values.LinkURL);
// Load cswParallaxTextblockCSS
Application.ADF.scripts.addHeaderCSS(cswParallaxTextblockCSS, "TERTIARY"); // resourceGroup: PRIMARY, SECONDARY, TERTIARY
// Load cswParallaxTextblockJS
//Application.ADF.scripts.addFooterJS(cswParallaxTextblockJS, "TERTIARY"); // resourceGroup: PRIMARY, SECONDARY, TERTIARY
var fieldMappingArray = ArrayNew(1);
var fieldDetailsStruct = StructNew();
fieldDetailsStruct = StructNew();
fieldDetailsStruct.FieldName = 'Title';
fieldDetailsStruct.Description = 'The Title for the Image Text Block.';
fieldDetailsStruct.Required = 1;
arrayAppend(fieldMappingArray, fieldDetailsStruct);
fieldDetailsStruct = StructNew();
fieldDetailsStruct.FieldName = 'Description';
fieldDetailsStruct.Description = 'The Description for the Icon Text Block.';
fieldDetailsStruct.Required = 0;
arrayAppend(fieldMappingArray, fieldDetailsStruct);
fieldDetailsStruct = StructNew();
fieldDetailsStruct.FieldName = 'ImageURL';
fieldDetailsStruct.Description = 'The server relative URL to the image, or the CommonSpot Image field structure.';
fieldDetailsStruct.Required = 1;
arrayAppend(fieldMappingArray, fieldDetailsStruct);
fieldDetailsStruct = StructNew();
fieldDetailsStruct.FieldName = 'LinkURL';
fieldDetailsStruct.Description = 'The URL visitors will be navigated to when clicking the Link in the Image Text Block. If not provided the Image Text Block will not be linked.';
fieldDetailsStruct.Required = 0;
arrayAppend(fieldMappingArray, fieldDetailsStruct);
fieldDetailsStruct = StructNew();
fieldDetailsStruct.FieldName = 'LinkText';
fieldDetailsStruct.Description = 'The text that will render for the Link or Button in the Image Text Block. If not provided the Image Text Block will not be linked.';
fieldDetailsStruct.Required = 0;
arrayAppend(fieldMappingArray, fieldDetailsStruct);
return fieldMappingArray;