www

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

definitions.js (3799B)


      1 /* Pas de modèle pour définitions: c'est juste une partie de instanceBloc */
      2 
      3 function VDéfinitions(vInstanceBlocParente) {
      4     $.extend(this,(
      5         $('#vue-définitions')
      6             .jqote({})
      7             .toDom()));
      8     vInstanceBlocParente.setVDéfinitions(this);
      9     
     10     this.vTitresTabs = this.find('.définitions.vTitresTabs');
     11     this.vBoutonNouvelleDéfinition = this.find('.définitions.vNouvelle-définition');
     12     
     13     this.vContenus = this.find('.définitions.vContenus');
     14     this.vContenusTabs = this.find('.définitions.vContenusTabs');
     15     this.vTitreAucuneDéfinition = this.find('.définition.vTitre.vAucune-définition');
     16     this.vCorpsAucuneDéfinition = this.find('.définition.vCorps.vAucune-définition');
     17     
     18     this.vPortsEntrée = this.find('.définitions.vPorts-entrée');
     19     this.vPortsSortie = this.find('.définitions.vPorts-sortie');
     20     
     21     this.aucuneDéfinition = true;
     22     
     23     
     24     var that = this;
     25     jQuery.event.special.drag.not = ''; // accept drag on all elements.
     26     this.vBoutonNouvelleDéfinition.bind('dragstart', function(event){
     27         $.dropManage({ mode:'intersect', filter:'.port-target' });
     28         return $('#vue-port-drag').jqote({}).appendTo('body');
     29     });
     30     
     31     this.vBoutonNouvelleDéfinition.bind('drag', function(event){
     32         $(event.dragProxy).position({my: 'center', at: 'center', of: event});
     33         return true;
     34     });
     35     
     36     this.vBoutonNouvelleDéfinition.bind('dragend', function(event){
     37         $(event.dragProxy).fadeOut();
     38     });
     39 
     40     this.ajoutVDéfinition = function(vTitreDéfinition, vCorpsDéfinition) {
     41         if (this.aucuneDéfinition) {
     42             this.vTitreAucuneDéfinition.hide();
     43             this.aucuneDéfinition = false;
     44         }
     45         var vtd = $(vTitreDéfinition).insertBefore(this.vTitresTabs.children('.clearfloat')); // hack…
     46         var vcd = vCorpsDéfinition.appendTo(this.vContenusTabs);
     47         
     48         vtd.click(function() {
     49             that.changerTab(vtd, vcd);
     50         });
     51         this.changerTab(vtd, vcd);
     52         this.ajusterBarreTitres();
     53         return vcd;
     54     };
     55 
     56     this.changerTab = function(titreTab, contenuTab) {
     57         this.vTitresTabs.children().removeClass("active");
     58         this.vContenusTabs.children().hide();
     59         titreTab.addClass("active");
     60         contenuTab.show();
     61     };
     62 
     63     this.setVPorts = function(vPorts, sens) {
     64         if (sens == 'entrée')
     65             this.vPortsEntrée.replaceWith(vPorts);
     66         else
     67             this.vPortsSortie.replaceWith(vPorts);
     68     };
     69     
     70     this.ajusterBarreTitres = function() {
     71         that.vContenus.css('top', that.vTitresTabs.outerHeight());
     72     }
     73     
     74     this.ajusterBarreTitres();
     75 }
     76 
     77 function CDéfinitions(mInstanceBloc, vInstanceBlocParente) {
     78     this.modèle = mInstanceBloc;
     79     this.vue = new VDéfinitions(vInstanceBlocParente);
     80     
     81     var that = this;
     82     (this.vue.vBoutonNouvelleDéfinition)
     83         .click(function() {
     84             that.modèle.bloc.monde.log.envoiMessage("Nouvelle définition.");
     85             var md = new MDéfinition();
     86             that.modèle.bloc.ajouterDéfinition(md);
     87         });
     88     
     89     this.modèle.bloc.onAjoutDéfinition(function(définition) {
     90         that.modèle.bloc.monde.log.envoiMessage("Ajout de définition", définition);
     91         new CDéfinition(définition, that.vue);
     92     });
     93 
     94     var that = this;
     95     this.vue.vBoutonNouvelleDéfinition[0].droppedOn = function(destination, position) { // Using [0] is a bit of a hack
     96         if (destination.entrée)
     97             destination.bloc.mPortsEntrée.ajouterPort(new MPort(true, destination.bloc.mPortsEntrée));
     98         else
     99             destination.bloc.mPortsSortie.ajouterPort(new MPort(true, destination.bloc.mPortsSortie));
    100     }
    101     
    102     new CPorts(this.modèle, this.vue);
    103 }