/* Minified: Inspector.properties.CustomField.js, jquery.configureCustomFields.js */
App.Inspector.Properties.CustomField=function(object,client_interface){var wrapper=$(this);var wrapper_row=wrapper.parents("div.property:first");var property_name=wrapper_row.attr("property_name");if(typeof(object.custom_fields)=="object"&&object.custom_fields&&typeof(object.custom_fields[property_name])!="undefined"){if(typeof(object.custom_fields[property_name]["value"])=="string"){var check_string=property_name+object.custom_fields[property_name]["value"].clean()}else{var check_string=property_name+object.custom_fields[property_name]["value"]}}else{var check_string="no_value"}if(wrapper.attr("check_string")==check_string){return true}wrapper.attr("check_string",check_string).empty();if(object.custom_fields[property_name]["value"]){if(typeof(object.custom_fields[property_name]["value"])=="string"){wrapper.append(object.custom_fields[property_name]["value"].clean())}else{wrapper.append(object.custom_fields[property_name]["value"])}wrapper_row.show()}else{wrapper_row.hide()}};
jQuery.fn.configureCustomFields=function(){return this.each(function(){var wrapper=$(this);var initialy_enabled=[];var show_hide_data_loss_alert=function(){var missing_fields_count=0;App.each(initialy_enabled,function(k,field_name){if(wrapper.find("tr.configure_custom_field[field_name="+field_name+"] input[type=checkbox]:checked").length==0){missing_fields_count++}});if(missing_fields_count==0){wrapper.find("p.custom_field_data_will_be_removed").remove()}else{var warning=wrapper.find("p.custom_field_data_will_be_removed");if(warning.length<1){warning=$('<p class="custom_field_data_will_be_removed"></p>').prependTo(wrapper)}if(missing_fields_count==1){warning.html("<b>"+App.lang("Warning")+"</b>: "+App.lang("You are about to disable a custom field. Data tracked in this field will be permanently removed if you save these changes")+"!")}else{warning.html("<b>"+App.lang("Warning")+"</b>: "+App.lang("You are about to disable :num custom fields. Data tracked in these fields will be permanently removed if you save these changes",{num:missing_fields_count})+"!")}}};wrapper.find("tr.configure_custom_field").each(function(){var row=$(this);var checkbox=row.find("td.is_enabled input[type=checkbox]");if(checkbox.prop("checked")){initialy_enabled.push(row.attr("field_name"))}else{row.find("input[type=text], select").prop("disabled",true)}});wrapper.find("tr.configure_custom_field td.is_enabled input[type=checkbox]").click(function(){var row=$(this).parents("tr.configure_custom_field");if(this.checked){row.find("input[type=text], select").prop("disabled",false);row.find("td.field_label input").focus();show_hide_data_loss_alert()}else{row.find("input[type=text], select").prop("disabled",true);show_hide_data_loss_alert()}})})};
