A pixel art painter geared specifically at NES pixel art. Includes export for .chr binary file as well as palette and namespace data.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.2KB

  1. import GlobalEvents from "/app/js/common/EventCaller.js";
  2. function UnselectTab(tabname, tabid, el){
  3. el.classList.remove("tab-selected");
  4. var d = document.querySelectorAll("[fortabs='" + tabname + "'][tabid='" + tabid + "']");
  5. for (let i=0; i < d.length; i++){
  6. d[i].classList.add("hidden");
  7. }
  8. }
  9. function SelectTab(tabname, tabid, el){
  10. if (!el.classList.contains("tab-selected"))
  11. el.classList.add("tab-selected");
  12. var d = document.querySelectorAll("[fortabs='" + tabname + "'][tabid='" + tabid + "']");
  13. for (let i=0; i < d.length; i++){
  14. d[i].classList.remove("hidden");
  15. }
  16. }
  17. function GenTABListener(tabname, tabid, lil){
  18. return function(e){
  19. for (let i=0; i < lil.length; i++){
  20. if (lil[i].classList.contains("tab-selected")){
  21. if (lil[i].getAttribute("tabid") !== tabid){
  22. UnselectTab(tabname, lil[i].getAttribute("tabid"), lil[i]);
  23. } else {break; /* The same tab is being selected. */}
  24. } else if (lil[i].getAttribute("tabid") === tabid){
  25. SelectTab(tabname, tabid, lil[i]);
  26. }
  27. }
  28. }
  29. }
  30. function HideAllTABContent(tabname){
  31. var d = document.querySelectorAll("[fortabs='" + tabname + "']");
  32. for (let i=0; i < d.length; i++){
  33. d[i].classList.add("hidden");
  34. }
  35. }
  36. class Tabs{
  37. constructor(){}
  38. initialize(){
  39. var tabs = document.querySelectorAll("ul[tabs]");
  40. for (let i=0; i < tabs.length; i++){
  41. var selectionMade = false;
  42. var tabname = tabs[i].getAttribute("tabs");
  43. HideAllTABContent(tabname);
  44. var li = tabs[i].querySelectorAll("li[tabid]");
  45. for (let j=0; j < li.length; j++){
  46. var tabid = li[j].getAttribute("tabid");
  47. var a = li[j].querySelector("a");
  48. a.addEventListener("click", GenTABListener(tabname, tabid, li));
  49. if (li[j].classList.contains("tab-selected")){
  50. if (selectionMade){
  51. UnselectTab(tabname, tabid, li[j]);
  52. } else {
  53. SelectTab(tabname, tabid, li[j]);
  54. selectionMade = true;
  55. }
  56. }
  57. }
  58. if (selectionMade == false){
  59. var tabid = li[0].getAttribute("tabid");
  60. SelectTab(tabname, tabid, li[0]);
  61. }
  62. }
  63. }
  64. }
  65. const instance = new Tabs();
  66. export default instance;