/**
* PrestaShop module created by VEKIA, a guy from official PrestaShop community ;-)
*
* @author VEKIA https://www.prestashop.com/forums/user/132608-vekia/
* @copyright 2010-2020 VEKIA
* @license This program is not free software and you can't resell and redistribute it
*
* CONTACT WITH DEVELOPER http://mypresta.eu
* support@mypresta.eu
*
*
* NEW TINYMCE FILE !
*
*/
var tinyMceLangLoaded = false;
function UrlExistsTinyMcePro(url) {
var http = new XMLHttpRequest();
http.open('HEAD', url, false);
http.send();
return http.status != 404;
}
$(document).ready(function () {
if (window.location.href.indexOf("AdminTranslations") > -1) {
if (typeof tinyMCE === 'undefined') {
setTimeout(function () {
$('.mails_field').off();
run_new_mail_editor();
}, 100);
return;
}
}
});
function run_new_mail_editor() {
$('.mails_field').on('shown.bs.collapse', function () {
var active_email = $(this).find('.email-collapse.in');
var frame = active_email.find('.email-html-frame');
var src = frame.data('email-src');
var rte_mail_selector = active_email.find('textarea.rte-mail').data('rte');
var rte_mail_config = {};
rte_mail_config['editor_selector'] = 'rte-mail-' + rte_mail_selector;
$('#translation_mails-control-actions').appendTo($(this).find('.panel-collapse.in'));
if (frame.find('iframe.email-frame').length == 0) {
frame.append('');
$.ajax({
url: 'ajax.php',
type: 'POST',
dataType: 'html',
data: {
getEmailHTML: true,
email: src,
token: window.token
},
success: function (result) {
var doc = frame.find('iframe')[0].contentWindow.document;
doc.open();
doc.write(result);
doc.close();
tinySetup(rte_mail_config);
}
});
}
});
}
function tinySetup(config) {
if (typeof tinyMCE === 'undefined') {
setTimeout(function () {
tinySetup(config);
}, 100);
return;
}
if (!config) {
config = {};
}
if (typeof config.editor_selector != 'undefined') {
config.selector = '.' + config.editor_selector;
}
var cssId = 'cssIdFontAwesomePro'; // you could encode the css path itself to generate id..
if (!document.getElementById('cssIdFontAwesomePro')) {
var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');
link.id = cssId;
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = '//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css';
link.media = 'all';
head.appendChild(link);
}
var path_array = baseAdminDir.split('/');
path_array.splice((path_array.length - 2), 2);
var final_path = path_array.join('/');
window.tinyMCEPreInit = {};
window.tinyMCEPreInit.base = final_path + '/js/tiny_mce';
window.tinyMCEPreInit.suffix = '.min';
var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');
link.id = cssId;
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = final_path + '/modules/tinymcepro/lib/iconset.css';
link.media = 'all';
head.appendChild(link);
if (typeof config.editor_selector != 'undefined')
config.selector = '.' + config.editor_selector;
default_config = {
editor_selector: ".rte",
selector: ".rte",
content_style: tinymcepro_contentstyle,
content_css: final_path + '/modules/tinymcepro/lib/editor.css',
plugins: tinymcepro_autoresize + tinymcepro_adv_bootstrap +" lineheight, paragraph, template, toc, bootstraplite, addiframe, imagetools, ecpicker, bootstrapaccordion, editattributes, bs_alert, bs_images, powerpaste, advlist, smileys, youtube, fullscreen, fontawesome, visualblocks, preview searchreplace print insertdatetime, hr charmap anchor code link image pagebreak table " + tinymcepro_contextmenu + " filemanager table code media textcolor editattributes",
toolbar1: tinymcepro_templates + " newdocument,print,|,undo,redo,|,lineheightselect,|,styleselect,|,formatselect,|,fontselect,|,fontsizeselect,|,editattributes,|,toc",
toolbar2: "cut,copy,paste,searchreplace,|,bold,italic,underline,strikethrough,superscript,subscript,|,forecolor,ecpicker,backcolor,|,bullist,numlist,alignleft,aligncenter,alignright,alignjustify,outdent,indent,blockquote,|,removeformat,|,link,unlink,anchor,",
toolbar3: "bootstraplite,bs_alert,bootstrapaccordion,|,"+ tinymcepro_adv_bootstrap_toolbar,
toolbar4: "code,preview,visualblocks,fullscreen,|,table,|,youtube,|,fontawesome,|,image,bs_images,|,addiframe,media,smileys,charmap,hr,inserttime,",
browser_spellcheck: true,
templates: JSON.parse(tinymcepro_template_files),
image_advtab: true,
table_row_advtab: true,
external_filemanager_path: baseAdminDir + "filemanager/",
filemanager_title: "File manager",
external_plugins: {"filemanager": baseAdminDir + "filemanager/plugin.min.js"},
contextmenu: "paragraph link image inserttable | cell row column deletetable",
language: iso_user,
skin: "prestashop",
statusbar: false,
relative_urls: false,
convert_urls: false,
font_formats: tinymcepro_fonts,
fontsize_formats: tinymcepro_sizes,
lineheight_formats: tinymcepro_lineheight,
allow_script_urls: true,
entity_encoding: "raw",
link_title: true,
verify_html: false,
forced_root_block: false,
force_br_newlines: tinymcepro_force_br_newlines,
convert_newlines_to_brs: tinymcepro_newlines_to_brs,
force_p_newlines: tinymcepro_force_p_newlines,
height: tinymceproHeight,
autoresize_max_height: 999999,
tinyplusInclude: {
framework: "b3",
includeCssToGlobalDoc: false
},
menu: {
edit: {title: 'Edit', items: 'undo redo | cut copy paste | selectall'},
insert: {title: 'Insert element', items: 'charmap fontawesome image media emoticons hr inserttime link anchor | pagebreak'},
view: {title: 'View', items: 'visualaid'},
format: {title: 'Format', items: 'bold italic underline strikethrough superscript subscript | formats | removeformat'},
table: {title: 'Table', items: 'inserttable tableprops deletetable | cell row column'}
},
valid_children: "+body[meta|style|script|iframe|section|link],+pre[iframe|section|script|div|p|br|span|img|style|h1|h2|h3|h4|h5|link],+div[meta|video|source],+video[source],*[*],+label[embed|sub|sup|textarea|strong|strike|small|em|form|frame|iframe|input|select|legend|button|div|img|h1|h2|h3|h4|h5|h6|h7|span|p|section|pre|b|u|i|a|ol|ul|li|table|td|tr|th|tbody|thead]",
valid_elements: '+*[*],a[accesskey|charset|class|coords|dir