variables.defaultFAversion = "4.7"; variables.defaultIconDataFile = "/ADF/thirdParty/css/font-awesome/#variables.defaultFAversion#/data/icon-data.csv"; variables.defaultIconClass = "fa"; var inputParameters = application.ADF.data.duplicateStruct(arguments.parameters); var currentValue = arguments.value; // the field's current value var readOnly = (arguments.displayMode EQ 'readonly') ? true : false; var iconDataArr = ArrayNew(1); var fontArray = ArrayNew(1); var iconDataFilePath = ''; var cftErrMsg = ''; var curVal = ''; var selected_index = ''; var a = 0; var i = 0; var selected = ""; var s = ""; var cftPath = "/ADF/extensions/customfields/font_awesome_select"; var iconClass = variables.defaultIconClass; var previewIconCurrentValue = ""; var previewTextCurrentValue = ""; var selectedCurrentValue = ""; var cftHeaderCSS = ''; inputParameters = setDefaultParameters(argumentCollection=arguments); if ( StructKeyExists(inputParameters,"iconDataFile") AND LEN(TRIM(inputParameters.iconDataFile)) ) iconDataFilePath = ExpandPath(inputParameters.iconDataFile); // Get the Full File Path to the IconDataFile // Make sure the data file exists if ( FileExists(iconDataFilePath) ) { // Convert the CSV file to an array iconDataArr = application.ADF.data.csvToArray(file=iconDataFilePath,Delimiter=","); } else { cftErrMsg = "Unable to load icon data file!"; if ( StructKeyExists(inputParameters,"iconDataFile") AND LEN(TRIM(inputParameters.iconDataFile)) ) cftErrMsg = cftErrMsg & "
'#inputParameters.iconDataFile#'"; } // Build the Font Awesome Icons array for ( a=1; a LTE ArrayLen(iconDataArr); a=a+1 ) { ArrayAppend( fontArray, '#iconDataArr[a][1]#,#iconDataArr[a][2]#' ); } // Set the curVal - NOT USED /*for( i=1; i lte ArrayLen(fontArray); i=i+1 ) { if ( ListFirst(fontArray[i]) eq currentValue ) { curVal = "#ListLast(fontArray[i])# #ListFirst(fontArray[i])#"; break; } }*/ // Clear value if switching ICON libraries if ( inputParameters.addIconClass AND FindNoCase(iconClass,currentValue,1) EQ 0 ) currentValue = ""; // TODO: Find similarly named icon in new icon library if ( LEN(TRIM(currentValue)) ) { if ( inputParameters.addIconClass ) { if ( ListFindNoCase(currentValue,iconClass,' ') EQ 0 ) currentValue = iconClass & ' ' & currentValue; previewIconCurrentValue = currentValue; previewTextCurrentValue = currentValue; if ( ListLen(currentValue,' ') GTE 2 ) previewTextCurrentValue = TRIM(ListGetAt(currentValue,2,' ')); selectedCurrentValue = previewTextCurrentValue; //previewTextCurrentValue = ListFirst(TRIM(ReplaceNoCase(currentValue,iconClass&' ','')), ' '); - OLD WAY } else { if ( ListFindNoCase(currentValue,iconClass,' ') NEQ 0 ) currentValue = TRIM(ReplaceNoCase(currentValue,iconClass&' ','')); previewIconCurrentValue = iconClass & ' ' & currentValue; previewTextCurrentValue = currentValue; if ( ListLen(currentValue,' ') GTE 1 ) previewTextCurrentValue = TRIM(ListGetAt(currentValue,1,' ')); selectedCurrentValue = previewTextCurrentValue; //previewTextCurrentValue = ListFirst(currentValue, ' '); - OLD WAY } }
application.ADF.scripts.loadUnregisteredResource('#cftPath#/font_awesome_select_styles.css', "stylesheet", "head", "TERTIARY", 0, 0); application.ADF.scripts.addHeaderCSS(cftHeaderCSS,"TERTIARY"); renderJSFunctions(argumentCollection=arguments, fieldParameters=inputParameters);
#previewTextCurrentValue#
disabled="disabled" class="fa-searchInput" placeholder="Type to filter list of icons">
#cftErrMsg#
  • #ListFirst(fontArray[i])#
Size:   checked="checked">   checked="checked">   checked="checked">   Pull:
var inputParameters = application.ADF.data.duplicateStruct(arguments.fieldParameters); var cftFASelectJS = "";; application.ADF.scripts.addFooterJS(cftFASelectJS,"TERTIARY"); var defaultFAversion = variables.defaultFAversion; var defaultIconDataFile = variables.defaultIconDataFile; var inputParameters = application.ADF.data.duplicateStruct(arguments.parameters); // Set the defaults if( NOT StructKeyExists(inputParameters,'addIconClass') OR !inputParameters.addIconClass ) inputParameters.addIconClass = false; if( NOT StructKeyExists(inputParameters,'ShowSize') ) inputParameters.ShowSize = 0; if( NOT StructKeyExists(inputParameters,'ShowFixedWidth') ) inputParameters.ShowFixedWidth = 0; if( NOT StructKeyExists(inputParameters,'ShowBorder') ) inputParameters.ShowBorder = 0; if( NOT StructKeyExists(inputParameters,'ShowSpin') ) inputParameters.ShowSpin = 0; if( NOT StructKeyExists(inputParameters,'ShowPull') ) inputParameters.ShowPull = 0; // Fix for bad version folder "Major.Minor.Maintenance". Should only be "Major.Minor" version. // - If the "4.2.0" folder is found, use the default icon data file value if( NOT StructKeyExists(inputParameters,'iconDataFile') OR LEN(TRIM(inputParameters.iconDataFile)) EQ 0 OR FindNoCase("/ADF/thirdParty/css/font-awesome/4.2.0/",inputParameters.iconDataFile)) inputParameters.iconDataFile = defaultIconDataFile; // Validate if the property field has been defined if ( NOT StructKeyExists(inputParameters, "fldID") OR LEN(inputParameters.fldID) LTE 0 ) inputParameters.fldID = arguments.fieldName; return inputParameters; private any function getValidationJS(required string formName, required string fieldName, required boolean isRequired) { if (arguments.isRequired) return 'hasValue(document.#arguments.formName#.#arguments.fieldName#, "TEXT")'; return ""; } private string function getValidationMsg() { return "Please select a value for the #arguments.label# field."; } private boolean function isMultiline() { return true; } /* IMPORTANT: Since loadResourceDependencies() is using ADF.scripts loadResources methods, getResourceDependencies() and loadResourceDependencies() must stay in sync by accounting for all of required resources for this Custom Field Type. */ public void function loadResourceDependencies() { // Load registered Resources via the ADF scripts_2_0 application.ADF.scripts.loadJQuery(noConflict=true); application.ADF.scripts.loadFontAwesome(); } public string function getResourceDependencies() { return "jQuery,FontAwesome"; }