-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Erwin Dondorp
committed
Oct 25, 2024
1 parent
f111018
commit de17bc4
Showing
30 changed files
with
407 additions
and
310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* global */ | ||
|
||
import {Character} from "./Character.js"; | ||
import {DropDownMenu} from "./DropDown.js"; | ||
|
||
export class DropDownMenuCheckBox extends DropDownMenu { | ||
|
||
static _menuItemTitleCallBack (pMenuItem) { | ||
let prefix = ""; | ||
if (pMenuItem._selected === true) { | ||
prefix = Character.HEAVY_CHECK_MARK + Character.NO_BREAK_SPACE; | ||
} | ||
return prefix + pMenuItem._title; | ||
} | ||
|
||
static _menuItemActionCallBack (pMenuItem) { | ||
pMenuItem._selected = !pMenuItem._selected; | ||
} | ||
|
||
addMenuItemCheckBox (pValue, pTitle, pUserCallBack) { | ||
const menuItem = super.addMenuItem( | ||
pValue, | ||
DropDownMenuCheckBox._menuItemTitleCallBack, | ||
DropDownMenuCheckBox._menuItemActionCallBack, | ||
pUserCallBack); | ||
menuItem._title = pTitle; | ||
return menuItem; | ||
} | ||
|
||
isSet (pValue) { | ||
for (const menuItem of this.menuDropdownContent.childNodes) { | ||
if (menuItem._selected === true && menuItem._value === pValue) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* global */ | ||
|
||
import {DropDownMenu} from "./DropDown.js"; | ||
|
||
export class DropDownMenuCmd extends DropDownMenu { | ||
|
||
addMenuItemCmd (pTitle, pUserCallBack) { | ||
return super.addMenuItem( | ||
null, | ||
pTitle, | ||
pUserCallBack | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* global */ | ||
|
||
import {Character} from "./Character.js"; | ||
import {DropDownMenu} from "./DropDown.js"; | ||
|
||
export class DropDownMenuRadio extends DropDownMenu { | ||
constructor (pParentElement) { | ||
super(pParentElement); | ||
this._value = null; | ||
this._defaultValue = null; | ||
} | ||
|
||
getValue () { | ||
if (this._value === null) { | ||
return this._defaultValue; | ||
} | ||
return this._value; | ||
} | ||
|
||
setValue (pValue) { | ||
this._value = pValue; | ||
} | ||
|
||
setDefaultValue (pDefaultValue) { | ||
this._defaultValue = pDefaultValue; | ||
} | ||
|
||
_menuItemTitleCallBack (pMenuItem) { | ||
let title; | ||
if (!pMenuItem._title) { | ||
title = "..."; | ||
} else if (typeof pMenuItem._title === "string") { | ||
title = pMenuItem._title; | ||
} else { | ||
title = pMenuItem._title.bind(this)(pMenuItem); | ||
} | ||
|
||
if (title === null) { | ||
// menu item will be hidden | ||
} else if (pMenuItem._value === this._value) { | ||
title = Character.BLACK_CIRCLE + Character.NO_BREAK_SPACE + title; | ||
} else if (this._value === null && pMenuItem._value === this._defaultValue) { | ||
title = Character.WHITE_CIRCLE + Character.NO_BREAK_SPACE + title; | ||
} | ||
return title; | ||
} | ||
|
||
_menuItemActionCallBack (pMenuItem) { | ||
this._value = pMenuItem._value; | ||
let menuTitle = pMenuItem._title; | ||
if (menuTitle && typeof menuTitle !== "string") { | ||
menuTitle = menuTitle.bind(this)(pMenuItem); | ||
} | ||
this.setTitle(menuTitle); | ||
} | ||
|
||
addMenuItemRadio (pValue, pTitle, pUserCallBack) { | ||
const menuItem = super.addMenuItem( | ||
pValue, | ||
this._menuItemTitleCallBack, | ||
this._menuItemActionCallBack, | ||
pUserCallBack); | ||
menuItem._value = pValue; | ||
menuItem._title = pTitle; | ||
return menuItem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.