Skip to content

Commit

Permalink
updated shim file and enqueue on the specific form
Browse files Browse the repository at this point in the history
  • Loading branch information
tamw-wnet committed Dec 12, 2024
1 parent d6ca4ec commit 80202a5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Binary file removed assets/js/.ea-donate-form.js.swp
Binary file not shown.
15 changes: 13 additions & 2 deletions assets/js/everyaction_pledge_shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
current_frequency = $(this).val();
}
});
set_required_amount();
}

function set_required_amount() {
Expand All @@ -68,8 +67,19 @@
} else {
$("input[name='OtherAmount']").val(required_donation_amount);
}
$("input[name='OtherAmount']").focus();
}

/* TK; A function to compare the required_donation_amount value
* (or if frequency is 4, required_installment_amount value)
* to each of the visible giving levels and disable any that are
* less than that value.
*/


/* TK: a function to to clear the shopping_cart cookie on successful form donation
*/

let initialize_form_when_ready = function () {
if (!$("input[title='PCodes']").length) {
setTimeout(initialize_form_when_ready, 100);
Expand All @@ -79,11 +89,12 @@
update_pcode_and_premium_and_value_fields();
$('input[name="SelectedFrequency"]').on('change click', function () {
check_frequency();
set_required_amount();
});
}

}

var nvtag_callbacks = nvtag_callbacks || {};
nvtag_callbacks.postRender = nvtag_callbacks.postRender || [];
nvtag_callbacks.postRender.push(initialize_form_when_ready);
nvtag_callbacks.postRender.push(initialize_form_when_ready);
10 changes: 9 additions & 1 deletion wnet-everyaction-wp-css-and-js.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
Plugin Name: WNET EveryAction WP CSS and JS
Description: A container to maintain the custom JS and CSS for embedded EveryAction forms on WNET sites
Version: 2023.03.23
Version: 2024.12.12
Authors: WNET Digital (plugin), MWD (JS and CSS)
*/

Expand All @@ -27,6 +27,14 @@ public function enqueue_scripts() {
wp_register_script( $this->token . '_js' , $this->assets_url . 'js/ea-donate-form.js', array('jquery'), $this->version, true );
wp_enqueue_script( $this->token . '_js' );
wp_enqueue_style( $this->token . '_css', $this->assets_url . 'css/ea-donate-form-theme-styles.css', null, $this->version);

// enqueue the pledge shim on one specific form
if ( is_singular('contribute')) {
global $post;
if ('premium-checkout' == $post->post_name) {
wp_enqueue_script('everyaction_pledge_shim',$this->assets_url . 'js/everyaction_pledge_shim.js', array('jquery','js-cookie'), $this->version, true);
}
}
}


Expand Down

0 comments on commit 80202a5

Please sign in to comment.