//-------------------------------------------------
// INITIALIZING PAGE
//-------------------------------------------------
jQuery(document).ready(function() {
setTimeout("CloseStatus();", 5000)
jQuery('#gform_fields').sortable({
axis: 'y',
cancel: '#field_settings',
handle: '.gfield_admin_icons',
start: function(event, ui){gforms_dragging = ui.item[0].id;}
});
jQuery('#field_choices').sortable({
axis: 'y',
handle: '.field-choice-handle',
update: function(event, ui){
var fromIndex = ui.item.data("index");
var toIndex = ui.item.index();
MoveFieldChoice(fromIndex, toIndex);
}
});
if(typeof gf_global['view'] == 'undefined' || gf_global['view'] != 'settings')
InitializeForm(form);
//for backwards compatibility <1.7
jQuery(document).trigger('gform_load_form_settings', [form]);
SetupUnsavedChangesWarning();
//log deprecated events
if (window.console){
var doc = jQuery(document)[0];
var data = jQuery.hasData(doc) && jQuery._data(doc);
if (data){
var deprecatedEvents = new Array('gform_load_form_settings');
for (var e in data.events) {
if (jQuery.inArray(e, deprecatedEvents) !== -1) {
console.log('Gravity Forms API warning: The jQuery event "' + e + '" is deprecated on this page since version 1.7');
}
}
}
}
// store original value of input before change
jQuery(document).on('focus', '#field_choices input.field-choice-text, #field_choices input.field-choice-value', function(){
jQuery(this).data('previousValue', jQuery(this).val());
});
});
function CloseStatus(){
jQuery('.updated_base, .error_base').slideUp();
}
function InitializeForm(form){
if(form.lastPageButton && form.lastPageButton.type == "image")
jQuery("#last_page_button_image").prop("checked", true);
else if(!form.lastPageButton || form.lastPageButton.type != "image")
jQuery("#last_page_button_text").prop("checked", true);
jQuery("#last_page_button_text_input").val(form.lastPageButton ? form.lastPageButton.text : gf_vars["previousLabel"]);
jQuery("#last_page_button_image_url").val(form.lastPageButton ? form.lastPageButton.imageUrl : "");
TogglePageButton('last_page', true);
if(form.postStatus)
jQuery('#field_post_status').val(form.postStatus);
if(form.postAuthor)
jQuery('#field_post_author').val(form.postAuthor);
//default to checked
if(form.useCurrentUserAsAuthor == undefined)
form.useCurrentUserAsAuthor = true;
jQuery('#gfield_current_user_as_author').prop('checked', form.useCurrentUserAsAuthor ? true : false);
if(form.postCategory)
jQuery('#field_post_category').val(form.postCategory);
if(form.postFormat)
jQuery('#field_post_format').val(form.postFormat);
if(form.postContentTemplateEnabled){
jQuery('#gfield_post_content_enabled').prop("checked", true);
jQuery('#field_post_content_template').val(form.postContentTemplate);
}
else{
jQuery('#gfield_post_content_enabled').prop("checked", false);
jQuery('#field_post_content_template').val("");
}
TogglePostContentTemplate(true);
if(form.postTitleTemplateEnabled){
jQuery('#gfield_post_title_enabled').prop("checked", true);
jQuery('#field_post_title_template').val(form.postTitleTemplate);
}
else{
jQuery('#gfield_post_title_enabled').prop("checked", false);
jQuery('#field_post_title_template').val("");
}
TogglePostTitleTemplate(true);
jQuery("#gform_last_page_settings").bind("click", function(){FieldClick(this);});
jQuery("#gform_pagination").bind("click", function(){FieldClick(this);});
jQuery(".gfield").bind("click", function(){FieldClick(this);});
var paginationType = form["pagination"] && form["pagination"]["type"] ? form["pagination"]["type"] : "percentage";
var paginationSteps = paginationType == "steps" ? true : false;
var paginationPercentage = paginationType == "percentage" ? true : false;
var paginationNone = paginationType == "none" ? true : false;
if(paginationSteps)
jQuery("#pagination_type_steps").prop("checked", true);
else if(paginationPercentage)
jQuery("#pagination_type_percentage").prop("checked", true);
else if(paginationNone)
jQuery("#pagination_type_none").prop("checked", true);
jQuery("#first_page_css_class").val(form["firstPageCssClass"]);
jQuery("#field_settings, #last_page_settings, #pagination_settings").tabs({selected:0});
TogglePageBreakSettings();
InitPaginationOptions(true);
InitializeFields();
}
function LoadFieldSettings(){
//loads settings
field = GetSelectedField();
var inputType = GetInputType(field);
jQuery("#field_label").val(field.label);
if(field.type == "html"){
jQuery(".tooltip_form_field_label_html").show();
jQuery(".tooltip_form_field_label").hide();
}
else{
jQuery(".tooltip_form_field_label_html").hide();
jQuery(".tooltip_form_field_label").show();
}
jQuery("#field_admin_label").val(field.adminLabel);
jQuery("#field_content").val(field["content"] == undefined ? "" : field["content"]);
jQuery("#post_custom_field_type").val(field.inputType);
jQuery("#post_tag_type").val(field.inputType);
jQuery("#field_size").val(field.size);
jQuery("#field_required").prop("checked", field.isRequired == true ? true : false);
jQuery("#field_margins").prop("checked", field.disableMargins == true ? true : false);
jQuery("#field_no_duplicates").prop("checked", field.noDuplicates == true ? true : false);
jQuery("#field_default_value").val(field.defaultValue == undefined ? "" : field.defaultValue);
jQuery("#field_default_value_textarea").val(field.defaultValue == undefined ? "" : field.defaultValue);
jQuery("#field_description").val(field.description == undefined ? "" : field.description);
jQuery("#field_css_class").val(field.cssClass == undefined ? "" : field.cssClass);
jQuery("#field_range_min").val(field.rangeMin);
jQuery("#field_range_max").val(field.rangeMax);
jQuery("#field_name_format").val(field.nameFormat);
jQuery('#field_force_ssl').prop('checked', field.forceSSL ? true : false);
jQuery('#credit_card_style').val(field.creditCardStyle ? field.creditCardStyle : "style1");
if(field.adminOnly)
jQuery("#field_visibility_admin").prop("checked", true);
else
jQuery("#field_visibility_everyone").prop("checked", true);
jQuery("#field_file_extension").val(field.allowedExtensions == undefined ? "" : field.allowedExtensions);
jQuery("#field_multiple_files").prop("checked", field.multipleFiles ? true : false);
jQuery("#field_max_files").val(field.maxFiles ? field.maxFiles : "" );
jQuery("#field_max_file_size").val(field.maxFileSize ? field.maxFileSize + "MB" : "" );
ToggleMultiFile(true);
jQuery(document).on('change', '#field_max_file_size', function(){
var $this = jQuery(this),
inputValue = parseInt($this.val());
var value = inputValue ? inputValue : '';
var maskedValue = value === '' ? '' : value + "MB"
SetFieldProperty('maxFileSize', value);
$this.val( maskedValue );
});
jQuery(document).on('onkeyup', '#field_max_file_size', function(){
var value = parseInt(jQuery(this).val()) ? parseInt(jQuery(this).val()) : '';
SetFieldProperty('maxFileSize', value);
});
jQuery("#field_phone_format").val(field.phoneFormat);
jQuery("#field_error_message").val(field.errorMessage);
jQuery('#field_captcha_theme').val(field.captchaTheme == undefined ? "red" : field.captchaTheme);
jQuery('#field_captcha_language').val(field.captchaLanguage == undefined ? "en" : field.captchaLanguage);
jQuery('#field_other_choice').prop('checked', field.enableOtherChoice ? true : false);
jQuery('#field_add_icon_url').val(field.addIconUrl ? field.addIconUrl : "");
jQuery('#field_delete_icon_url').val(field.deleteIconUrl ? field.deleteIconUrl : "");
jQuery('#gfield_enable_enhanced_ui').prop('checked', field.enableEnhancedUI ? true : false);
jQuery("#gfield_password_strength_enabled").prop("checked", field.passwordStrengthEnabled == true ? true : false);
jQuery("#gfield_min_strength").val(field.minPasswordStrength == undefined ? "" : field.minPasswordStrength);
TogglePasswordStrength(true);
jQuery("#gfield_email_confirm_enabled").prop("checked", field.emailConfirmEnabled == true ? true : false);
//Creating blank item for number format to existing number fields so that user is not force into a format (for backwards compatibility)
if(!field.numberFormat){
if(jQuery("#field_number_format #field_number_format_blank").length == 0){
jQuery("#field_number_format").prepend("");
}
}
else
jQuery("#field_number_format_blank").remove();
jQuery("#field_number_format").val(field.numberFormat ? field.numberFormat : "");
// Handle calculation options
// hide rounding option for calculation product fields
if (field.type == 'product' && field.inputType == 'calculation') {
field.enableCalculation = true;
jQuery('.field_calculation_rounding').hide();
jQuery('.field_enable_calculation').hide();
} else {
jQuery('.field_enable_calculation').show();
if (field.type == 'number' && field.numberFormat == "currency") {
jQuery('.field_calculation_rounding').hide();
} else {
jQuery('.field_calculation_rounding').show();
}
}
jQuery('#field_enable_calculation').prop('checked', field.enableCalculation ? true : false);
ToggleCalculationOptions(field.enableCalculation, field);
jQuery('#field_calculation_formula').val(field.calculationFormula);
var rounding = gformIsNumber(field.calculationRounding) ? field.calculationRounding : "norounding";
jQuery('#field_calculation_rounding').val(rounding);
jQuery("#option_field_type").val(field.inputType);
var productFieldType = jQuery("#product_field_type");
productFieldType.val(field.inputType);
if(has_entry(field.id))
productFieldType.prop("disabled", true);
else
productFieldType.prop("disabled", false);
jQuery("#donation_field_type").val(field.inputType);
jQuery("#quantity_field_type").val(field.inputType);
if(field["inputType"] == "hiddenproduct" || field["inputType"] == "singleproduct" || field["inputType"] == "singleshipping" || field["inputType"] == "calculation"){
var basePrice = field.basePrice == undefined ? "" : field.basePrice;
jQuery("#field_base_price").val(field.basePrice == undefined ? "" : field.basePrice);
SetBasePrice(basePrice);
}
jQuery("#field_disable_quantity").prop("checked", field.disableQuantity == true ? true : false);
SetDisableQuantity(field.disableQuantity == true);
var isPassword = field.enablePasswordInput ? true : false
jQuery("#field_password").prop("checked", isPassword ? true : false);
jQuery("#field_maxlen").val(typeof field.maxLength == "undefined" ? "" : field.maxLength);
jQuery("#field_maxrows").val(typeof field.maxRows == "undefined" ? "" : field.maxRows);
var addressType = field.addressType == undefined ? "international" : field.addressType;
jQuery('#field_address_type').val(addressType);
jQuery("#field_address_hide_address2").prop("checked", field.hideAddress2 == true ? true : false);
jQuery("#field_address_hide_state_" + addressType).prop("checked", field.hideState == true ? true : false);
var defaultState = field.defaultState == undefined ? "" : field.defaultState;
var defaultProvince = field.defaultProvince == undefined ? "" : field.defaultProvince; //for backwards compatibility
var defaultStateProvince = addressType == "canadian" && defaultState == "" ? defaultProvince : defaultState;
jQuery("#field_address_default_state_" + addressType).val(defaultStateProvince);
jQuery("#field_address_default_country_" + addressType).val(field.defaultCountry == undefined ? "" : field.defaultCountry);
jQuery("#field_address_hide_country_" + addressType).prop("checked", field.hideCountry == true ? true : false);
SetAddressType(true);
jQuery("#gfield_display_title").prop("checked", field.displayTitle == true ? true : false);
jQuery("#gfield_display_caption").prop("checked", field.displayCaption == true ? true : false);
jQuery("#gfield_display_description").prop("checked", field.displayDescription == true ? true : false);
var customFieldExists = CustomFieldExists(field.postCustomFieldName);
jQuery("#field_custom_field_name_select")[0].selectedIndex = 0;
jQuery("#field_custom_field_name_text").val("");
if(customFieldExists)
jQuery("#field_custom_field_name_select").val(field.postCustomFieldName);
else
jQuery("#field_custom_field_name_text").val(field.postCustomFieldName);
if(customFieldExists)
jQuery("#field_custom_existing").prop("checked", true);
else
jQuery("#field_custom_new").prop("checked", true);
ToggleCustomField(true);
jQuery('#gfield_customfield_content_enabled').prop("checked", field.customFieldTemplateEnabled ? true : false);
jQuery('#field_customfield_content_template').val(field.customFieldTemplateEnabled ? field.customFieldTemplate : "");
ToggleCustomFieldTemplate(true);
if(field.displayAllCategories)
jQuery("#gfield_category_all").prop("checked", true);
else
jQuery("#gfield_category_select").prop("checked", true);
ToggleCategory(true);
jQuery('#gfield_post_category_initial_item_enabled').prop("checked", field.categoryInitialItemEnabled ? true : false);
jQuery('#field_post_category_initial_item').val(field.categoryInitialItemEnabled ? field.categoryInitialItem : "");
TogglePostCategoryInitialItem(true);
var hasPostFeaturedImage = field.postFeaturedImage ? true : false;
jQuery('#gfield_featured_image').prop('checked', hasPostFeaturedImage);
var isStandardMask = IsStandardMask(field.inputMaskValue);
jQuery("#field_input_mask").prop('checked', field.inputMask ? true : false);
if(isStandardMask){
jQuery("#field_mask_standard").prop("checked", true);
jQuery("#field_mask_select").val(field.inputMaskValue);
}
else{
jQuery("#field_mask_custom").prop("checked", true);
jQuery("#field_mask_text").val(field.inputMaskValue);
}
ToggleInputMask(true);
ToggleInputMaskOptions(true);
if(inputType == "creditcard"){
if(!field.creditCards || field.creditCards.length <= 0)
field.creditCards = ['amex', 'visa', 'discover', 'mastercard'];
for(i in field.creditCards) {
if(!field.creditCards.hasOwnProperty(i))
continue;
jQuery('#field_credit_card_' + field.creditCards[i]).prop('checked', true);
}
}
if(!field["dateType"] && inputType == "date")
field["dateType"] = "datepicker";
jQuery("#field_date_input_type").val(field["dateType"]);
jQuery("#gfield_calendar_icon_url").val(field["calendarIconUrl"] == undefined ? "" : field["calendarIconUrl"]);
jQuery('#field_date_format').val(field['dateFormat'] == "dmy" ? "dmy" : field['dateFormat']);
jQuery('#field_time_format').val(field['timeFormat'] == "24" ? "24" : "12");
SetCalendarIconType(field["calendarIconType"], true);
ToggleDateCalendar(true);
LoadDateInputs();
LoadTimeInputs();
field.allowsPrepopulate = field.allowsPrepopulate ? true : false; //needed when property is undefined
jQuery("#field_prepopulate").prop("checked", field.allowsPrepopulate ? true : false);
CreateInputNames(field);
ToggleInputName(true);
var canHaveConditionalLogic = GetFirstRuleField() > 0;
if(field["type"] == "page"){
LoadFieldConditionalLogic(canHaveConditionalLogic, "next_button");
LoadFieldConditionalLogic(canHaveConditionalLogic, "page");
}
else{
LoadFieldConditionalLogic(canHaveConditionalLogic, "field");
}
if(field.nextButton){
if(field.nextButton.type == "image")
jQuery("#next_button_image").prop("checked", true);
else
jQuery("#next_button_text").prop("checked", true);
jQuery("#next_button_text_input").val(field.nextButton.text);
jQuery("#next_button_image_url").val(field.nextButton.imageUrl);
}
if(field.previousButton){
if(field.previousButton.type == "image")
jQuery("#previous_button_image").prop("checked", true);
else
jQuery("#previous_button_text").prop("checked", true);
jQuery("#previous_button_text_input").val(field.previousButton.text);
jQuery("#previous_button_image_url").val(field.previousButton.imageUrl);
}
TogglePageButton("next", true);
TogglePageButton("previous", true);
jQuery(".gfield_category_checkbox").each(function(){
if(field["choices"]){
for(var i=0; i').val(selected_state).html(selected_state));
state_dropdown.val(selected_state).show();
}
else{
jQuery(".field_selected .state_dropdown").hide();
jQuery(".field_selected .state_text").val("").show();
}
//hide/show address line 2
if(jQuery("#field_address_hide_address2").is(":checked"))
jQuery(".field_selected #input_" + field["id"] + "_2_container").hide();
else
jQuery(".field_selected #input_" + field["id"] + "_2_container").show();
//hide/show state field
if(jQuery("#field_address_hide_state_" + addressType).is(":checked"))
jQuery(".field_selected #input_" + field["id"] + "_4_container").hide();
else
jQuery(".field_selected #input_" + field["id"] + "_4_container").show();
}
function SetAddressProperties(){
var addressType = jQuery("#field_address_type").val();
SetFieldProperty("addressType", addressType);
SetFieldProperty("hideAddress2", jQuery("#field_address_hide_address2").is(":checked"));
SetFieldProperty("hideState", jQuery("#field_address_hide_state_" + addressType).is(":checked"));
SetFieldProperty("defaultState", jQuery("#field_address_default_state_" + addressType).val());
SetFieldProperty("defaultProvince",""); //for backwards compatibility
//Only save the hide country property for address types that have that option (ones with no country)
var country = jQuery("#field_address_country_" + addressType).val();
if(country == ""){
SetFieldProperty("hideCountry",jQuery("#field_address_hide_country_" + addressType).is(":checked"));
country = jQuery("#field_address_default_country_" + addressType).val();
}
SetFieldProperty("defaultCountry",country);
UpdateAddressFields();
}
function TogglePasswordStrength(isInit){
var speed = isInit ? "" : "slow";
if(jQuery("#gfield_password_strength_enabled").is(":checked")){
jQuery("#gfield_min_strength_container").show(speed);
}
else{
jQuery("#gfield_min_strength_container").hide(speed);
}
}
function ToggleCategory(isInit){
var speed = isInit ? "" : "slow";
if(jQuery("#gfield_category_all").is(":checked")){
jQuery("#gfield_settings_category_container").hide(speed);
SetFieldProperty("displayAllCategories", true);
SetFieldProperty("choices", new Array()); //reset selected categories
}
else{
jQuery("#gfield_settings_category_container").show(speed);
SetFieldProperty("displayAllCategories", false);
}
}
function SetCustomFieldTemplate(){
var enabled = jQuery("#gfield_customfield_content_enabled").is(":checked");
SetFieldProperty("customFieldTemplate", enabled ? jQuery("#field_customfield_content_template").val() : null);
SetFieldProperty("customFieldTemplateEnabled", enabled );
}
function SetCategoryInitialItem(){
var enabled = jQuery("#gfield_post_category_initial_item_enabled").is(":checked");
SetFieldProperty("categoryInitialItem", enabled ? jQuery("#field_post_category_initial_item").val() : null);
SetFieldProperty("categoryInitialItemEnabled", enabled );
}
function PopulateContentTemplate(fieldName){
if(jQuery("#" + fieldName).val().length == 0){
var field = GetSelectedField();
jQuery("#" + fieldName).val("{" + field.label + ":" + field.id + "}");
}
}
function TogglePostContentTemplate(isInit){
var speed = isInit ? "" : "slow";
if(jQuery("#gfield_post_content_enabled").is(":checked")){
jQuery("#gfield_post_content_container").show(speed);
if(!isInit){
PopulateContentTemplate("field_post_content_template");
}
}
else{
jQuery("#gfield_post_content_container").hide(speed);
}
}
function TogglePostTitleTemplate(isInit){
var speed = isInit ? "" : "slow";
if(jQuery("#gfield_post_title_enabled").is(":checked")){
jQuery("#gfield_post_title_container").show(speed);
if(!isInit)
PopulateContentTemplate("field_post_title_template");
}
else{
jQuery("#gfield_post_title_container").hide(speed);
}
}
function ToggleCustomFieldTemplate(isInit){
var speed = isInit ? "" : "slow";
if(jQuery("#gfield_customfield_content_enabled").is(":checked")){
jQuery("#gfield_customfield_content_container").show(speed);
if(!isInit){
PopulateContentTemplate("field_customfield_content_template");
}
}
else{
jQuery("#gfield_customfield_content_container").hide(speed);
}
}
function ToggleInputName(isInit){
var speed = isInit ? "" : "slow";
if(jQuery('#field_prepopulate').is(":checked")){
jQuery('#field_input_name_container').show(speed);
}
else{
jQuery('#field_input_name_container').hide(speed);
jQuery("#field_input_name").val("");
}
}
function SetFieldColumns(){
SetFieldChoices();
}
function ToggleChoiceValue(isInit){
var speed = isInit ? "" : "slow";
var field = GetSelectedField();
var suffix = field.enablePrice ? "_and_price" : "";
var container = jQuery('#gfield_settings_choices_container');
//removing all classes
container.removeClass("choice_with_price choice_with_value choice_with_value_and_price");
var isShowValues = jQuery('#field_choice_values_enabled').is(":checked");
if(isShowValues){
container.addClass("choice_with_value" + suffix);
}
else if(field.enablePrice){
container.addClass("choice_with_price");
}
}
function TogglePageButton(button_name, isInit){
var isText = jQuery("#" + button_name + "_button_text").is(":checked");
show_element = isText ? "#" + button_name + "_button_text_container" : "#" + button_name + "_button_image_container"
hide_element = isText ? "#" + button_name + "_button_image_container" : "#" + button_name + "_button_text_container";
if(isInit){
jQuery(hide_element).hide();
jQuery(show_element).show();
}
else{
jQuery(hide_element).hide();
jQuery(show_element).fadeIn(800);
}
}
function SetPageButton(button_name){
field = GetSelectedField();
var buttonType = jQuery("#" + button_name + "_button_image").is(":checked") ? "image" : "text";
field[button_name + "Button"]["type"] = buttonType;
if(buttonType == "image"){
field[button_name + "Button"]["text"] = "";
field[button_name + "Button"]["imageUrl"] = jQuery("#" + button_name + "_button_image_url").val();
}
else{
field[button_name + "Button"]["text"] = jQuery("#" + button_name + "_button_text_input").val();
field[button_name + "Button"]["imageUrl"] = "";
}
}
function ToggleCustomField(isInit){
var isExisting = jQuery("#field_custom_existing").is(":checked");
show_element = isExisting ? "#field_custom_field_name_select" : "#field_custom_field_name_text"
hide_element = isExisting ? "#field_custom_field_name_text" : "#field_custom_field_name_select";
var speed = isInit ? "" : "";
jQuery(hide_element).hide(speed);
jQuery(show_element).show(speed);
}
function ToggleInputMask(isInit){
var speed = isInit ? "" : "slow";
if(jQuery("#field_input_mask").is(":checked")){
jQuery("#gform_input_mask").show(speed);
jQuery(".maxlen_setting").hide();
SetFieldProperty('inputMask', true);
//setting max length to blank
jQuery("#field_maxlen").val("");
SetFieldProperty('maxLength', "");
}
else{
jQuery("#gform_input_mask").hide(speed);
jQuery(".maxlen_setting").show();
SetFieldProperty('inputMask', false);
SetFieldProperty('inputMaskValue', '');
}
}
function ToggleInputMaskOptions(isInit){
var isStandard = jQuery("#field_mask_standard").is(":checked");
show_element = isStandard ? "#field_mask_select" : "#field_mask_text, .mask_text_description"
hide_element = isStandard ? "#field_mask_text, .mask_text_description" : "#field_mask_select";
var speed = isInit ? "" : "";
jQuery(hide_element).val('').hide(speed);
jQuery(show_element).show(speed);
if(!isInit)
SetFieldProperty('inputMaskValue', '');
}
function ToggleAutoresponder(){
if(jQuery("#form_autoresponder_enabled").is(":checked"))
jQuery("#form_autoresponder_container").show("slow");
else
jQuery("#form_autoresponder_container").hide("slow");
}
function ToggleMultiFile(isInit){
var speed = isInit ? "" : "slow";
if(jQuery("#field_multiple_files").prop("checked")){
jQuery("#gform_multiple_files_options").show(speed);
SetFieldProperty('multipleFiles', true);
}
else{
jQuery("#gform_multiple_files_options").hide(speed);
SetFieldProperty('multipleFiles', false);
jQuery("#field_max_files").val("");
SetFieldProperty('maxFiles', "");
}
if(!isInit){
var field = GetSelectedField();
jQuery("#field_settings").slideUp(function(){StartChangeInputType("fileupload", field);});
}
}
function HasPostContentField(){
for(var i=0; i= 0)
fields.push(form["fields"][i]);
}
return fields;
}
function GetNextFieldId(){
var max = 0;
for(var i=0; i max)
max = parseFloat(form.fields[i].id);
}
return parseFloat(max) + 1;
}
function EndAddField(field, fieldString){
gf_vars["currentlyAddingField"] = false;
//sets up DOM for new field
jQuery("#gform_fields").append(fieldString);
var newFieldElement = jQuery("#field_" + field.id);
newFieldElement.animate({ backgroundColor: '#FFFBCC' }, 'fast', function(){jQuery(this).animate({backgroundColor: '#FFF'}, 'fast', function(){jQuery(this).css('background-color', '');})})
newFieldElement.bind("click", function(){FieldClick(this);});
//creates new javascript field
form.fields.push(field);
jQuery('#no-fields').hide();
//Unselects all fields
jQuery(".selectable").removeClass("field_selected");
//Closing editors
HideSettings("field_settings");
HideSettings("form_settings");
HideSettings("last_page_settings");
//Select current field
newFieldElement.addClass("field_selected");
//initializes new field with default data
SetFieldSize(field.size);
TogglePageBreakSettings();
InitializeFields();
newFieldElement.removeClass("field_selected");
jQuery(document).trigger('gform_field_added', [form, field]);
}
function StartChangeNameFormat(format){
field = GetSelectedField();
field["nameFormat"] = format;
SetFieldProperty('nameFormat', format);
jQuery("#field_settings").slideUp(function(){StartChangeInputType(field["type"], field);});
}
function StartChangeCaptchaType(captchaType){
field = GetSelectedField();
field["captchaType"] = captchaType;
SetFieldProperty('captchaType', captchaType);
jQuery("#field_settings").slideUp(function(){StartChangeInputType(field["type"], field);});
}
function StartChangeProductType(type){
field = GetSelectedField();
if(type == "singleproduct" || type == "hiddenproduct" || field["inputType"] == "calculation" )
field["enablePrice"] = null;
else
field["enablePrice"] = true;
return StartChangeInputType(type, field);
}
function StartChangeDonationType(type){
field = GetSelectedField();
if(type != "donation")
field["enablePrice"] = true;
else
field["enablePrice"] = null;
return StartChangeInputType(type, field);
}
function StartChangeShippingType(type){
field = GetSelectedField();
if(type != "singleshipping")
field["enablePrice"] = true;
return StartChangeInputType(type, field);
}
function StartChangePostCategoryType(type){
if(type == 'dropdown') {
jQuery('.post_category_initial_item_setting').hide();
} else {
jQuery('.post_category_initial_item_setting').show();
}
field = GetSelectedField();
return StartChangeInputType(type, field);
}
function EndChangeInputType(fieldId, fieldType, fieldString){
jQuery("#field_" + fieldId).html(fieldString);
var field = GetFieldById(fieldId);
//setting input type if different than field type
field.inputType = field.type != fieldType ? fieldType : "";
SetDefaultValues(field);
SetFieldLabel(field.label);
SetFieldSize(field.size);
SetFieldDefaultValue(field.defaultValue);
SetFieldDescription(field.description);
SetFieldRequired(field.isRequired);
InitializeFields();
LoadFieldSettings();
//UpdateDescriptionPlacement();
}
function InitializeFields(){
//Border on/off logic on mouse over
jQuery(".selectable").hover(
function () {
jQuery(this).addClass("field_hover");
},
function () {
jQuery(this).removeClass("field_hover");
}
);
jQuery(".field_delete_icon, .field_duplicate_icon").bind("click", function(event){
event.stopPropagation();
});
jQuery("#field_settings, #form_settings, #last_page_settings, #pagination_settings, .captcha_message, .form_delete_icon, .all-merge-tags").bind("click", function(event){
event.stopPropagation();
});
//UpdateLabelPlacement(true);
}
function FieldClick(field){
//disable click that happens right after dragging ends
if(gforms_dragging == field.id){
gforms_dragging = 0;
return;
}
if(jQuery(field).hasClass("field_selected")) {
var element_id = "";
switch(field.id){
case "gform_heading" :
element_id = "#form_settings";
jQuery('.gf_form_toolbar_settings a').removeClass("gf_toolbar_active");
break;
case "gform_last_page_settings" :
element_id = "#last_page_settings";
break;
case "gform_pagination" :
element_id = "#pagination_settings";
break;
default:
element_id = "#field_settings";
}
// force focus to ensure onblur events fire for field setting inputs
jQuery('input#gform_force_focus').focus();
jQuery(element_id).slideUp(function(){
jQuery(field).removeClass("field_selected").addClass("field_hover");
HideSettings("field_settings");
});
return;
}
//unselects all fields
jQuery(".selectable").removeClass("field_selected");
//selects current field
jQuery(field).removeClass("field_hover").addClass("field_selected");
//if this is a field (not the form title), load appropriate field type settings
if(field.id == "gform_heading"){
//hide field settings
HideSettings("field_settings");
HideSettings("last_page_settings");
HideSettings("pagination_settings");
InitializeFormConditionalLogic();
//Displaying form settings
ShowSettings("form_settings");
//highlighting toolbar item
jQuery('.gf_form_toolbar_settings a').addClass("gf_toolbar_active");
}
else if(field.id == "gform_last_page_settings"){
//hide field settings
HideSettings("field_settings");
HideSettings("form_settings");
HideSettings("pagination_settings");
//Displaying form settings
ShowSettings("last_page_settings");
}
else if(field.id == "gform_pagination"){
//hide field settings
HideSettings("field_settings");
HideSettings("form_settings");
HideSettings("last_page_settings");
InitPaginationOptions();
//Displaying pagination settings
ShowSettings("pagination_settings");
}
else{
//hide form settings
HideSettings("form_settings");
HideSettings("last_page_settings");
HideSettings("pagination_settings");
//selects current field
LoadFieldSettings();
}
}
function TogglePercentageStyle(isInit){
var speed = isInit ? "" : "slow";
if(jQuery("#percentage_style").val() == 'custom'){
jQuery('.percentage_custom_container').show(speed);
}
else{
jQuery('.percentage_custom_container').hide(speed);
}
}
function TogglePercentageConfirmationText(isInit){
var speed = isInit ? "" : "slow";
if(jQuery("#percentage_confirmation_display").is(":checked")){
jQuery('.percentage_confirmation_page_name_setting').show(speed);
}
else{
jQuery('.percentage_confirmation_page_name_setting').hide(speed);
}
}
function CustomFieldExists(name){
if(!name)
return true;
var options = jQuery("#field_custom_field_name_select option");
for(var i=0; i" + key + "";
}
str += "";
jQuery("#bulk_items").prepend(str);
}
}
function SelectCustomChoice(name){
jQuery("#gfield_bulk_add_input").val(gform_custom_choices[name].join("\n"));
gform_selected_custom_choice = name;
InitBulkCustomPanel();
}
function SelectPredefinedChoice(name){
jQuery('#gfield_bulk_add_input').val(gform_predefined_choices[name].join('\n'));
gform_selected_custom_choice = "";
InitBulkCustomPanel();
}
function InsertBulkChoices(choices){
field = GetSelectedField();
field.choices = new Array();
var enableValue = false;
for(var i=0; i 1){
var currency = GetCurrentCurrency();
price = currency.toMoney(text_price[1]);
}
text_value = text_value.split("|");
field.choices.push(new Choice(jQuery.trim(text_value[0]), jQuery.trim(text_value[text_value.length -1]), jQuery.trim(price)));
if(text_value.length > 1)
enableValue = true;
}
if(enableValue){
field["enableChoiceValue"] = true;
jQuery('#field_choice_values_enabled').prop("checked", true);
ToggleChoiceValue();
}
LoadFieldChoices(field);
UpdateFieldChoices(field.type);
}
function InitBulkCustomPanel(){
if(gform_selected_custom_choice.length == 0){
CloseCustomChoicesPanel();
}
else{
LoadCustomChoicesPanel();
}
}
function LoadCustomChoicesPanel(isNew, speed){
if(isNew){
jQuery("#custom_choice_name").val("");
jQuery("#bulk_save_button").html(gf_vars.save);
jQuery("#bulk_cancel_link").show();
jQuery("#bulk_delete_link").hide();
}
else{
jQuery("#custom_choice_name").val(gform_selected_custom_choice);
jQuery("#bulk_save_button").html(gf_vars.update);
jQuery("#bulk_cancel_link").hide();
jQuery("#bulk_delete_link").show();
}
if(!speed)
speed = '';
jQuery("#bulk_save_as").hide(speed);
jQuery("#bulk_custom_edit").show(speed);
}
function CloseCustomChoicesPanel(speed){
if(!speed)
speed = '';
jQuery("#bulk_save_as").show(speed);
jQuery("#bulk_custom_edit").hide(speed);
}
function IsEmpty(array){
var key;
for (key in array) {
if (array.hasOwnProperty(key))
return false;
}
return true;
}
function SetFieldChoice(inputType, index){
text = jQuery("#" + inputType + "_choice_text_" + index).val();
value = jQuery("#" + inputType + "_choice_value_" + index).val();
price = jQuery("#" + inputType + "_choice_price_" + index).val();
var element = jQuery("#" + inputType + "_choice_selected_" + index);
isSelected = element.is(":checked");
field = GetSelectedField();
field.choices[index].text = text;
field.choices[index].value = field.enableChoiceValue ? value : text;
if(field.enablePrice){
var currency = GetCurrentCurrency();
var price = currency.toMoney(price);
if(!price)
price = "";
field.choices[index]["price"] = price;
jQuery("#" + inputType + "_choice_price_" + index).val(price);
}
//set field selections
jQuery("#field_choices :radio, #field_choices :checkbox").each(function(index){
field.choices[index].isSelected = this.checked;
});
LoadBulkChoices(field);
UpdateFieldChoices(GetInputType(field));
}
function UpdateFieldChoices(fieldType){
var choices = '';
var selector = '';
if(fieldType == "checkbox")
field.inputs = new Array();
var skip = 0;
switch(GetInputType(field)){
case "select" :
for(var i=0; i" + field.choices[i].text + "";
}
break;
case "checkbox" :
for(var i=0; i";
}
if(field.choices.length > 5)
choices += "" + gf_vars["editToViewAll"].replace("%d", field.choices.length) + "";
break;
case "radio" :
for(var i=0; i";
}
choices += field.enableOtherChoice ? "" : "";
if(field.choices.length > 5)
choices += "" + gf_vars["editToViewAll"].replace("%d", field.choices.length) + "";
break;
case "list" :
var has_columns = field["choices"] != null;
columns = has_columns ? field["choices"] : [[]];
var class_attr = "";
if(has_columns){
choices += "";
for(var i=0; i" + columns[i]["text"] + "";
}
choices += " |
";
}
else{
class_attr = "class='gf_list_one_column'";
}
choices += "";
choices += "";
for(var j=0; j";
}
choices +=" | ";
choices +="
";
break;
}
selector = '.gfield_' + fieldType;
jQuery(".field_selected " + selector).html(choices);
}
function InsertFieldChoice(index){
field = GetSelectedField();
var price = field["enablePrice"] ? "0.00" : "";
var new_choice = new Choice("", "", price);
if(window["gform_new_choice_" + field.type])
new_choice = window["gform_new_choice_" + field.type](field, new_choice);
field.choices.splice(index, 0, new_choice);
LoadFieldChoices(field);
UpdateFieldChoices(GetInputType(field));
}
function DeleteFieldChoice(index){
field = GetSelectedField();
var value = jQuery('#' + GetInputType(field) + '_choice_value_' + index).val();
if( HasConditionalLogicDependency(field.id, value) ) {
if(!confirm(gf_vars.conditionalLogicDependencyChoice))
return;
}
field.choices.splice(index, 1);
LoadFieldChoices(field);
UpdateFieldChoices(GetInputType(field));
}
function MoveFieldChoice(fromIndex, toIndex){
field = GetSelectedField();
var choice = field.choices[fromIndex];
//deleting from old position
field.choices.splice(fromIndex, 1);
//inserting into new position
field.choices.splice(toIndex, 0, choice);
LoadFieldChoices(field);
UpdateFieldChoices(GetInputType(field));
}
function GetFieldType(fieldId){
return fieldId.substr(0, fieldId.lastIndexOf("_"));
}
function GetSelectedField(){
var id = jQuery(".field_selected")[0].id.substr(6);
return GetFieldById(id);
}
function SetPasswordProperty(isChecked){
SetFieldProperty("enablePasswordInput", isChecked);
}
function ToggleDateCalendar(isInit){
var speed = isInit ? "" : "slow";
var dateType = jQuery("#field_date_input_type").val();
if(dateType == "datefield" || dateType == "datedropdown"){
jQuery("#date_picker_container").hide(speed);
SetCalendarIconType("none");
}
else{
jQuery("#date_picker_container").show(speed);
}
}
function ToggleCalendarIconUrl(isInit){
var speed = isInit ? "" : "slow";
if(jQuery("#gsetting_icon_custom").is(":checked")){
jQuery("#gfield_icon_url_container").show(speed);
}
else{
jQuery("#gfield_icon_url_container").hide(speed);
jQuery("#gfield_calendar_icon_url").val("");
SetFieldProperty('calendarIconUrl', '');
}
}
function SetTimeFormat(format){
SetFieldProperty('timeFormat', format);
LoadTimeInputs();
}
function LoadTimeInputs(){
var format = jQuery("#field_time_format").val();
if(format == "24")
jQuery(".field_selected .gfield_time_ampm").hide();
else
jQuery(".field_selected .gfield_time_ampm").show();
}
function SetDateFormat(format){
SetFieldProperty('dateFormat', format);
LoadDateInputs();
}
function LoadDateInputs(){
var type = jQuery("#field_date_input_type").val();
var format = jQuery("#field_date_format").val();
//setting up field positions
var position = format ? format.substr(0,3) : "mdy";
if(type == "datefield"){
switch(position){
case "ymd" :
jQuery(".field_selected #gfield_input_date_month").remove().insertBefore(".field_selected #gfield_input_date_day");
jQuery(".field_selected #gfield_input_date_year").remove().insertBefore(".field_selected #gfield_input_date_month");
break;
case "mdy" :
jQuery(".field_selected #gfield_input_date_day").remove().insertBefore(".field_selected #gfield_input_date_year");
jQuery(".field_selected #gfield_input_date_month").remove().insertBefore(".field_selected #gfield_input_date_day");
break;
case "dmy" :
jQuery(".field_selected #gfield_input_date_month").remove().insertBefore(".field_selected #gfield_input_date_year");
jQuery(".field_selected #gfield_input_date_day").remove().insertBefore(".field_selected #gfield_input_date_month");
break;
}
jQuery(".field_selected .ginput_date").show();
jQuery(".field_selected .ginput_date_dropdown").hide();
jQuery(".field_selected #gfield_input_datepicker").hide();
jQuery(".field_selected #gfield_input_datepicker_icon").hide();
}
else if(type == "datedropdown"){
switch(position){
case "ymd" :
jQuery(".field_selected #gfield_dropdown_date_month").remove().insertBefore(".field_selected #gfield_dropdown_date_day");
jQuery(".field_selected #gfield_dropdown_date_year").remove().insertBefore(".field_selected #gfield_dropdown_date_month");
break;
case "mdy" :
jQuery(".field_selected #gfield_dropdown_date_day").remove().insertBefore(".field_selected #gfield_dropdown_date_year");
jQuery(".field_selected #gfield_dropdown_date_month").remove().insertBefore(".field_selected #gfield_dropdown_date_day");
break;
case "dmy" :
jQuery(".field_selected #gfield_dropdown_date_month").remove().insertBefore(".field_selected #gfield_dropdown_date_year");
jQuery(".field_selected #gfield_dropdown_date_day").remove().insertBefore(".field_selected #gfield_dropdown_date_month");
break;
}
jQuery(".field_selected .ginput_date_dropdown").css("display", "inline");
jQuery(".field_selected .ginput_date").hide();
jQuery(".field_selected #gfield_input_datepicker").hide();
jQuery(".field_selected #gfield_input_datepicker_icon").hide();
}
else{
jQuery(".field_selected .ginput_date").hide();
jQuery(".field_selected .ginput_date_dropdown").hide();
jQuery(".field_selected #gfield_input_datepicker").show();
//Displaying or hiding the calendar icon
if(jQuery("#gsetting_icon_calendar").is(":checked"))
jQuery(".field_selected #gfield_input_datepicker_icon").show();
else
jQuery(".field_selected #gfield_input_datepicker_icon").hide();
}
}
function SetCalendarIconType(iconType, isInit){
field = GetSelectedField();
if(GetInputType(field) != "date")
return;
if(iconType == undefined)
iconType = "none";
if(iconType == "none")
jQuery("#gsetting_icon_none").prop("checked", true);
else if(iconType == "calendar")
jQuery("#gsetting_icon_calendar").prop("checked", true);
else if(iconType == "custom")
jQuery("#gsetting_icon_custom").prop("checked", true);
SetFieldProperty('calendarIconType', iconType);
ToggleCalendarIconUrl(isInit);
LoadDateInputs();
}
function SetDateInputType(type){
field = GetSelectedField();
if(GetInputType(field) != "date")
return;
SetFieldProperty('dateType', type);
ToggleDateCalendar();
LoadDateInputs();
}
function SetPostImageMeta(){
var displayTitle = jQuery('.field_selected #gfield_display_title').is(":checked");
var displayCaption = jQuery('.field_selected #gfield_display_caption').is(":checked");
var displayDescription = jQuery('.field_selected #gfield_display_description').is(":checked");
var displayLabel = (displayTitle || displayCaption || displayDescription);
//setting property
SetFieldProperty('displayTitle', displayTitle);
SetFieldProperty('displayCaption', displayCaption);
SetFieldProperty('displayDescription', displayDescription);
//updating UI
jQuery('.field_selected .ginput_post_image_title').css("display", displayTitle ? "block" : "none");
jQuery('.field_selected .ginput_post_image_caption').css("display", displayCaption ? "block" : "none");
jQuery('.field_selected .ginput_post_image_description').css("display", displayDescription ? "block" : "none");
jQuery('.field_selected .ginput_post_image_file').css("display", displayLabel ? "block" : "none");
}
function SetFeaturedImage() {
var isChecked = jQuery('#gfield_featured_image').is(':checked');
if(isChecked) {
for(i in form.fields) {
if(!form.fields.hasOwnProperty(i))
continue;
form.fields[i].postFeaturedImage = false;
}
SetFieldProperty('postFeaturedImage', true);
}
else{
SetFieldProperty('postFeaturedImage', false);
}
}
function SetFieldProperty(name, value){
if(value == undefined)
value = "";
GetSelectedField()[name] = value;
}
function SetInputName(value, inputId){
var field = GetSelectedField();
if(value)
value = value.trim();
if(!inputId){
field["inputName"] = value;
}
else{
for(var i=0; i b["text"].toLowerCase() );});
}
function SetFieldLabel(label){
var requiredElement = jQuery(".field_selected .gfield_required")[0];
jQuery(".field_selected .gfield_label, .field_selected .gsection_title").text(label).append(requiredElement);
SetFieldProperty("label", label);
}
function SetCaptchaTheme(theme, thumbnailUrl){
jQuery(".field_selected .gfield_captcha").attr("src", thumbnailUrl);
SetFieldProperty("captchaTheme", theme);
}
function SetCaptchaSize(size){
var type = jQuery("#field_captcha_type").val();
SetFieldProperty("simpleCaptchaSize", size);
RedrawCaptcha();
jQuery(".field_selected .gfield_captcha_input_container").removeClass(type + "_small").removeClass(type + "_medium").removeClass(type + "_large").addClass(type + "_" + size);
}
function SetCaptchaFontColor(color){
SetFieldProperty("simpleCaptchaFontColor", color);
RedrawCaptcha();
}
function SetCaptchaBackgroundColor(color){
SetFieldProperty("simpleCaptchaBackgroundColor", color);
RedrawCaptcha();
}
function RedrawCaptcha(){
var captchaType = jQuery("#field_captcha_type").val();
if(captchaType == "math"){
url_1 = GetCaptchaUrl(1);
url_2 = GetCaptchaUrl(2);
url_3 = GetCaptchaUrl(3);
jQuery(".field_selected .gfield_captcha:eq(0)").attr("src", url_1);
jQuery(".field_selected .gfield_captcha:eq(1)").attr("src", url_2);
jQuery(".field_selected .gfield_captcha:eq(2)").attr("src", url_3);
}
else{
url = GetCaptchaUrl();
jQuery(".field_selected .gfield_captcha").attr("src", url);
}
}
function SetFieldSize(size){
jQuery(".field_selected .small, .field_selected .medium, .field_selected .large").removeClass("small").removeClass("medium").removeClass("large").addClass(size);
SetFieldProperty("size", size);
}
function SetFieldAdminOnly(isAdminOnly){
SetFieldProperty('adminOnly', isAdminOnly);
if(isAdminOnly)
jQuery(".field_selected").addClass("field_admin_only");
else
jQuery(".field_selected").removeClass("field_admin_only");
}
function SetFieldDefaultValue(defaultValue){
jQuery(".field_selected > div > input, .field_selected > div > textarea").val(defaultValue);
SetFieldProperty('defaultValue', defaultValue);
}
function SetFieldDescription(description){
if(description == undefined)
description = "";
jQuery(".field_selected .gfield_description, .field_selected .gsection_description").html(description);
SetFieldProperty('description', description);
}
function SetPasswordStrength(isEnabled){
if(isEnabled){
jQuery(".field_selected .gfield_password_strength").show();
}
else{
jQuery(".field_selected .gfield_password_strength").hide();
//resetting min strength
jQuery("#gfield_min_strength").val("");
SetFieldProperty('minPasswordStrength', "");
}
SetFieldProperty('passwordStrengthEnabled', isEnabled);
}
function SetEmailConfirmation(isEnabled){
if(isEnabled){
jQuery(".field_selected .ginput_single_email").hide();
jQuery(".field_selected .ginput_confirm_email").show();
}
else{
jQuery(".field_selected .ginput_confirm_email").hide();
jQuery(".field_selected .ginput_single_email").show();
}
SetFieldProperty('emailConfirmEnabled', isEnabled);
//UpdateDescriptionPlacement();
}
function SetCardType(elem, value) {
var cards = GetSelectedField()['creditCards'] ? GetSelectedField()['creditCards'] : new Array();
if(jQuery(elem).is(':checked')) {
if(jQuery.inArray(value, cards) == -1) {
jQuery('.gform_card_icon_' + value).fadeIn();
cards[cards.length] = value;
}
} else {
var index = jQuery.inArray(value, cards);
if(index != -1) {
jQuery('.gform_card_icon_' + value).fadeOut();
cards.splice(index, 1);
}
}
SetFieldProperty('creditCards', cards);
}
function SetFieldRequired(isRequired){
var required = isRequired ? "*" : "";
jQuery(".field_selected .gfield_required").html(required);
SetFieldProperty('isRequired', isRequired);
}
function SetMaxLength(input) {
var patt = GetMaxLengthPattern();
var cleanValue = '';
var characters = input.value.split('');
for(i in characters) {
if(!characters.hasOwnProperty(i))
continue;
if( !patt.test(characters[i]) )
cleanValue += characters[i];
}
input.value = cleanValue;
SetFieldProperty('maxLength', cleanValue);
}
function GetMaxLengthPattern() {
return /[a-zA-Z\-!@#$%^&*();'":_+=<,>.~`?\/|\[\]\{\}\\]/;
}
/**
* Validate any keypress events based on a provided RegExp.
*
* Function retrieves the character code from the keypress event and tests it against provided pattern.
* Optionally specify 'matchPositive' argument to false in order to return true if the character is NOT
* in the provided pattern.
*
* @param event The JS keypress event.
* @param patt RegExp to test keypress character against.
* @param matchPositive Defaults to true. Whether to return true if the character is found or NOT found in the pattern.
*/
function ValidateKeyPress(event, patt, matchPositive) {
var matchPositive = typeof matchPositive == 'undefined' ? true : matchPositive;
var char = event['which'] ? event.which : event.keyCode;
var isMatch = patt.test(String.fromCharCode(char));
if(event.ctrlKey)
return true;
return matchPositive ? isMatch : !isMatch;
}
function IndexOf(ary, item){
for(var i=0; i | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | |
|
').appendTo("body");jQuery(document.createElement("div")).attr("id","iColorPickerBg").click(function(){jQuery("#iColorPickerBg").hide();jQuery("#iColorPicker").fadeOut()}).appendTo("body");jQuery('table.pickerTable td').css({'width':'12px','height':'14px','border':'1px solid #000','cursor':'pointer'});jQuery('#iColorPicker table.pickerTable').css({'border-collapse':'collapse'});jQuery('#iColorPicker').css({'border':'1px solid #ccc','background':'#333','padding':'5px','color':'#fff','z-index':9999})}
jQuery('#colorPreview').css({'height':'50px'});
})
};
jQuery(function(){iColorPicker()});
function SetColorPickerColor(field_name, color, callback){
var chip = jQuery('#chip_' + field_name);
chip.css("background-color", color);
if(callback)
window[callback](color);
}
function SetFieldChoices(){
var field = GetSelectedField();
for(var i=0; i