<commit_before><% @title = "Spot.us - Fund Your Donations" %>

<% content_for :head do %>

	<% javascript_tag do %>

	jQuery(document).ready(function(){
		jQuery("form#donation_amounts").submit(function(){
			if(jQuery("#purchase").css("display") != "none") {
				jQuery("#loading_status").fadeIn(50);
				jQuery.post(jQuery(this).attr("action"), jQuery(this).serialize(), function(result){
					jQuery("#loading_status").hide();
					jQuery.facebox(result);
					return false;
				}, "script");
				return false;
			}
		});
		jQuery('#remove_spotus_donation').click(function(){
			jQuery('input#spotus_donation').remove();
			jQuery('#support_spotus').hide();
			getTotalAmounts(true);
			return false;
		});

		jQuery('select.invisible').val('');

		jQuery('a.show_group_selector').toggle(function(){
			jQuery(this).next("select").removeClass("invisible").focus().next("em").removeClass("invisible");        
		},function(){
			jQuery(this).blur().next("select").val('').addClass("invisible").next("em").addClass("invisible");
		});
		
		getTotalAmounts(true);
		
		jQuery('input.line_item').change(function(){
			getTotalAmounts(true);
		});
		jQuery('input#spotus_donation').change(function(){
			getTotalAmounts(false);
		});		
	});
	<% end %>
<% end %>

<% if @donations && @donations.any?(&:errors) %>
	<% content_for :error do %>
		<%= error_messages_for :donations, :object => @donations %>
	<% end %>
<% end %>
<%= render :partial => "layouts/common_questions" %>
<div id="donation_amounts">
	<h2 class="heading"> Almost done! One more step:</h2>
	
	<h3 class="heading">You can contribute more by adjusting the amounts below.</h3>
    
    <% if unpaid_donations.any? %>
		<h3 class="heading">Fund Your Donations</h3>
    <% end %>   
    <% form_tag myspot_donations_amounts_path, :method => :put, :class=>"clearfix", :id => "donation_amounts" do %>
       <ul class="unpaid_donations">
         <% unpaid_donations.each do |donation| %>
            <% content_tag_for :li, donation, :class => 'unpaid clearfix' do %>
               <%= link_to image_tag(donation.pitch.featured_image.url(:thumb)), donation.pitch %>
               <div class="donation_item">
                  <h4 class="display_inline">PITCH: <%= link_to donation.pitch.headline, donation.pitch %></h4><br/>
                  <% if Group.all.any? %>
                      <p>
                        <a href="#group_selection" class="show_group_selector">Donate on behalf of group?</a>
                        <%= select_tag "donation_amounts[#{donation.id}][group_id]", '<option value=''>select a group</option>' +  options_from_collection_for_select(Group.all, :id, :name), :class => "invisible" %>
                        <em class="invisible quiet small">optional</em>
                      </p>
                  <% end %>
                  <p>
                     <%= truncate_words(donation.pitch.short_description,10) %>
                     <%= link_to 'Read More &raquo;', donation.pitch %>
                  </p>
               </div>
               <div class="donater">
                   $ <%= text_field_tag "donation_amounts[#{donation.id}][amount]", number_to_currency(donation.amount, :delimiter => '', :unit => ''), :size => 6, :id => "donation_amounts_#{donation.id}_amount", :style => "text-align:right;", :donation_id => donation.id, :class => "line_item" %>
                  <div class="action">
                     <%= link_to "Remove", myspot_donation_url(donation), :method => :delete, :confirm => "Are you sure you'd like to remove this donation of #{number_to_currency(donation.amount)}?" %>
                  </div> 
               </div>
            <% end %>
         <% end %>
         </ul>
        <% if unpaid_credits.any? %>
          <h3 class="heading">Apply Credits</h3>
          <ul class="unpaid_donations">
              <% unpaid_credits.each do |credit_pitch| %>
                <% content_tag_for :li, credit_pitch, :class => 'unpaid clearfix' do %>
                    <%= link_to image_tag(credit_pitch.pitch.featured_image.url(:thumb)), credit_pitch.pitch %>
                    <div class="donation_item">
                       <h4 class="display_inline">PITCH:
                           <%= link_to credit_pitch.pitch.headline, credit_pitch.pitch %>
                        </h4><br/>
                        <p>
                           <%= truncate_words(credit_pitch.pitch.short_description, 10) %>
                           <%= link_to 'Read More &raquo;', credit_pitch.pitch %>
                        </p>
                    </div>
                    <div class="donater">
                        $ <%= text_field_tag "credit_pitch_amounts[#{credit_pitch.id}][amount]", number_to_currency(credit_pitch.amount, :delimiter => '', :unit => ''), :size => 6, :id => "credit_pitch_amounts_#{credit_pitch.id}_amount", :style => "text-align:right;", :class => "line_item" %>
                        <div class="action">
                           <%= link_to "Remove", myspot_donation_path(credit_pitch), :method => :delete, :confirm => "Are you sure you'd like to remove this credit of #{number_to_currency(credit_pitch.amount)}?" %>
                        </div>
                    </div>
               <% end %> 
            <% end %>
            </ul>
         <% end %>
         <h3 class="heading">Extra</h3>
         <ul>
            <li id="support_spotus" class="donation clearfix">
               <div class="donation_extra">
                  <h3>Support Spot.Us</h3>
				  <p>
					We are a nonprofit and this money goes to support our overhead such as credit card fees to process your contribution.
                  </p>
               </div>
               <div class="donater">
                  $ <%= text_field_tag "spotus_donation_amount", number_to_currency(spotus_donation.amount, :unit => ''), :size => 5, :id => "spotus_donation", :style => "text-align:right;" %>
                  <div class="action">
                     <%= link_to "Remove", '#', :id => 'remove_spotus_donation' %>
                  </div>
               </div>
            </li>
         </ul>
		<% if current_user.total_credits > 0 %>
         <ul>
            <li id="support_spotus" class="donation clearfix">
               <div class="donation_extra">
                  <h3>Your available credits</h3>
               </div>
               <div class="donater_credit">
				 - $<span id="spotus_credit_amount"><%=number_to_currency(current_user.total_credits, :unit => '')%></span>
               </div>
            </li>
         </ul>
		<%end%>
		
		<h3 class="heading"></h3>
         <ul style="background:#eee;border:1px solid #ccc;width:100%;margin-left:0px;margin-bottom:10px;">
            <li id="support_spotus" class="donation clearfix" style="font-weight:bold;padding:10px;margin:0px;">
               <div class="donation_owe">
                  <h3>Total:</h3>
               </div>
               <div class="donater_owe" style="padding-right:5px;">
                  <span id="spotus_total_amount">-</span>
               </div>
            </li>
         </ul>
      <div class="float-right"><commit_msg>disable the spotus donation and making it mandatory.<commit_after><% @title = "Spot.us - Fund Your Donations" %>

<% content_for :head do %>

	<% javascript_tag do %>

	jQuery(document).ready(function(){
		jQuery("form#donation_amounts").submit(function(){
			if(jQuery("#purchase").css("display") != "none") {
				jQuery("#loading_status").fadeIn(50);
				jQuery.post(jQuery(this).attr("action"), jQuery(this).serialize(), function(result){
					jQuery("#loading_status").hide();
					jQuery.facebox(result);
					return false;
				}, "script");
				return false;
			}
		});
		jQuery('#remove_spotus_donation').click(function(){
			jQuery('input#spotus_donation').remove();
			jQuery('#support_spotus').hide();
			getTotalAmounts(true);
			return false;
		});

		jQuery('select.invisible').val('');

		jQuery('a.show_group_selector').toggle(function(){
			jQuery(this).next("select").removeClass("invisible").focus().next("em").removeClass("invisible");        
		},function(){
			jQuery(this).blur().next("select").val('').addClass("invisible").next("em").addClass("invisible");
		});
		
		getTotalAmounts(true);
		
		jQuery('input.line_item').change(function(){
			getTotalAmounts(true);
		});
		jQuery('input#spotus_donation').change(function(){
			getTotalAmounts(false);
		});		
	});
	<% end %>
<% end %>

<% if @donations && @donations.any?(&:errors) %>
	<% content_for :error do %>
		<%= error_messages_for :donations, :object => @donations %>
	<% end %>
<% end %>
<%= render :partial => "layouts/common_questions" %>
<div id="donation_amounts">
	<h2 class="heading"> Almost done! One more step:</h2>
	
	<h3 class="heading">You can contribute more by adjusting the amounts below.</h3>
    
    <% if unpaid_donations.any? %>
		<h3 class="heading">Fund Your Donations</h3>
    <% end %>   
    <% form_tag myspot_donations_amounts_path, :method => :put, :class=>"clearfix", :id => "donation_amounts" do %>
       <ul class="unpaid_donations">
         <% unpaid_donations.each do |donation| %>
            <% content_tag_for :li, donation, :class => 'unpaid clearfix' do %>
               <%= link_to image_tag(donation.pitch.featured_image.url(:thumb)), donation.pitch %>
               <div class="donation_item">
                  <h4 class="display_inline">PITCH: <%= link_to donation.pitch.headline, donation.pitch %></h4><br/>
                  <% if Group.all.any? %>
                      <p>
                        <a href="#group_selection" class="show_group_selector">Donate on behalf of group?</a>
                        <%= select_tag "donation_amounts[#{donation.id}][group_id]", '<option value=''>select a group</option>' +  options_from_collection_for_select(Group.all, :id, :name), :class => "invisible" %>
                        <em class="invisible quiet small">optional</em>
                      </p>
                  <% end %>
                  <p>
                     <%= truncate_words(donation.pitch.short_description,10) %>
                     <%= link_to 'Read More &raquo;', donation.pitch %>
                  </p>
               </div>
               <div class="donater">
                   $ <%= text_field_tag "donation_amounts[#{donation.id}][amount]", number_to_currency(donation.amount, :delimiter => '', :unit => ''), :size => 6, :id => "donation_amounts_#{donation.id}_amount", :style => "text-align:right;", :donation_id => donation.id, :class => "line_item" %>
                  <div class="action">
                     <%= link_to "Remove", myspot_donation_url(donation), :method => :delete, :confirm => "Are you sure you'd like to remove this donation of #{number_to_currency(donation.amount)}?" %>
                  </div> 
               </div>
            <% end %>
         <% end %>
         </ul>
        <% if unpaid_credits.any? %>
          <h3 class="heading">Apply Credits</h3>
          <ul class="unpaid_donations">
              <% unpaid_credits.each do |credit_pitch| %>
                <% content_tag_for :li, credit_pitch, :class => 'unpaid clearfix' do %>
                    <%= link_to image_tag(credit_pitch.pitch.featured_image.url(:thumb)), credit_pitch.pitch %>
                    <div class="donation_item">
                       <h4 class="display_inline">PITCH:
                           <%= link_to credit_pitch.pitch.headline, credit_pitch.pitch %>
                        </h4><br/>
                        <p>
                           <%= truncate_words(credit_pitch.pitch.short_description, 10) %>
                           <%= link_to 'Read More &raquo;', credit_pitch.pitch %>
                        </p>
                    </div>
                    <div class="donater">
                        $ <%= text_field_tag "credit_pitch_amounts[#{credit_pitch.id}][amount]", number_to_currency(credit_pitch.amount, :delimiter => '', :unit => ''), :size => 6, :id => "credit_pitch_amounts_#{credit_pitch.id}_amount", :style => "text-align:right;", :class => "line_item" %>
                        <div class="action">
                           <%= link_to "Remove", myspot_donation_path(credit_pitch), :method => :delete, :confirm => "Are you sure you'd like to remove this credit of #{number_to_currency(credit_pitch.amount)}?" %>
                        </div>
                    </div>
               <% end %> 
            <% end %>
            </ul>
         <% end %>
         <h3 class="heading">Extra</h3>
         <ul>
            <li id="support_spotus" class="donation clearfix">
               <div class="donation_extra">
                  <h3>Support Spot.Us</h3>
				  <p>
					We are a nonprofit and this money goes to support our overhead such as credit card fees to process your contribution.
                  </p>
               </div>
               <div class="donater">
                  $ <%= text_field_tag "spotus_donation_amount", number_to_currency(spotus_donation.amount, :unit => ''), :size => 5, :id => "spotus_donation", :style => "text-align:right;", :disabled=>true %>
                  <div class="action">
                     <%#= link_to "Remove", '#', :id => 'remove_spotus_donation' %>
                  </div>
               </div>
            </li>
         </ul>
		<% if current_user.total_credits > 0 %>
         <ul>
            <li id="support_spotus" class="donation clearfix">
               <div class="donation_extra">
                  <h3>Your available credits</h3>
               </div>
               <div class="donater_credit">
				 - $<span id="spotus_credit_amount"><%=number_to_currency(current_user.total_credits, :unit => '')%></span>
               </div>
            </li>
         </ul>
		<%end%>
		
		<h3 class="heading"></h3>
         <ul style="background:#eee;border:1px solid #ccc;width:100%;margin-left:0px;margin-bottom:10px;">
            <li id="support_spotus" class="donation clearfix" style="font-weight:bold;padding:10px;margin:0px;">
               <div class="donation_owe">
                  <h3>Total:</h3>
               </div>
               <div class="donater_owe" style="padding-right:5px;">
                  <span id="spotus_total_amount">-</span>
               </div>
            </li>
         </ul>
      <div class="float-right">
{'fraction_non_alphanumeric': 0.16593643507893455, 'fraction_numerical': 0.005980944432853467, 'mean_word_length': 2.205528310298707, 'pattern_counts': {'":': 0, '<': 263, '<?xml version=': 0, '>': 328, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2266089', 'n_tokens_mistral': 4765, 'n_tokens_neox': 4173, 'n_words': 761}