From 1d6924261105510ad7d68d75a0861f01277f18f0 Mon Sep 17 00:00:00 2001 From: poonam_b Date: Mon, 25 Nov 2019 16:36:38 +0530 Subject: [PATCH 01/22] Preview email facility in tjnotification #65 --- .../admin/views/notification/tmpl/edit.php | 37 +++++++++++++++ .../admin/views/notification/view.html.php | 4 ++ src/com_tjnotifications/media/js/template.js | 47 +++++++++++++++++++ .../media/js/template.min.js | 9 ++++ src/com_tjnotifications/tjnotifications.xml | 4 ++ 5 files changed, 101 insertions(+) create mode 100644 src/com_tjnotifications/media/js/template.js create mode 100644 src/com_tjnotifications/media/js/template.min.js diff --git a/src/com_tjnotifications/admin/views/notification/tmpl/edit.php b/src/com_tjnotifications/admin/views/notification/tmpl/edit.php index e7b822f6..bf7421a9 100644 --- a/src/com_tjnotifications/admin/views/notification/tmpl/edit.php +++ b/src/com_tjnotifications/admin/views/notification/tmpl/edit.php @@ -4,7 +4,13 @@ defined('_JEXEC') or die; JHtml::_('formbehavior.chosen','select'); JHtml::_('behavior.formvalidator'); +use Joomla\CMS\Language\Text; + $today= gmdate('Y-m-d'); + +$options['relative'] = true; + +JHtml::_('script', 'com_tjnotifications/template.js', $options); ?> diff --git a/src/com_tjnotifications/admin/views/notification/view.html.php b/src/com_tjnotifications/admin/views/notification/view.html.php index dff5fa7e..8b008b68 100644 --- a/src/com_tjnotifications/admin/views/notification/view.html.php +++ b/src/com_tjnotifications/admin/views/notification/view.html.php @@ -83,6 +83,10 @@ protected function addToolBar() JToolBarHelper::apply('notification.editSave', 'JTOOLBAR_APPLY'); JToolBarHelper::save('notification.saveClose', 'JTOOLBAR_SAVE'); JToolBarHelper::custom('notification.saveNew', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + + // Add preview toolbar + JToolbarHelper::modal('templatePreview', 'icon-eye', 'COM_TJNOTIFICATIONS_TEMPLATE_PREVIEW'); + JToolBarHelper::cancel('notification.cancel', 'JTOOLBAR_CANCEL'); } diff --git a/src/com_tjnotifications/media/js/template.js b/src/com_tjnotifications/media/js/template.js new file mode 100644 index 00000000..ffb289a8 --- /dev/null +++ b/src/com_tjnotifications/media/js/template.js @@ -0,0 +1,47 @@ +/** + * @package TJNotifications + * @subpackage com_tjnotifications + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +var template = { + + previewTemplate: function () { + + jQuery(document).on('click', 'button[data-target="#templatePreview"]', function () { + + jQuery('#show-info').hide(); + + if (typeof tinyMCE != "undefined") + { + tinyMCE.execCommand('mceToggleEditor', false, 'jform_email_body'); + } + else if (typeof CodeMirror != "undefined") + { + var editor = document.querySelector('.CodeMirror').CodeMirror; + jQuery('#jform_email_body').html(editor.getValue()); + } + else + { + jQuery('#show-info').show(); + } + + jQuery('#previewTempl').empty(); + jQuery('