diff --git a/addons/default/visiosoft/advs-module/migrations/2018_09_25_211039_visiosoft.module.advs__create_advs_stream.php b/addons/default/visiosoft/advs-module/migrations/2018_09_25_211039_visiosoft.module.advs__create_advs_stream.php index 77c2ed644..96ef7cf30 100644 --- a/addons/default/visiosoft/advs-module/migrations/2018_09_25_211039_visiosoft.module.advs__create_advs_stream.php +++ b/addons/default/visiosoft/advs-module/migrations/2018_09_25_211039_visiosoft.module.advs__create_advs_stream.php @@ -32,7 +32,9 @@ class VisiosoftModuleAdvsCreateAdvsStream extends Migration 'slug' => [ 'required' => true, ], - 'advs_desc', + 'advs_desc' => [ + 'translatable' => true, + ], 'cat1', 'cat2', 'cat3', diff --git a/addons/default/visiosoft/advs-module/resources/js/new-create.js b/addons/default/visiosoft/advs-module/resources/js/new-create.js index e85dae5e0..b94edf40f 100644 --- a/addons/default/visiosoft/advs-module/resources/js/new-create.js +++ b/addons/default/visiosoft/advs-module/resources/js/new-create.js @@ -62,4 +62,94 @@ $('input[name="price"]').on('click', function () { { $(this).val(""); } -}) \ No newline at end of file +}) + +$(document).on('ajaxComplete ready shown.bs.tab', function () { + + // Initialize WYSIWYG editors. + $('textarea[data-field="advs_desc"]:not(.hasEditor)').each(function () { + + /** + * Gather available buttons / plugins. + */ + let textarea = $(this); + + let buttons = textarea.data('available_buttons'); + let plugins = textarea.data('available_plugins'); + + textarea.addClass('hasEditor'); + + textarea.redactor({ + + element: $(this), + + /** + * Initialize the editor icons. + */ + callbacks: { + init: function () { + + let icons = {}; + + $.each(buttons, function (k, v) { + if (v.icon) { + icons[v.button ? v.button : k] = ''; + } + }); + + $.each(plugins, function (k, v) { + if (v.icon) { + icons[v.button ? v.button : k] = ''; + } + }); + + $.each(this.button.all(), $.proxy(function (i, s) { + + let key = $(s).attr('rel'); + + if (typeof icons[key] !== 'undefined') { + let icon = icons[key]; + let button = this.button.get(key); + this.button.setIcon(button, icon); + } + + }, this)); + } + }, + + /** + * Settings + */ + script: false, + structure: true, + linkTooltip: true, + cleanOnPaste: true, + toolbarFixed: false, + imagePosition: true, + imageResizable: true, + breakline: Boolean(textarea.data('breakline')), + removeNewLines: Boolean(textarea.data('remove_new_lines')), + imageFloatMargin: '20px', + removeEmpty: ['strong', 'em', 'p'], + + /** + * Features + */ + minHeight: textarea.data('height'), + placeholder: textarea.attr('placeholder'), + folders: textarea.data('folders').toString().split(','), + buttons: textarea.data('buttons').toString().split(','), + plugins: textarea.data('plugins').toString().split(',') + }); + + textarea.closest('form').on('submit', function () { + textarea.val(textarea.redactor('code.get')); + }); + + if (textarea.is('[readonly]') || textarea.is('[disabled]')) { + textarea.redactor('button.disableAll'); + textarea.redactor('core.editor') + .attr('contenteditable', false); + } + }); +}); diff --git a/addons/default/visiosoft/advs-module/resources/views/advs/new-create.twig b/addons/default/visiosoft/advs-module/resources/views/advs/new-create.twig index 7ce5e13de..dea8f5a43 100644 --- a/addons/default/visiosoft/advs-module/resources/views/advs/new-create.twig +++ b/addons/default/visiosoft/advs-module/resources/views/advs/new-create.twig @@ -105,7 +105,7 @@