Current Path : /var/test/www/html/wp-content/plugins/gravityforms/includes/addon/js/ |
Current File : /var/test/www/html/wp-content/plugins/gravityforms/includes/addon/js/gaddon_genericmap.min.js |
var GFGenericMap=function(a){var b=this;return b.options=a,b.UI=jQuery("#gaddon-setting-row-"+b.options.fieldName),b.init=function(){b.bindEvents(),b.setupData(),b.setupRepeater()},b.bindEvents=function(){b.UI.on("change",'select[name="_gaddon_setting_'+b.options.keyFieldName+'"]',function(){var a=jQuery(this),b=a.data("chosen")?a.siblings(".chosen-container"):a.data("select2")?a.siblings(".select2-container"):a,c=a.siblings(".custom-key-container");"gf_custom"==a.val()&&b.fadeOut(function(){c.fadeIn().focus()})}),b.UI.on("change",'select[name="_gaddon_setting_'+b.options.valueFieldName+'"]',function(){var a=jQuery(this),b=a.data("chosen")?a.siblings(".chosen-container"):a.data("select2")?a.siblings(".select2-container"):a,c=a.siblings(".custom-value-container");"gf_custom"==a.val()&&b.fadeOut(function(){c.fadeIn().focus()})}),b.UI.on("click","a.custom-key-reset",function(a){a.preventDefault();var b=jQuery(this),c=b.parents(".custom-key-container"),d=c.siblings("select.key"),e=d.data("chosen")?d.siblings(".chosen-container"):d.data("select2")?d.siblings(".select2-container"):d;c.fadeOut(function(){c.find("input").val("").change(),d.val("").trigger("change"),e.fadeIn().focus()})}),b.UI.on("click","a.custom-value-reset",function(a){a.preventDefault();var b=jQuery(this),c=b.parents(".custom-value-container"),d=c.siblings("select.value"),e=d.data("chosen")?d.siblings(".chosen-container"):d.data("select2")?d.siblings(".select2-container"):d;c.fadeOut(function(){c.find("input").val("").change(),d.val("").trigger("change"),e.fadeIn().focus()})}),b.UI.closest("form").on("submit",function(a){jQuery('[name^="_gaddon_setting_'+b.options.fieldName+'_"]').each(function(a){jQuery(this).removeAttr("name")})})},b.setupData=function(){b.data=jQuery.parseJSON(jQuery("#"+b.options.fieldId).val()),b.data||(b.data=[{key:"",value:"",custom_key:"",custom_value:""}])},b.setupRepeater=function(){var a=b.options.limit>0?b.options.limit:0;b.UI.find("tbody.repeater").repeater({limit:a,items:b.data,addButtonMarkup:"<span>+</span>",removeButtonMarkup:"<span>-</span>",callbacks:{add:function(a,c,d){var e=c.find('select[name="_gaddon_setting_'+b.options.keyFieldName+'"]');!d.custom_key&&e.length>0?c.find(".custom-key-container").hide():c.find(".key").hide();var f=c.find('select[name="_gaddon_setting_'+b.options.valueFieldName+'"]');!d.custom_value&&f.length>0?c.find(".custom-value-container").hide():c.find(".value").hide(),b.options.mergeTags&&new gfMergeTagsObj(form,c.find(".custom-value-container input")),window.hasOwnProperty("gform")&&gform.doAction("gform_fieldmap_add_row",a,c,d)},save:function(a,c){jQuery("#"+b.options.fieldId).val(JSON.stringify(c))}}})},b.init()};