jQuery(function(a){var b={is_wcml_product:!1,field_views:null,footer_view:null,save_buttons_tip:null,init:function(){a(document).on("WPML_TM.editor.before_render",b.do_editor_before_render),a(document).on("WPML_TM.editor.ready",b.do_editor_ready)},show_file_paths_button:function(a,b){"file-url"===b.field.field_type.substr(0,8)&&b.$el.append('
")},show_downloadable_files_frame:function(b){var c,d,e,f=a(this);if(d=f.closest(".wpml-form-row").find(".translated_value"),e=d.val(),b.preventDefault(),c)return void c.open();var g=[new wp.media.controller.Library({library:wp.media.query(),multiple:!0,title:f.data("choose"),priority:20,filterable:"uploaded"})];c=wp.media.frames.downloadable_file=wp.media({title:f.data("choose"),library:{type:""},button:{text:f.data("update")},multiple:!0,states:g}),c.on("select",function(){c.state().get("selection").map(function(a){a=a.toJSON(),a.url&&(e=a.url)}),d.val(e)}),c.on("ready",function(){c.uploader.options.uploader.params={type:"downloadable_product"}}),c.open()},update_slug:function(){var b=a("#job_field_title .js-translated-value").val(),c=a("#job_field_slug .js-translated-value");if(""!=b&&""==c.val()){var d=a("#icl_tm_editor input[name=job_id]").val();c.prop("readonly","on"),a.ajax({url:ajaxurl,type:"POST",dataType:"json",data:{action:"wcml_editor_auto_slug",title:b,job_id:d},success:function(b){c.val(b.slug),c.removeAttr("readonly"),a("#icl_tm_copy_link_slug").prop("disabled","on")}})}},do_editor_before_render:function(c,d){b.is_wcml_product="post_product"===d,b.is_wcml_product&&(a(document).on("WPML_TM.editor.field_view_ready",b.show_file_paths_button),a(document).on("WPML_TM.editor.field_update_ui",b.field_update_ui),a(document).on("click",".wcml_file_paths_button",b.show_downloadable_files_frame),a(document).on("blur","#job_field_title .js-translated-value",b.update_slug),a(document).on("focus","#job_field_slug .js-translated-value",b.update_slug),a(document).on("blur","#job_field_slug .js-translated-value",b.update_slug))},do_editor_ready:function(a,c,d,e){b.is_wcml_product&&(b.save_buttons_tip=WCML_Tooltip.add_before(".js-save-and-close",wcml_settings.strings.save_tooltip,"margin-right: 3px;"),b.field_views=d,b.footer_view=e,b.update_save_button_state(),b.check_variations_fields(),wcml_settings.hide_resign?b.footer_view.hideResignButton(!0):WCML_Tooltip.add_after(".js-resign",wcml_settings.strings.resign_tooltip,"margin-left:-12px;"))},update_save_button_state:function(){var a=["title","product_content","product_excerpt"],c=!0;_.each(b.field_views,function(d){""!==d.getTranslation()&&jQuery.inArray(d.getFieldType(),a)!==-1&&(c=!1,b.save_buttons_tip&&b.save_buttons_tip.hide())}),c&&b.save_buttons_tip.show(),b.footer_view.disableSaveButtons(c)},field_update_ui:function(a,c){b.update_save_button_state()},check_variations_fields:function(){var a=!1;jQuery('[id^="job_field_variation_desc"]').closest(".postbox").find(".original_value").each(function(){if(""!==jQuery(this).val())return!1;a=jQuery(this)}),a&&a.closest(".postbox").find(".button-link").click()}};b.init()});