From 2bf0718db5815aff191e9a836aaa11db7d77f7e9 Mon Sep 17 00:00:00 2001 From: Jagadedes Date: Mon, 22 Sep 2014 17:32:25 +0530 Subject: [PATCH] #29750 progress bar initial page created. --- CRM/Wci/Form/ProgressBar.php | 127 +++++++++++++++++++++++++++++++++++ addmore.js | 71 ++++++++++++++++++++ 2 files changed, 198 insertions(+) create mode 100644 CRM/Wci/Form/ProgressBar.php create mode 100644 addmore.js diff --git a/CRM/Wci/Form/ProgressBar.php b/CRM/Wci/Form/ProgressBar.php new file mode 100644 index 0000000..7a01085 --- /dev/null +++ b/CRM/Wci/Form/ProgressBar.php @@ -0,0 +1,127 @@ +addScriptFile('org.civicrm.wci', 'addmore.js'); + parent::preProcess(); + } + function buildQuickForm() { + $this->add( + 'text', // field type + 'progressbar_name', // field name + 'Name', // field label + true // is required + ); + $this->add( + 'text', // field type + 'starting_amount', // field name + 'Starting amount', // field label + true // is required + ); + $this->add( + 'text', // field type + 'goal_amount', // field name + 'Goal amount', // field label + true // is required + ); + $this->add( + 'select', // field type + 'contribution_page_1', // field name + 'Contribution page', // field label + getContributionPageOptions(), // list of options + true // is required + ); + $this->add( + 'text', // field type + 'percentage_1', // field name + 'percentage', // field label + true // is required + ); + //$this->getElement('percentage')->setAttribute("id", "percentage"); + + $this->addElement('link', 'addmore_link',' ', 'addmore', 'Add more'); +// $this->addElement('link', 'remove_link',' ', 'remove', 'Remove'); + + $this->addElement('hidden', 'contrib_count', '1'); + //$this->getElement('contrib_count')->setAttribute("id", "count"); + + $this->addButtons(array( + array( + 'type' => 'text', + 'name' => ts('Add More'), + 'isDefault' => FALSE, + ), + array( + 'type' => 'submit', + 'name' => ts('Save'), + 'isDefault' => TRUE, + ), + )); + + // export form elements + $this->assign('elementNames', $this->getRenderableElementNames()); + + parent::buildQuickForm(); + } + + function postProcess() { + echo "post pro"; + $values = $this->exportValues(); + $options = $this->getColorOptions(); +/* CRM_Core_Session::setStatus(ts('You picked color "%1"', array( + 1 => $options[$values['favorite_color']] + )));*/ + parent::postProcess(); + } + +/* + function getColorOptions() { + $options = array( + '' => ts('- select -'), + '#f00' => ts('Red'), + '#0f0' => ts('Green'), + '#00f' => ts('Blue'), + '#f0f' => ts('Purple'), + ); + foreach (array('1','2','3','4','5','6','7','8','9','a','b','c','d','e') as $f) { + $options["#{$f}{$f}{$f}"] = ts('Grey (%1)', array(1 => $f)); + } + return $options; + }*/ + + /** + * Get the fields/elements defined in this form. + * + * @return array (string) + */ + function getRenderableElementNames() { + // The _elements list includes some items which should not be + // auto-rendered in the loop -- such as "qfKey" and "buttons". These + // items don't have labels. We'll identify renderable by filtering on + // the 'label'. + $elementNames = array(); + foreach ($this->_elements as $element) { + $label = $element->getLabel(); + if (!empty($label)) { + $elementNames[] = $element->getName(); + } + } + return $elementNames; + } +} + +function wci__civicrm_buildForm( $formName, &$form ) +{ +echo "hi
"; + //CRM_Core_Resources::singleton()->addScriptFile('wci', 'addmore.js'); + CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.wci', 'addmore.js'); +} diff --git a/addmore.js b/addmore.js new file mode 100644 index 0000000..9d25e16 --- /dev/null +++ b/addmore.js @@ -0,0 +1,71 @@ +// Updated to wait until the document is loaded. addmore_link + +jQuery(document).ready(function () { +// var text = jQuery('h1').text(); +// alert(text); + +}); + +cj(function ( $ ) { + +// var text = jQuery('h1').text(); +// alert(text); + + $('#addmore_link').on('click', function( e ) { + e.preventDefault(); +// $('#addmore_link').click(function () { + var count = parseInt($('input[name=contrib_count]').val()); + count++; + + //$('#myDiv').append('
'); + + //$('#myDiv').append(''); +// var contr_name = "contribution_page_" + count.toString(); + //$('input[name=percentage_1]').parent('div').parent('div').parent('div').append(''); +// $('#crm-container').append(''); + + var c_page = $('select[name=contribution_page_1]').clone().attr('id', 'choices_' + $(this).index()); + c_page.attr("id", "contribution_page_" + count); + c_page.attr("name", "contribution_page_" + count); + //.insertAfter("select[name=contribution_page_1]"); + + + $('input[name=percentage_1]').parent().parent().append("
") + $('input[name=percentage_1]').parent().parent().append(c_page); +// $('input[name=percentage_1]').parent('div').append('
'); +// $('input[name=contribution_page_' + count + ']').text($('input[name=contribution_page_1]').text()); + + $('input[name=percentage_1]').parent().parent().append(' Remove'); + + $('input[name=contrib_count]').val(count); + alert(count); + //alert(contr_sel); + //alert($('input[name=contrib_count]').val()); + //alert($('select[name=contribution_page]').val()); + //alert($("select[name=contribution_page] option:selected").text()); + //alert($("#count").val()); + //$('select[name=contribution_page]'). + + + }); + + $('#remove_link').on('click', function( e ) { + e.preventDefault(); + alert("hi"); + }) +/* + $(function() { + var scntDiv = $('#p_scents'); + var i = $('#p_scents p').size() + 1; + + $('#addmore_link').live('click', function() { + $('

Remove

').appendTo(scntDiv); + i++; + return false; + }); + */ + +}); -- 2.25.1