-
-
Notifications
You must be signed in to change notification settings - Fork 994
Refactored corporate-member-join.js
#2043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,3 +228,32 @@ document.querySelectorAll('.btn-clipboard').forEach(function (el) { | |
input_el.value = '25'; | ||
}); | ||
})(); | ||
|
||
// Manage amount and membership level fields on corporate membership page | ||
(function () { | ||
const form_el = document.querySelector('.corporate-membership-join-form'); | ||
|
||
if (!form_el) { | ||
return; | ||
} | ||
|
||
const amount_el = form_el.querySelector('#id_amount'); | ||
const level_el = form_el.querySelector('#id_membership_level'); | ||
const levels = [-Infinity, 2000, 5000, 12500, 30000, 100000]; | ||
|
||
amount_el.addEventListener('change', function () { | ||
let value; | ||
|
||
for (let i = 0; i < levels.length; i++) { | ||
if (this.value >= levels[i]) { | ||
value = i; | ||
} | ||
|
||
level_el.value = value || ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The empty string sets the |
||
} | ||
}); | ||
|
||
level_el.addEventListener('change', function () { | ||
amount_el.value = this.value ? levels[Number(this.value)] : ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The empty string sets the Also, I don't think the |
||
}); | ||
})(); |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many ways to implement the functionality for this handler, but this seemed to be the simplest to me.