1 line
25 KiB
JavaScript
1 line
25 KiB
JavaScript
|
|
function FormatCurrency(a){if(gf_vars.gf_currency_config){var b=new Currency(gf_vars.gf_currency_config),c=b.toMoney(jQuery(a).val());jQuery(a).val(c)}}function ToggleConditionalLogic(a,b){var c=a?"":"slow";if(jQuery("#"+b+"_conditional_logic").is(":checked")){CreateConditionalLogic(b,GetConditionalObject(b)),SetConditionalProperty(b,"actionType",jQuery("#"+b+"_action_type").val()),SetConditionalProperty(b,"logicType",jQuery("#"+b+"_logic_type").val()),SetRule(b,0),jQuery("#"+b+"_conditional_logic_container").show(c)}else jQuery("#"+b+"_conditional_logic_container").hide(c)}function GetConditionalObject(a){var b=!1;switch(a){case"page":case"field":b=GetSelectedField();break;case"next_button":b=GetSelectedField().nextButton;break;case"confirmation":b=confirmation;break;case"notification":b=current_notification;break;default:b="undefined"!=typeof form&&form.button}return b=gform.applyFilters("gform_conditional_object",b,a)}function CreateConditionalLogic(a,b){b.conditionalLogic||(b.conditionalLogic=new ConditionalLogic);var c,d="hide"==b.conditionalLogic.actionType?"selected='selected'":"",e="show"==b.conditionalLogic.actionType?"selected='selected'":"",f="all"==b.conditionalLogic.logicType?"selected='selected'":"",g="any"==b.conditionalLogic.logicType?"selected='selected'":"";c="section"==b.type?gf_vars.thisSectionIf:"field"==a?gf_vars.thisFieldIf:"page"==a?gf_vars.thisPage:"confirmation"==a?gf_vars.thisConfirmation:"notification"==a?gf_vars.thisNotification:gf_vars.thisFormButton;var h={};h.actionType="<select id='"+a+"_action_type' onchange='SetConditionalProperty(\""+a+"\", \"actionType\", jQuery(this).val());'><option value='show' "+e+">"+gf_vars.show+"</option><option value='hide' "+d+">"+gf_vars.hide+"</option></select>",h.objectDescription=c,h.logicType="<select id='"+a+"_logic_type' onchange='SetConditionalProperty(\""+a+"\", \"logicType\", jQuery(this).val());'><option value='all' "+f+">"+gf_vars.all+"</option><option value='any' "+g+">"+gf_vars.any+"</option></select>",h.ofTheFollowingMatch=gf_vars.ofTheFollowingMatch;var i=makeArray(h),j=i.join(" ");j=gform.applyFilters("gform_conditional_logic_description",j,h,a,b);var k,l;for(k=0;k<b.conditionalLogic.rules.length;k++)l=b.conditionalLogic.rules[k],j+="<div width='100%' class='gf_conditional_logic_rules_container'>",j+=GetRuleFields(a,k,l.fieldId),j+=GetRuleOperators(a,k,l.fieldId,l.operator),j+=GetRuleValues(a,k,l.fieldId,l.value),j+="<a class='add_field_choice' title='add another rule' onclick=\"InsertRule('"+a+"', "+(k+1)+');" onkeypress="InsertRule(\''+a+"', "+(k+1)+");\" ><i class='gficon-add'></i></a>",b.conditionalLogic.rules.length>1&&(j+="<a class='delete_field_choice' title='remove this rule' onclick=\"DeleteRule('"+a+"', "+k+');" onkeypress="DeleteRule(\''+a+"', "+k+");\" ><i class='gficon-subtract'></i></a></li>"),j+="</div>";jQuery("#"+a+"_conditional_logic_container").html(j),Placeholders.enable()}function GetRuleOperators(a,b,c,d){var e,f,g,h;return f={is:"is",isnot:"isNot",">":"greaterThan","<":"lessThan",contains:"contains",starts_with:"startsWith",ends_with:"endsWith"},e="<select id='"+a+"_rule_operator_"+b+"' class='gfield_rule_select' onchange='SetRuleProperty(\""+a+'", '+b+', "operator", jQuery(this).val());var valueSelector="#'+a+"_rule_value_"+b+'"; jQuery(valueSelector).replaceWith(GetRuleValues("'+a+'", '+b+',"'+c+'", ""));jQuery(valueSelector).change();\'>',g=IsEntryMeta(c)?GetOperatorsForMeta(f,c):f,g=gform.applyFilters("gform_conditional_logic_operators",g,a,c),jQuery.each(g,function(a,b){h=d==a?"selected='selected'":"",e+="<option value='"+a+"' "+h+">"+gf_vars[b]+"</option>"}),e+="</select>"}function GetOperatorsForMeta(a,b){var c={};return entry_meta[b]&&entry_meta[b].filter&&entry_meta[b].filter.operators?jQuery.each(a,function(a,d){jQuery.inArray(a,entry_meta[b].filter.operators)>=0&&(c[a]=d)}):c=a,c}function GetRuleFields(a,b,c){for(var d="<select id='"+a+"_rule_field_"+b+"' class='gfield_rule_select' onchange='jQuery(\"#"+a+"_rule_operator_"+b+'").replaceWith(GetRuleOperators("'+a+'", '+b+', jQuery(this).val()));jQuery("#'+a+"
|