Skip to content

Instantly share code, notes, and snippets.

@shrutis22
Created October 16, 2016 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shrutis22/de44e01434e45bc53d4a13b7b5fb5999 to your computer and use it in GitHub Desktop.
Save shrutis22/de44e01434e45bc53d4a13b7b5fb5999 to your computer and use it in GitHub Desktop.
JS File for the Field Set UI Generator
/**
* This JavaScript file is created to apply
* additional functionalities to the
* 'FieldSetUIGeneratorController' page.
*
* @author Shruti Sridharan
* @since 05/09/2016
* @revisions N/A
*/
var FieldSetUI = {
constants : {
selectors : {
INPUT : "input[type='text'],input[type='checkbox'],select,textarea",
ANCHOR : "a",
SLDS_INPUT : "input[type='text'],select,textarea",
MULTI_SELECT : "select[multiple='multiple']"
},
classes : {
SLDS_INPUT : "slds-input"
}
},
helpers : {
/**
* This function is created to apply
* 'slds-input' classes to all the
* input tags.
*/
applySLDS : function() {
var constants = FieldSetUI.constants;
var helpers = FieldSetUI.helpers;
$( constants.selectors.SLDS_INPUT ).addClass( constants.classes.SLDS_INPUT );
helpers.showElements();
},
/**
* This function is created to apply
* Selectize Library to the Multi-
* Picklist Fields.
*/
applySelectize : function() {
var constants = FieldSetUI.constants;
$( constants.selectors.MULTI_SELECT )
.removeClass( constants.classes.SLDS_INPUT )
.selectize(
{
maxItems: null
}
);
},
/**
* This function is created to show the
* input boxes because initially the
* input boxes gets loaded without
* the 'slds-input' class being applied
* as this class is being applied via JS.
*/
showElements : function() {
var constants = FieldSetUI.constants;
$( constants.selectors.INPUT ).fadeIn();
$( constants.selectors.ANCHOR ).fadeIn();
}
},
actions : {
},
init : function() {
FieldSetUI.helpers.applySLDS();
FieldSetUI.helpers.applySelectize();
}
};
FieldSetUI.init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment