소스 검색

Update 'src/app/core/application/menu.js'

Added header
Changes to use object constructor "description" (app/core/models/components/component-options.js) in button (app/core/application/menu.js)
In "refresh()" was added: title="${options.description}"
leo 1 년 전
부모
커밋
7bf91f5d81
1개의 변경된 파일39개의 추가작업 그리고 11개의 파일을 삭제
  1. 39 11
      src/app/core/application/menu.js

+ 39 - 11
src/app/core/application/menu.js

@@ -1,29 +1,57 @@
+/*
+ * iGeom by LInE
+ * Free software to student private data
+ *
+ * http://www.matematica.br/igeom
+ * http://www.usp.br/line
+ *
+ * Treat object Menu (File | Edit)
+ *
+ * ./app/core/application/menu.js
+ * @version 2023/09/20: Added this header and some comments
+ */
+
 class Menu {
+
+  // @see ./app/core/models/components/component-options.js: class ComponentOptions 
+  // ComponentOptions has fields {id, title, icon, description, type}
+
   constructor() {
     this.tools = [];
     $("#tools").empty();
-  }
-  add(component) {
+    }
+
+  add (component) {
     this.tools.push(component);
-  }
-  refresh() {
+    }
+
+  refresh () {
     this.tools
       .filter(component => {
         return component.created == undefined;
-      })
+        })
       .forEach(component => {
+        // Put each iGeom option button (as "build Circumference")
         if (component != undefined && component.created) return;
         component.created = true;
-        const options = component.options;
+        const options = component.options; // defined on ./app/core/models/components/component-options.js (using ComponentOptions)
+
+        console.log("menu.js: " + options.title + " : " + options.description);
+
+        //TODO It is missign 'internationalization'!
+
+        // Each object has its associated button, each one with "ComponentOptions" that define its "desciption"
+        // (to be used on "title" bellow)
         $("#tools").append(`<button id="btn-${options.id}"
-          class="tool icon icon-${options.icon} fadeInRight">
+          class="tool icon icon-${options.icon} fadeInRight" title="${options.description}">
           <span> ${options.title} </span></button>`);
         $("body").on(
           "click",
           `#btn-${options.id}`,
           component.click.bind(component)
-        );
-      });
+          );
+        });
+    }
   }
-}
-export const menu = new Menu();
+
+export const menu = new Menu();