mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2024-11-28 04:44:06 +00:00
Single Option Menu (#231)
* add flag * Update clickToggle() to handle single-option submenus (#232) Co-authored-by: asimon-1 <asimon1@protonmail.com> Co-authored-by: asimon-1 <40246417+asimon-1@users.noreply.github.com> Co-authored-by: asimon-1 <asimon1@protonmail.com>
This commit is contained in:
parent
a4533a4810
commit
841ea5e8fe
2 changed files with 21 additions and 7 deletions
|
@ -39,7 +39,8 @@ struct SubMenu<'a> {
|
|||
sliders: Vec<Slider>,
|
||||
onoffselector: Vec<OnOffSelector<'a>>,
|
||||
index: usize,
|
||||
check_against: usize
|
||||
check_against: usize,
|
||||
is_single_option: Option<bool>
|
||||
}
|
||||
|
||||
impl<'a> SubMenu<'a> {
|
||||
|
@ -103,7 +104,8 @@ impl<'a> Menu<'a> {
|
|||
sliders: Vec::new(),
|
||||
onoffselector: Vec::new(),
|
||||
index: self.max_idx() + 1,
|
||||
check_against
|
||||
check_against,
|
||||
is_single_option: Some(true)
|
||||
};
|
||||
|
||||
for toggle in toggles {
|
||||
|
@ -125,7 +127,8 @@ impl<'a> Menu<'a> {
|
|||
sliders: Vec::new(),
|
||||
onoffselector: Vec::new(),
|
||||
index: self.max_idx() + 1,
|
||||
check_against
|
||||
check_against,
|
||||
is_single_option: None
|
||||
};
|
||||
|
||||
for i in 0..strs.len() {
|
||||
|
@ -145,7 +148,8 @@ impl<'a> Menu<'a> {
|
|||
sliders: Vec::new(),
|
||||
onoffselector: Vec::new(),
|
||||
index: self.max_idx() + 1,
|
||||
check_against
|
||||
check_against,
|
||||
is_single_option: None
|
||||
};
|
||||
|
||||
sub_menu.add_onoffselector(title, checked, (default & OnOff::On as usize) != 0);
|
||||
|
|
|
@ -155,7 +155,7 @@
|
|||
<div class="keyword-button-outer">
|
||||
<a tabindex="{{index}}" class="flex-button keyword-button scuffle-thema" href="javascript:void(0)" onclick="clickToggle(this);" nx-se-disabled="">
|
||||
<div class="button-icon-wrapper">
|
||||
<img class="button-icon toggle {{checked}}" ref="./check.svg" src="./check.svg" default="{{default}}">
|
||||
<img class="button-icon toggle {{checked}} {{#is_single_option}}is-single-option{{/is_single_option}}" ref="./check.svg" src="./check.svg" default="{{default}}">
|
||||
</div>
|
||||
<div class="button-msg-wrapper">
|
||||
<div class="keyword-message f-u-bold">
|
||||
|
@ -316,8 +316,18 @@
|
|||
}
|
||||
|
||||
function clickToggle(e) {
|
||||
$(e).find(".toggle").toggleClass("is-appear");
|
||||
$(e).find(".toggle").toggleClass("is-hidden");
|
||||
var toggleOptions = $(e).find(".toggle");
|
||||
if ($(e).find(".is-single-option").length) { // Single-option submenu
|
||||
// Deselect all submenu options
|
||||
$(e).closest(".l-qa").find(".toggle").removeClass("is-appear");
|
||||
$(e).closest(".l-qa").find(".toggle").addClass("is-hidden");
|
||||
// Then set the current one as the active setting
|
||||
toggleOptions.addClass("is-appear");
|
||||
toggleOptions.removeClass("is-hidden");
|
||||
} else { // Multi-option submenu
|
||||
toggleOptions.toggleClass("is-appear");
|
||||
toggleOptions.toggleClass("is-hidden");
|
||||
}
|
||||
}
|
||||
|
||||
function getParams(url) {
|
||||
|
|
Loading…
Reference in a new issue