fixed beta 1 bugs, 31062, 31063, 31101, 31067, 31065
authorJagadedes <jagadees.pillai@zyxware.com>
Tue, 11 Nov 2014 12:09:26 +0000 (17:39 +0530)
committerJagadedes <jagadees.pillai@zyxware.com>
Tue, 11 Nov 2014 12:09:26 +0000 (17:39 +0530)
CRM/Wci/Form/CreateWidget.php
CRM/Wci/Form/ProgressBar.php
CRM/Wci/Form/WCISettings.php
CRM/Wci/Page/ProgressBarList.php
addmore.js
createwidget.js
extern/embed.php
sql/install.sql
sql/uninstall.sql
templates/CRM/Wci/Form/CreateWidget.tpl
templates/CRM/Wci/Page/wciwidget.tpl

index 5517583b9da639b983764c1077032957eddedac4..58fa128ea95f77a5508d9e0c899e6cbbf77100ca 100644 (file)
@@ -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<br><SMALL>Fixed width. Height depends on what contents selected.</SMALL>'), $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;
index d6f58e11b27f2b2a84fc83ad054f3e78427b0318..0be406e9b9709035ac9794da50ec3cf005acc05f 100644 (file)
@@ -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'));
index a18348f2b4ae2f90c7649d76cf6e4d976ab48bf4..5979a75f9e3f2d028cf25424853ec5038fcc4d2f 100644 (file)
@@ -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(
index 02f8e1cc677b73994b98df751863b0bfd9e3a64e..f0a220c2650889f86679393413979e3e3711dca5 100644 (file)
@@ -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();      
       } 
     }
index 0875b01c05f2ada47cc62deabfe7d77d74f8eff7..9754d14dee9992cbc1e6ac206c63f5762063fcc2 100644 (file)
@@ -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('<label><br><SMALL>Progressbar shows the sum of each percentage of contributions done on each selected contribution page</SMALL></label>');
   });
   $("#ProgressBar").validate({
     rules: {
index b5a1907b9061ab8458d32618ee250f09f33350cb..9af6254ed44e1b81207723aec483c87d5be8e4ac 100644 (file)
@@ -12,6 +12,10 @@ cj(function ( $ ) {
     } else {
       $('#embd_code').parents('.crm-section').hide();
     }
+    
+    $('#image').after('<label><br><SMALL>Select a smaller image than Size variant</SMALL></label>');
+    $('#logo_image').after('<label><br><SMALL>Select smaller image appropriate for logo</SMALL></label>');
+    
   }
   $(document).ready(setState)
   $('#override').click(setState);
index 5b0a2dd4bfba0cab940a84c9566e38de5e4311d0..0260f4d45c8cc0df4fc0a2de3f587c470809ea21 100644 (file)
@@ -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;
 }
 
index 0b5836592baeb9a3e330017f5f185b82f2465ee8..3e149ec01982fc0e4f7a42f33c39039301ed2603 100644 (file)
@@ -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.
index f2957709811f07c9aba1149724f61f49354c1c65..432207f6cb49b87f93aafea40664f37bed48e06a 100644 (file)
@@ -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;
+
index 0041224a860f0c9c65f7454d1d73cd3b0455a945..24a401c88c3f2fb22f59a56f73d4fe8926cef80b 100644 (file)
@@ -4,16 +4,6 @@
   {include file="CRM/common/formButtons.tpl" location="top"}
   </div>
 
-  {* FIELD EXAMPLE: OPTION 1 (AUTOMATIC LAYOUT) *}
-
-  {foreach from=$elementNames item=elementName}
-    <div class="crm-section">
-      <div class="label">{$form.$elementName.label}</div>
-      <div class="content">{$form.$elementName.html}</div>
-      <div class="clear"></div>
-    </div>
-  {/foreach}
-
   {if $form.title.value != ""}
     {php} 
       if(isset($_REQUEST['id'])) {
     {/php}
 
     <div class="crm-section">
-      <fieldset>
-        <legend>
-          Preview Widget
-        </legend>
+      <div class="label">Widget Preview</div>
+        <div class="content">
+
         <div class="col1">
           <div class="description">
             Click <strong>Save &amp; Preview</strong> to save any changes to your settings, and preview the widget again on this page.
           </div>
-          <script type="text/javascript" src="{php}echo $widget_controller_path;{/php}?widgetId={php}echo $wid_id;{/php}&embed=0&referalid=2442"></script></script>
+          <script type="text/javascript" src="{php}echo $widget_controller_path;{/php}?widgetId={php}echo $wid_id;{/php}&preview=1&referalid=2442"></script></script>
   <div id='widgetwci'></div>
         </div>
 <!--        <div class="col2">
             <a href="#" onclick="CreateWidget.widget_code.select(); return false;">ยป Select Code</a>
           </strong>
         </div> -->
-      </fieldset>
+    </div>
+          <div class="clear"></div>
     </div>
   {/if}
   
+  {* FIELD EXAMPLE: OPTION 1 (AUTOMATIC LAYOUT) *}
+
+  {foreach from=$elementNames item=elementName}
+    <div class="crm-section">
+      <div class="label">{$form.$elementName.label}</div>
+      <div class="content">{$form.$elementName.html}</div>
+      <div class="clear"></div>
+    </div>
+  {/foreach}
+  
   {* FIELD EXAMPLE: OPTION 2 (MANUAL LAYOUT)
 
     <div>
index 9bb909d889bfe973d8d5c704a0ddf66ea7a86482..50c569de725002bad9be4416d96a1c08da91b0bd 100644 (file)
@@ -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;
 {literal}
 </style>
 {/literal}
+
+{if (1 == $wciform.hide_border)}
 <div id="crm_wid_{$wciform.widgetId}" class="crm-wci-widget {$wciform.size_variant}">
-  {if $wciform.title && (false == $wciform.hide_title)}
-    <h5 id="crm_wid_{$wciform.widgetId}_title">
+{else}
+<div id="crm_wid_{$wciform.widgetId}" class="crm-wci-widget crm-wci-widget-border {$wciform.size_variant}">
+{/if}
       {if $wciform.logo_image}
         <span class="crm-logo">
           <img src="{$wciform.logo_image}" alt={ts}Logo{/ts}>
         </span>
       {/if}
+  {if $wciform.title && (false == $wciform.hide_title)}
+    <h5 id="crm_wid_{$wciform.widgetId}_title">
       {$wciform.title}
     </h5>
   {/if}
     </div>
     <div id="crm_wid_{$wciform.widgetId}_campaign" class="crm-campaign">
     </div>
-    {if $wciform.button_title}
+    {if $wciform.button_title && $cpageId}
     <div class="crm-wci-button-wrapper" id="crm_wid_{$wciform.widgetId}_button">
         <a href='{crmURL p="civicrm/contribute/transact" q="reset=1&id=$cpageId" h=0 a=1 fe=1}' class="crm-wci-button"><span class="crm-wci-button-inner" id="crm_wid_{$wciform.widgetId}_btn_txt">{$wciform.button_title}</span></a>
     </div>
+        {if $wciform.email_signup_group_id}
+        <hr>
+        {/if}
     {/if}
     {if $wciform.email_signup_group_id}
-      {if $embed eq 1 }
+      {if $preview eq 0 }
         <form action="{$wciform.emailSignupGroupFormURL}" method="post">
       {/if}
         <p id="newsletter_msg">
           <input id="frmEmail" type="text" name="email-Primary" size="18" maxlength="80" placeholder="email address">
         </p>
         <p id="newsletter_submit">
-          {if $embed eq 1 }
+          {if $preview eq 0 }
             <input class ="btnNL" type="submit" name="_qf_Edit_next" value="Subscribe me">
           {else}
             <button class ="btnNL" type="button" name="_qf_Edit_next" value="Subscribe me">Subscribe me</button>
           <input type="hidden" name="group[{$wciform.email_signup_group_id}]" value="1">
           <input name="_qf_default" type="hidden" value="Edit:cancel">
         </div>
-      {if $embed eq 1 }
+      {if $preview eq 0 }
         </form>
       {/if}
     {/if}