titre-définition.js (1662B)
1 function MTitreDéfinition() { 2 makeUid(this); 3 makeField(this, 'titre', 'Nom de la définition'); 4 } 5 6 function VTitreDéfinition(mTitreDéfinition, emplacement) { 7 makeView(this, 'vTitreDéfinition', emplacement, 'vTitre', 'vÉdition', 'vTexte', 'vSubmit', 'vCancel'); 8 9 var that = this; 10 11 // Actions 12 this.updateTitreDéfinition = function(mTitreDéfinition, titre) { 13 that.parties.vTitre.text(titre); 14 that.parties.vTexte.val(titre); 15 }; 16 17 this.editerTitreDéfinition = function() { 18 that.parties.vTitre.hide(); 19 that.parties.vÉdition.show(); 20 }; 21 22 this.accepteÉditionTitreDéfinition = function() { 23 mTitreDéfinition.titre(that.parties.vTexte.val()); 24 that.vueNormale(); 25 }; 26 27 this.anuleÉditionTitreDéfinition = function() { 28 that.parties.vTexte.val(mTitreDéfinition.titre()); 29 that.vueNormale(); 30 }; 31 32 this.vueNormale = function() { 33 that.parties.vTitre.show(); 34 that.parties.vÉdition.hide(); 35 }; 36 37 this.active = function(val) { 38 if (val) that.vue.addClass('active'); 39 else that.vue.removeClass('active'); 40 }; 41 42 // Binding 43 mTitreDéfinition.onChangeTitre(this.updateTitreDéfinition); 44 this.updateTitreDéfinition(mTitreDéfinition, mTitreDéfinition.titre()); 45 46 that.parties.vTitre.dblclick(this.editerTitreDéfinition); 47 48 that.parties.vCancel.click(this.anuleÉditionTitreDéfinition); 49 50 that.parties.vÉdition.submit(function(e) { 51 that.accepteÉditionTitreDéfinition(); 52 return false; 53 }); 54 55 // Défauts 56 this.vueNormale(); 57 }