www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

bloc.js (1559B)


      1 function MBloc() {
      2     $.extend(this, {
      3         uid: singleton.uid(),
      4         
      5         // Propriétés
      6         nom: "Nouveau bloc",
      7         description: '', /* Est une définition ? */
      8         
      9         // Parents
     10         monde: null,
     11         
     12         // Enfants
     13         définitions: [],
     14         mPortsEntrée: null,
     15         mPortsSortie: null,
     16         
     17         // Instanciation
     18         instances: [],
     19         demanderInstance: function() {
     20             var mib = new MInstanceBloc();
     21             mib.bloc = this;
     22             this.instances.push(mib);
     23             return mib;
     24         },
     25         // Modification
     26         changeNom: function(nouveauNom) {
     27             this.nom = nouveauNom;
     28             faireCallbacks(this.cbChangeNom, this);
     29             faireCallbacks(this.cbModification, this);
     30         },
     31         // Ajout
     32         ajouterDéfinition: function(d) {
     33             d.bloc = this;
     34             this.définitions.push(d);
     35             faireCallbacks(this.cbAjoutDéfinition, d);
     36             faireCallbacks(this.cbModification, this);
     37         },
     38         cbAjoutDéfinition: [],
     39         onAjoutDéfinition: function(callback) {
     40             this.cbAjoutDéfinition.push(callback);
     41         },
     42         cbChangeNom: [],
     43         onChangeNom: function(callback) {
     44             this.cbChangeNom.push(callback);
     45         },
     46         cbModification: [],
     47         onModification: function(callback) {
     48             this.cbModification.push(callback);
     49         },
     50     });
     51     this.mPortsEntrée = new MPorts(this, true);
     52     this.mPortsSortie = new MPorts(this, false);
     53 }