/*jshint browser:true, devel:true */ /*global _, jQuery, ajaxurl, icl_ajx_url, icl_ajxloaderimg, wpActiveEditor, tinyMCE, tinymce, iclSaveForm, tmEditorStrings, WPML_TM.editorFooterView, WPML_TM.editorHeaderView, WpmlTmEditorMainView, WpmlTranslationEditorTemplates, WpmlTemplateCompiler */ var WPML_TM = WPML_TM || {}; "use strict"; var tmEditor = { dontShowAgain: false, copyLinks: {}, copyLinkViews: [], footerView: {}, model: {}, view: {}, update_copy_link_visibility: function () { var self = tmEditor; self.copyLinks.each(function () { var type = this.id.replace(/^icl_tm_copy_link_/, ''); var content = self.get_content_for_copy_field(type); if (content && content.trim() !== "") { jQuery(this).closest('span').hide(); } else { jQuery(this).closest('span').show(); } }); if (self.copyLinks.filter(':visible').length === 1) { self.copyLinks.closest('span').hide(); } else { self.copyLinks.find('#icl_tm_copy_link_icl_all_fields').closest('span').show(); } }, findInputFieldForCheckBox: function (cbName) { var fieldName = cbName.replace(/finished/, 'data'); var inputField = jQuery('[name="' + fieldName + '"]'); if (inputField.length === 0) { inputField = false; } return inputField; }, find_custom_editor: function (field_type) { var custom_editor = false; var editors; if (typeof tinyMCE !== 'undefined' && (editors = tinyMCE.editors) !== undefined) { jQuery.each( editors, function () { var item = this; if (("field-wpcf-" + field_type).toLowerCase() === item.id.toLowerCase() || field_type.toLowerCase() === item.id.toLowerCase()) { custom_editor = item; } } ); } return custom_editor; }, get_content_for_copy_field: function (field_type) { var editor = this.find_custom_editor(field_type); return editor !== false ? editor.getContent() : jQuery('#' + field_type).val(); }, icl_populate_field: function (field_type, content) { var custom_editor = tmEditor.find_custom_editor(field_type); if (custom_editor !== false && !custom_editor.isHidden() && custom_editor.getContent().trim() === "") { custom_editor.insertContent(content); } else { custom_editor = jQuery('#' + field_type); if ('undefined' !== typeof custom_editor && 'undefined' !== typeof custom_editor.val()) { custom_editor.val(custom_editor.val().trim() !== "" ? custom_editor.val() : content); } } } }; jQuery(document).ready(function () { var wpml_diff_toggle = jQuery('.wpml_diff_toggle'); wpml_diff_toggle.closest('.wpml_diff_wrapper').find('.wpml_diff').hide(); wpml_diff_toggle.on('click', function (e) { e.preventDefault(); jQuery(this).closest('.wpml_diff_wrapper').find('.wpml_diff').slideToggle(); return false; }); jQuery('.tm-learn-more').on('click', function (e) { e.preventDefault(); var popUpHtml = '
', tmEditorStrings.dontShowAgain, '