variables.defaultBootstrapVersion = "3.3";
variables.defaultGlyphIconDataFile = "/ADF/thirdParty/jquery/bootstrap/#variables.defaultBootstrapVersion#/data/glyphicon-data.csv";
variables.defaultIconClass = "glyphicon";
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 glyphiconDataArr = ArrayNew(1);
var fontArray = ArrayNew(1);
var glyphiconDataFilePath = '';
var cftErrMsg = '';
var curVal = '';
var selected_index = '';
var a = 0;
var i = 0;
var selected = "";
var s = "";
var cftPath = "/ADF/extensions/customfields/bootstrap_glyphicon_select";
var iconClass = variables.defaultIconClass;
var previewIconCurrentValue = "";
var previewTextCurrentValue = "";
var selectedCurrentValue = "";
var cftIconSizeCSS = '';
inputParameters = setDefaultParameters(argumentCollection=arguments);
if ( StructKeyExists(inputParameters,"glyphiconDataFile") AND LEN(TRIM(inputParameters.glyphiconDataFile)) )
glyphiconDataFilePath = ExpandPath(inputParameters.glyphiconDataFile);
// Get the Full File Path to the IconDataFile
// Make sure the data file exists
if ( FileExists(glyphiconDataFilePath) )
{
// Convert the CSV file to an array
glyphiconDataArr = application.ADF.data.csvToArray(file=glyphiconDataFilePath,Delimiter=",");
}
else
{
cftErrMsg = "Unable to load glyph icon data file!";
if ( StructKeyExists(inputParameters,"glyphiconDataFile") AND LEN(TRIM(inputParameters.glyphiconDataFile)) )
cftErrMsg = cftErrMsg & " '#inputParameters.glyphiconDataFile#'";
}
// Build the Font Awesome Icons array
for ( a=1; a LTE ArrayLen(glyphiconDataArr); a=a+1 )
{
ArrayAppend( fontArray, glyphiconDataArr[a][1] );
}
// Set the curVal - NOT USED
/*for( i=1; i lte ArrayLen(fontArray); i=i+1 )
{
if ( fontArray[i] eq currentValue )
{
curVal = 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
}
}
if ( !StructKeyExists(Request, 'cftBootstrapGlyphiconSelectCSS') )
{
application.ADF.scripts.loadUnregisteredResource('#cftPath#/bootstrap_glyphicon_select_styles.css', "stylesheet", "head", "TERTIARY", 0, 0);
request.cftBootstrapGlyphiconSelectCSS = 1;
}
application.ADF.scripts.addHeaderCSS(cftIconSizeCSS,"TERTIARY");
renderJSFunctions(argumentCollection=arguments, fieldParameters=inputParameters);
#previewTextCurrentValue#
disabled="disabled" class="bsgi-searchInput" placeholder="Type to filter list of Glyphicons">
#cftErrMsg#
#ListFirst(fontArray[i])#
Size: >Large
var inputParameters = application.ADF.data.duplicateStruct(arguments.fieldParameters);
var cftGlyphSelectJS = '';
application.ADF.scripts.addFooterJS(cftGlyphSelectJS,"TERTIARY");
var defaultBootstrapVersion = variables.defaultBootstrapVersion;
var defaultGlyphIconDataFile = variables.defaultGlyphIconDataFile;
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,'glyphiconDataFile') OR LEN(TRIM(inputParameters.glyphiconDataFile)) EQ 0 )
inputParameters.glyphiconDataFile = defaultGlyphIconDataFile;
// 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.";
}
public string function getResourceDependencies()
{
return listAppend(super.getResourceDependencies(), "jQuery,Bootstrap");
}
public void function loadResourceDependencies()
{
application.ADF.scripts.loadJQuery(noConflict=true);
application.ADF.scripts.loadBootstrap();
}
private boolean function isMultiline()
{
return true;
}