From fbe9a7d4ff39c94136dd11563d9864fe5286dc15 Mon Sep 17 00:00:00 2001 From: Jagadedes Date: Tue, 11 Nov 2014 17:39:26 +0530 Subject: [PATCH] fixed beta 1 bugs, 31062, 31063, 31101, 31067, 31065 --- CRM/Wci/Form/CreateWidget.php | 15 +++----- CRM/Wci/Form/ProgressBar.php | 4 +-- CRM/Wci/Form/WCISettings.php | 5 +-- CRM/Wci/Page/ProgressBarList.php | 5 +-- addmore.js | 1 + createwidget.js | 4 +++ extern/embed.php | 47 ++++++++++++++++++++++--- sql/install.sql | 2 +- sql/uninstall.sql | 4 ++- templates/CRM/Wci/Form/CreateWidget.tpl | 32 ++++++++--------- templates/CRM/Wci/Page/wciwidget.tpl | 36 ++++++++++++------- 11 files changed, 105 insertions(+), 50 deletions(-) diff --git a/CRM/Wci/Form/CreateWidget.php b/CRM/Wci/Form/CreateWidget.php index 5517583..58fa128 100644 --- a/CRM/Wci/Form/CreateWidget.php +++ b/CRM/Wci/Form/CreateWidget.php @@ -109,7 +109,7 @@ class CRM_Wci_Form_CreateWidget extends CRM_Core_Form { $this->add('select', 'progress_bar', ts('Progress bar'), $this->getProgressBars()); $this->addWysiwyg('description', ts('Description'), ''); $this->add('select', 'email_signup_group_id', ts('Newsletter signup'), $this->getGroupOptions()); - $this->add('select', 'size_variant', ts('Size variant'), $this->getSizeOptions()); + $this->add('select', 'size_variant', ts('Size variant
Fixed width. Height depends on what contents selected.'), $this->getSizeOptions()); // $fieldset = $this->addElement('fieldset')->setLabel('Advanced Settings'); $this->add('checkbox', 'hide_title', ts('Hide Title')); $this->add('checkbox', 'hide_border', ts('Hide border')); @@ -138,11 +138,9 @@ class CRM_Wci_Form_CreateWidget extends CRM_Core_Form { 'name' => ts('Save & Preview'), ), )); - // export form elements $this->assign('elementNames', $this->getRenderableElementNames()); - - if (isset($this->_id)) { + if (isset($this->_id)) { /** Updating existing widget*/ /*$query = "SELECT pb.id as pbid, w.* FROM civicrm_wci_widget w INNER JOIN civicrm_wci_progress_bar pb on pb.id = w.progress_bar_id @@ -154,10 +152,8 @@ where w.id=" . $this->_id;*/ $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_Widget'); while ($dao->fetch()) { - $wid_page[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $wid_page[$dao->id]); - $this->setDefaults(array( 'title' => $wid_page[$dao->id]['title'])); $this->setDefaults(array( @@ -168,7 +164,6 @@ where w.id=" . $this->_id;*/ 'button_link_to' => $wid_page[$dao->id]['button_link_to'])); $this->setDefaults(array( 'button_title' => $wid_page[$dao->id]['button_title'])); - $this->setDefaults(array( 'progress_bar' => $dao->progress_bar_id/*$dao->pbid*/)); $description = $wid_page[$dao->id]['description']; @@ -388,9 +383,9 @@ where w.id=" . $this->_id;*/ function getSizeOptions() { $options = array( - 'thin' => ts('Thin'), - 'normal' => ts('Normal'), - 'wide' => ts('Wide'), + 'thin' => ts('Thin (150px)'), + 'normal' => ts('Normal (200px)'), + 'wide' => ts('Wide (250px)'), ); return $options; diff --git a/CRM/Wci/Form/ProgressBar.php b/CRM/Wci/Form/ProgressBar.php index d6f58e1..0be406e 100644 --- a/CRM/Wci/Form/ProgressBar.php +++ b/CRM/Wci/Form/ProgressBar.php @@ -56,7 +56,7 @@ class CRM_Wci_Form_ProgressBar extends CRM_Core_Form { $this->add( 'text', // field type 'percentage_'.$count, // field name - 'Percentage', // field label + 'Percentage of contribution taken', // field label false // is required ); //save formula id @@ -84,7 +84,7 @@ class CRM_Wci_Form_ProgressBar extends CRM_Core_Form { $this->add( 'text', // field type 'percentage_1', // field name - 'Percentage', // field label + 'Percentage of contribution taken', // field label true // is required ); CRM_Utils_System::setTitle(ts('Create Progress Bar')); diff --git a/CRM/Wci/Form/WCISettings.php b/CRM/Wci/Form/WCISettings.php index a18348f..5979a75 100644 --- a/CRM/Wci/Form/WCISettings.php +++ b/CRM/Wci/Form/WCISettings.php @@ -19,13 +19,14 @@ class CRM_Wci_Form_WCISettings extends CRM_Core_Form { true // is required );*/ - $this->add( + /*$this->add( 'select', // field type 'default_widget', // field name 'Default widget', // field label $this->getWidgets(), // list of options false // is required - ); + );*/ + $this->add('text', 'default_profile', ts('Default profile'),true)->setSize(45); $this->addButtons(array( array( diff --git a/CRM/Wci/Page/ProgressBarList.php b/CRM/Wci/Page/ProgressBarList.php index 02f8e1c..f0a220c 100644 --- a/CRM/Wci/Page/ProgressBarList.php +++ b/CRM/Wci/Page/ProgressBarList.php @@ -27,6 +27,7 @@ class CRM_Wci_Page_ProgressBarList extends CRM_Core_Page { return $controller->run(); } elseif ($action & CRM_Core_Action::DELETE) { + $errorScope = CRM_Core_TemporaryErrorScope::useException(); try { $transaction = new CRM_Core_Transaction(); $sql = "DELETE FROM civicrm_wci_progress_bar_formula where progress_bar_id = " . $id; @@ -37,8 +38,8 @@ class CRM_Wci_Page_ProgressBarList extends CRM_Core_Page { $transaction->commit(); } catch (Exception $e) { - //TODO - print_r($e->getMessage()); + $errmgs = $e->getMessage() . ts('. Check whether progressbar is used by any widget or not'); + CRM_Core_Session::setStatus($errmgs, '', 'error'); $transaction->rollback(); } } diff --git a/addmore.js b/addmore.js index 0875b01..9754d14 100644 --- a/addmore.js +++ b/addmore.js @@ -9,6 +9,7 @@ cj(function ( $ ) { $('#' + "contribution_page_" + i).parent().parent().attr("id", "crm-section-con-" + i); $('#' + "percentage_" + i).parent().parent().attr("id", 'crm-section-per-' + i); } + $('#percentage_1').after(''); }); $("#ProgressBar").validate({ rules: { diff --git a/createwidget.js b/createwidget.js index b5a1907..9af6254 100644 --- a/createwidget.js +++ b/createwidget.js @@ -12,6 +12,10 @@ cj(function ( $ ) { } else { $('#embd_code').parents('.crm-section').hide(); } + + $('#image').after(''); + $('#logo_image').after(''); + } $(document).ready(setState) $('#override').click(setState); diff --git a/extern/embed.php b/extern/embed.php index 5b0a2dd..0260f4d 100644 --- a/extern/embed.php +++ b/extern/embed.php @@ -43,6 +43,46 @@ require_once 'CRM/Core/Config.php'; require_once 'CRM/Contribute/BAO/Widget.php'; require_once 'CRM/Utils/Request.php'; +$wciembed_js = '// 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; +}'; + $config = CRM_Core_Config::singleton(); $template = CRM_Core_Smarty::singleton(); @@ -55,7 +95,7 @@ if(empty($widgetId)) { $widgetId = civicrm_api3('setting', 'getValue', array('group' => 'Wci Preference', 'name' => 'default_wci_widget')); } } -$embed = CRM_Utils_Request::retrieve('embed', 'Positive', CRM_Core_DAO::$_nullObject); +$preview = CRM_Utils_Request::retrieve('preview', 'Positive', CRM_Core_DAO::$_nullObject); if (isset($format)) { $jsonvar .= $cpageId; @@ -66,7 +106,7 @@ if (isset($format)) { $template->assign('wciform', $data); $template->assign('cpageId', $data['button_link_to']); - $template->assign('embed', $embed); + $template->assign('preview', $preview); if ($data["override"] == '0') { $template->template_dir[] = getWciWidgetTemplatePath(); @@ -76,8 +116,7 @@ if (isset($format)) { } $output = 'var wciwidgetcode = ' . json_encode($wcidata) . ';'; - $wciembed = file_get_contents('wciembed.js',FILE_USE_INCLUDE_PATH); - $output = $output . $wciembed; + $output = $output . $wciembed_js; echo $output; } diff --git a/sql/install.sql b/sql/install.sql index 0b58365..3e149ec 100644 --- a/sql/install.sql +++ b/sql/install.sql @@ -51,7 +51,7 @@ CREATE TABLE IF NOT EXISTS civicrm_wci_widget ( PRIMARY KEY (`id`), UNIQUE KEY `unique_wci_title` (`title`), - CONSTRAINT FK_civicrm_wci_widget_progress_bar_id FOREIGN KEY (`progress_bar_id`) REFERENCES `civicrm_wci_progress_bar`(`id`) ON DELETE SET NULL + CONSTRAINT FK_civicrm_wci_widget_progress_bar_id FOREIGN KEY (`progress_bar_id`) REFERENCES `civicrm_wci_progress_bar`(`id`) ON DELETE RESTRICT ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; -- WCI embed code. diff --git a/sql/uninstall.sql b/sql/uninstall.sql index f295770..432207f 100644 --- a/sql/uninstall.sql +++ b/sql/uninstall.sql @@ -1,3 +1,5 @@ DROP TABLE IF EXISTS civicrm_wci_widget; DROP TABLE IF EXISTS civicrm_wci_progress_bar_formula; -DROP TABLE IF EXISTS civicrm_wci_progress_bar; \ No newline at end of file +DROP TABLE IF EXISTS civicrm_wci_progress_bar; +DROP TABLE IF EXISTS civicrm_wci_embed_code; + diff --git a/templates/CRM/Wci/Form/CreateWidget.tpl b/templates/CRM/Wci/Form/CreateWidget.tpl index 0041224..24a401c 100644 --- a/templates/CRM/Wci/Form/CreateWidget.tpl +++ b/templates/CRM/Wci/Form/CreateWidget.tpl @@ -4,16 +4,6 @@ {include file="CRM/common/formButtons.tpl" location="top"} - {* FIELD EXAMPLE: OPTION 1 (AUTOMATIC LAYOUT) *} - - {foreach from=$elementNames item=elementName} -
-
{$form.$elementName.label}
-
{$form.$elementName.html}
-
-
- {/foreach} - {if $form.title.value != ""} {php} if(isset($_REQUEST['id'])) { @@ -33,15 +23,14 @@ {/php}
-
- - Preview Widget - +
Widget Preview
+
+
Click Save & Preview to save any changes to your settings, and preview the widget again on this page.
- +
-
+
+
{/if} + {* FIELD EXAMPLE: OPTION 1 (AUTOMATIC LAYOUT) *} + + {foreach from=$elementNames item=elementName} +
+
{$form.$elementName.label}
+
{$form.$elementName.html}
+
+
+ {/foreach} + {* FIELD EXAMPLE: OPTION 2 (MANUAL LAYOUT)
diff --git a/templates/CRM/Wci/Page/wciwidget.tpl b/templates/CRM/Wci/Page/wciwidget.tpl index 9bb909d..50c569d 100644 --- a/templates/CRM/Wci/Page/wciwidget.tpl +++ b/templates/CRM/Wci/Page/wciwidget.tpl @@ -8,14 +8,18 @@ -webkit-border-radius: 12px; -khtml-border-radius: 12px; border-radius: 12px; - {/literal}{if (0 == $wciform.hide_border)}{literal} - border: 4px solid {/literal}{$wciform.color_border}{literal}; - {if (1 == $wciform.hide_border)} - border: None; - {/literal}{/if}{literal} + } + .crm-wci-widget-border { + border: 4px solid {/literal}{$wciform.color_border}{literal}; background-color: {/literal}{$wciform.color_widget_bg}{literal}; /* background color */ } + .crm-wci-widget hr { + text-align:center; + display: block; height: 1px; + border: 0; border-top: 1px solid {/literal}{$wciform.color_border}{literal}; + margin: 1em 0; padding: 0; + } .crm-wci-widget.thin { width: 150px; } @@ -28,7 +32,7 @@ width: 250px; } - h5 { + .crm-wci-widget h5 { font-size:14px; padding:3px; margin: 0px; @@ -164,14 +168,19 @@ {literal} {/literal} + +{if (1 == $wciform.hide_border)}
- {if $wciform.title && (false == $wciform.hide_title)} -
+{else} +
+{/if} {if $wciform.logo_image} {/if} + {if $wciform.title && (false == $wciform.hide_title)} +
{$wciform.title}
{/if} @@ -197,13 +206,16 @@
- {if $wciform.button_title} + {if $wciform.button_title && $cpageId} + {if $wciform.email_signup_group_id} +
+ {/if} {/if} {if $wciform.email_signup_group_id} - {if $embed eq 1 } + {if $preview eq 0 }
{/if}

@@ -213,7 +225,7 @@

- {if $embed eq 1 } + {if $preview eq 0 } {else} @@ -224,7 +236,7 @@

- {if $embed eq 1 } + {if $preview eq 0 } {/if} {/if} -- 2.25.1