Переглянути джерело

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 8 місяців тому
батько
коміт
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();