From cb59e7c2fba16f5ce5fd2a047de8a604626e1354 Mon Sep 17 00:00:00 2001 From: Manoj K Date: Mon, 3 Nov 2014 18:39:25 +0530 Subject: [PATCH] #29801 - Fixed title encoding bug and made long js in embed as including file. --- CRM/Wci/BAO/Widget.php | 2 +- CRM/Wci/Form/CreateWidget.php | 2 +- extern/wciembed.js | 39 +++++++++++++++++++ templates/CRM/Wci/Form/CreateWidget.tpl | 50 ++----------------------- templates/CRM/Wci/Page/wciwidget.tpl | 4 +- 5 files changed, 45 insertions(+), 52 deletions(-) create mode 100644 extern/wciembed.js diff --git a/CRM/Wci/BAO/Widget.php b/CRM/Wci/BAO/Widget.php index 4c08e5f..3cedbec 100644 --- a/CRM/Wci/BAO/Widget.php +++ b/CRM/Wci/BAO/Widget.php @@ -135,7 +135,7 @@ class CRM_Wci_BAO_Widget extends CRM_Wci_DAO_Widget { $data = array(); while ($dao->fetch()) { - $data["title"] = base64_decode($dao->title); + $data["title"] = $dao->title; $data["logo_image"] = $dao->logo_image; $data["image"] = $dao->image; $data["button_title"] = $dao->button_title; diff --git a/CRM/Wci/Form/CreateWidget.php b/CRM/Wci/Form/CreateWidget.php index d014af1..b746bd8 100644 --- a/CRM/Wci/Form/CreateWidget.php +++ b/CRM/Wci/Form/CreateWidget.php @@ -140,7 +140,7 @@ where w.id=" . $this->_id;*/ CRM_Core_DAO::storeValues($dao, $wid_page[$dao->id]); $this->setDefaults(array( - 'title' => base64_decode($wid_page[$dao->id]['title']))); + 'title' => $wid_page[$dao->id]['title'])); $this->setDefaults(array( 'logo_image' => $wid_page[$dao->id]['logo_image'])); $this->setDefaults(array( diff --git a/extern/wciembed.js b/extern/wciembed.js new file mode 100644 index 0000000..9fb0125 --- /dev/null +++ b/extern/wciembed.js @@ -0,0 +1,39 @@ +// Cleanup functions for the document ready method +if ( document.addEventListener ) { + DOMContentLoaded = function() { + document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + onReady(); + }; +} else if ( document.attachEvent ) { + DOMContentLoaded = function() { + // Make sure body exists, at least, in case IE gets a little overzealous + if ( document.readyState === "complete" ) { + document.detachEvent( "onreadystatechange", DOMContentLoaded ); + onReady(); + } + }; +} +if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + setTimeout( onReady, 1 ); +} + +// Mozilla, Opera and webkit support this event +if ( document.addEventListener ) { + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + // A fallback to window.onload, that will always work + window.addEventListener( "load", onReady, false ); + // If IE event model is used +} else if ( document.attachEvent ) { + // ensure firing before onload, + // maybe late but safe also for iframes + document.attachEvent("onreadystatechange", DOMContentLoaded); + + // A fallback to window.onload, that will always work + window.attachEvent( "onload", onReady ); +} + +function onReady( ) { + document.getElementById('widgetwci').innerHTML = wciwidgetcode; +} \ No newline at end of file diff --git a/templates/CRM/Wci/Form/CreateWidget.tpl b/templates/CRM/Wci/Form/CreateWidget.tpl index 8067b71..5737d69 100644 --- a/templates/CRM/Wci/Form/CreateWidget.tpl +++ b/templates/CRM/Wci/Form/CreateWidget.tpl @@ -28,6 +28,7 @@ $wcidata = $template->fetch('string:' . base64_decode($wid_page[$dao->id]['custom_template'])); } $widget_controller_path = getWciWidgetControllerPath(); + $extension_root_path = getExtensionRootPath(); } {/php} @@ -40,47 +41,7 @@ {literal} {/literal}
@@ -92,13 +53,8 @@ function onReady( ) {
{* {include file="CRM/Wci/Page/wciwidget.tpl"} *} - - +
diff --git a/templates/CRM/Wci/Page/wciwidget.tpl b/templates/CRM/Wci/Page/wciwidget.tpl index 4c3320e..4f61252 100644 --- a/templates/CRM/Wci/Page/wciwidget.tpl +++ b/templates/CRM/Wci/Page/wciwidget.tpl @@ -187,9 +187,7 @@

Get the monthly newsletter

-

email id: - -

+

{if $embed eq 1 } -- 2.25.1