fixed beta 1 bugs, 31062, 31063, 31101, 31067, 31065
[com.zyxware.civiwci.git] / addmore.js
index 870c18376eab07cf2d733908744a6422972464cc..9754d14dee9992cbc1e6ac206c63f5762063fcc2 100644 (file)
@@ -1,7 +1,16 @@
 // Updated to wait until the document is loaded. addmore_link
 
 cj(function ( $ ) { 
-
+  $(document).ready(function(){
+    var count = parseInt($('input[name=contrib_count]').val());
+    for ( var i = 2; i <= count; i++ ) {
+      $('#' + "contribution_page_" + i).after(
+      '<a id=\"remove_link\" class=\"form-link\" href=\"remove\" name=\"remove_link-' + i + '\"> Remove</a>');
+      $('#' + "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: {
       starting_amount: {
@@ -35,14 +44,14 @@ cj(function ( $ ) {
     c_page_sel.attr("name", "contribution_page_" + count);
 
     var id_section = "crm-section-con-" + count;
-    var sect_tag = "<div class=\"crm-section\" id=" + id_section + "> <div class=\"label\"><label>Contribution Page</label>";
+    var sect_tag = "<div class=\"crm-section\" id=" + id_section + "> <hr width='50%' size='1'> <div class=\"label\"><label>Contribution Page</label>";
     $('#addmore_link').parent().parent().before(sect_tag);
 
     var id_content = "content_con-" + count;
     $('#' + id_section).append("<div class=\"content\" id="+ id_content + ">");
     $('#' + id_content).append(c_page_sel);
     $('#' + id_content).append('<a id=\"remove_link\" class=\"form-link\" href=\"remove\" name=\"remove_link-' + count + '\"> Remove</a>');
-    $('#' + id_section).append("</div");
+    $('#' + id_section).append("</div>");
 
     id_section = "crm-section-per-" + count;
     sect_tag = "<div class=\"crm-section\" id=" + id_section + "> <div class=\"label\"><label>Percentage</label>";
@@ -67,17 +76,17 @@ cj(function ( $ ) {
     
   });
 
-  $('#remove_link').live('click', function( e ) {
+  $(document).on('click', '#remove_link', function( e ) {
     e.preventDefault();
     
     var rem_name = e.target.name;
     //assuming that - is the delimiter. second string will be the count
     var rem_name_ar = rem_name.split('-');
     var contri_page = "\"#percentage_" + rem_name_ar[1] + "\"";
-
     $('#crm-section-con-'+ rem_name_ar[1] +'').remove();
     $('#crm-section-per-'+ rem_name_ar[1] +'').remove();
-
+    var count = parseInt($('input[name=contrib_count]').val());
+    count--;
+    $('input[name=contrib_count]').val(count);
   });
 });