From d839d441878640bda2d114dc279a9b82558d7d97 Mon Sep 17 00:00:00 2001 From: Coleman Watts <coleman@civicrm.org> Date: Mon, 24 Mar 2014 12:33:19 -0400 Subject: [PATCH] Mailing popups - JS cleanup --- CRM/Mailing/BAO/Mailing.php | 12 ++++-------- js/Common.js | 8 -------- templates/CRM/Activity/Form/ActivityView.tpl | 4 ++-- templates/CRM/Mailing/Page/Report.tpl | 4 ++-- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php index 026750bedb..50303221ee 100644 --- a/CRM/Mailing/BAO/Mailing.php +++ b/CRM/Mailing/BAO/Mailing.php @@ -2566,30 +2566,26 @@ SELECT $mailing.id as mailing_id $text = CRM_Utils_Request::retrieve('text', 'Boolean', $form); if ($text) { - echo "<pre>{$textHeader}</br>{$report['mailing']['body_text']}</br>{$textFooter}</pre>"; - CRM_Utils_System::civiExit(); + CRM_Core_Page_AJAX::returnJsonResponse("<pre>{$textHeader}</br>{$report['mailing']['body_text']}</br>{$textFooter}</pre>"); } if (!$isSMS) { $html = CRM_Utils_Request::retrieve('html', 'Boolean', $form); if ($html) { $output = $htmlHeader . $report['mailing']['body_html'] . $htmlFooter ; - echo str_replace( "\n", '<br />', $output ); - CRM_Utils_System::civiExit(); + CRM_Core_Page_AJAX::returnJsonResponse(str_replace("\n", '<br />', $output)); } } if (!empty($report['mailing']['body_text'])) { $url = CRM_Utils_System::url('civicrm/mailing/report', 'reset=1&text=1&mid=' . $form->_mailing_id); - $popup = "javascript:popUp(\"$url\");"; - $form->assign('textViewURL', $popup); + $form->assign('textViewURL', $url); } if (!$isSMS) { if (!empty($report['mailing']['body_html'])) { $url = CRM_Utils_System::url('civicrm/mailing/report', 'reset=1&html=1&mid=' . $form->_mailing_id); - $popup = "javascript:popUp(\"$url\");"; - $form->assign('htmlViewURL', $popup); + $form->assign('htmlViewURL', $url); } } diff --git a/js/Common.js b/js/Common.js index 5b0f4c7692..aaddfd1100 100644 --- a/js/Common.js +++ b/js/Common.js @@ -170,14 +170,6 @@ function submitOnce(obj, formId, procText) { } } } -/** - * @deprecated - */ -function popUp(URL) { - day = new Date(); - id = day.getTime(); - eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=640,height=420,left = 202,top = 184');"); -} /** * Function to show / hide the row in optionFields diff --git a/templates/CRM/Activity/Form/ActivityView.tpl b/templates/CRM/Activity/Form/ActivityView.tpl index 5f9373caff..53a6f7d35c 100644 --- a/templates/CRM/Activity/Form/ActivityView.tpl +++ b/templates/CRM/Activity/Form/ActivityView.tpl @@ -101,7 +101,7 @@ {$mailingReport.mailing.body_text|mb_truncate:30|escape|nl2br} <br /> {if $values.mailingId} - <strong><a href='{$textViewURL}'>» {ts}View complete message{/ts}</a></strong> + <strong><a class="crm-popup" href='{$textViewURL}'>» {ts}View complete message{/ts}</a></strong> {/if} </td> </tr> @@ -114,7 +114,7 @@ {$mailingReport.mailing.body_html|mb_truncate:30|escape|nl2br} <br/> {if $values.mailingId} - <strong><a href='{$htmlViewURL}'>» {ts}View complete message{/ts}</a></strong> + <strong><a class="crm-popup" href='{$htmlViewURL}'>» {ts}View complete message{/ts}</a></strong> {/if} </td> </tr> diff --git a/templates/CRM/Mailing/Page/Report.tpl b/templates/CRM/Mailing/Page/Report.tpl index 521a4b963c..6249dd425f 100644 --- a/templates/CRM/Mailing/Page/Report.tpl +++ b/templates/CRM/Mailing/Page/Report.tpl @@ -169,7 +169,7 @@ <td> {$report.mailing.body_text|mb_truncate:30|escape|nl2br} <br /> - <strong><a href='{$textViewURL}'>» {ts}View complete message{/ts}</a></strong> + <strong><a class="crm-popup" href='{$textViewURL}'>» {ts}View complete message{/ts}</a></strong> </td> </tr> {/if} @@ -180,7 +180,7 @@ <td> {$report.mailing.body_html|mb_truncate:30|escape|nl2br} <br/> - <strong><a href='{$htmlViewURL}'>» {ts}View complete message{/ts}</a></strong> + <strong><a class="crm-popup" href='{$htmlViewURL}'>» {ts}View complete message{/ts}</a></strong> </td> </tr> {/if} -- 2.25.1