instance-bloc.js (3402B)
1 function MInstanceBloc() { 2 $.extend(this, { 3 uid: singleton.uid(), 4 // Propriétés 5 bloc: null, 6 // Parents 7 définition: null, 8 // Enfants 9 //instancesPorts: [], 10 // Ajout 11 }); 12 } 13 14 function VInstanceBloc(vDéfinitionParente) { 15 $.extend(this,( 16 $('#vue-instance-bloc') 17 .jqote({}) 18 .appendTo(vDéfinitionParente))); 19 20 var that = this; 21 this.click(function() { 22 that.appendTo(vDéfinitionParente); 23 }); 24 25 this.vBarreTitre = this.find('.instance-bloc.vBarre-titre'); 26 this.vTitre = this.find('.instance-bloc.vTitre'); 27 this.vVueTitre = this.find('.instance-bloc.vVue-titre'); 28 this.vÉditionTitre = this.find('.instance-bloc.vÉdition-titre'); 29 this.vChampTitre = this.find('.instance-bloc.vChamp-titre'); 30 this.vBoutonValiderTitre = this.find('.instance-bloc.vBoutonValiderTitre'); 31 this.vDéfinitionsFille = null; 32 this.vDéfinitions = this.find('.instance-bloc.vDéfinitions'); 33 34 this.setVDéfinitions = function(vDéfinitions) { 35 this.vDéfinitions.append(vDéfinitions); 36 this.vDéfinitionsFille = vDéfinitions; 37 } 38 39 this.titre = function(val) { 40 if (typeof val != "function") { 41 this.vTitre.text(val); 42 this.ajusterBarreTitre(); 43 return true; 44 } 45 this.vTitre.hide(); 46 this.vChampTitre.val(this.vTitre.text()); 47 this.vÉditionTitre.show(); 48 this.ajusterBarreTitre(); 49 this.vChampTitre.select(); 50 var cbModifTitre = val; 51 this.vÉditionTitre.submit(function(ev) { 52 that.vTitre.show(); 53 that.vÉditionTitre.hide(); 54 that.ajusterBarreTitre(); 55 window.setTimeout(function() {cbModifTitre(that.vChampTitre.val());}, 0); 56 return false; 57 }); 58 } 59 60 this.ajusterBarreTitre = function() { 61 that.vDéfinitions.css('top', that.vBarreTitre.outerHeight()); 62 } 63 64 this.draggable(); 65 this.resizable({ 66 resize: function() { 67 that.ajusterBarreTitre(); 68 if (that.vDéfinitionsFille) 69 that.vDéfinitionsFille.ajusterBarreTitres(); 70 } 71 }); 72 this.vÉditionTitre.hide(); 73 this.ajusterBarreTitre(); 74 } 75 76 function CInstanceBloc(mInstanceBloc, vDéfinitionParente) { 77 this.modèle = mInstanceBloc; 78 this.vue = new VInstanceBloc(vDéfinitionParente); 79 80 var that = this; 81 (this.vue.vTitre) 82 .dblclick(function() { 83 that.vue.titre(function(nouveauNom) { 84 that.modèle.bloc.changeNom(nouveauNom); 85 }); 86 }); 87 88 (this.modèle.bloc) 89 .onChangeNom(function(nouveauNom) { 90 that.vue.titre(that.modèle.bloc.nom); 91 }); 92 93 this.vue.titre(this.modèle.bloc.nom); 94 this.vue.css('left', (this.modèle.rect.x1 - this.modèle.rectParent.x1) / this.modèle.rectParent.width * vDéfinitionParente.width()); 95 this.vue.css('top', (this.modèle.rect.y1 - this.modèle.rectParent.y1) / this.modèle.rectParent.height * vDéfinitionParente.height()); 96 this.vue.width(this.modèle.rect.width / this.modèle.rectParent.width * vDéfinitionParente.width()); 97 this.vue.height(this.modèle.rect.height / this.modèle.rectParent.height * vDéfinitionParente.height()); 98 99 new CDéfinitions(this.modèle, this.vue); 100 }