$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'));
'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
$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(
'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'];
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;
$this->add(
'text', // field type
'percentage_'.$count, // field name
- 'Percentage', // field label
+ 'Percentage of contribution taken', // field label
false // is required
);
//save formula id
$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'));
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(
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;
$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();
}
}
$('#' + "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: {
} 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);
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();
$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;
$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();
}
$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;
}
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.
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;
+
{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 & 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>
-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;
}
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}