www

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

commit 1d2692d3f517dad75b7fe8c8aa3b1906b1c57505
parent 9391069f424ecb95054628059edf558a584b11aa
Author: gduperon <gduperon@5d9ba3ac-444b-4713-9fb3-0b58e79229a2>
Date:   Thu, 13 May 2010 18:29:19 +0000

séparation du mvc en plusieurs fichiers, logs multiples \o/

git-svn-id: https://projetud.info-ufr.univ-montp2.fr/svn/flin607-2009-gduperon@46 5d9ba3ac-444b-4713-9fb3-0b58e79229a2

Diffstat:
Mjside3/index.html | 36+++++++++++++++++++++++++++---------
Mjside3/modele.js | 189-------------------------------------------------------------------------------
Ajside3/mvc/barre-outils.js | 44++++++++++++++++++++++++++++++++++++++++++++
Ajside3/mvc/bloc.js | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ajside3/mvc/connexion.js | 19+++++++++++++++++++
Ajside3/mvc/definition.js | 47+++++++++++++++++++++++++++++++++++++++++++++++
Ajside3/mvc/instance-bloc.js | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ajside3/mvc/instance-log.js | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ajside3/mvc/log.js | 32++++++++++++++++++++++++++++++++
Ajside3/mvc/monde.js | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ajside3/mvc/port.js | 15+++++++++++++++
Mjside3/style.css | 28+++++++++++++++++++++++++++-
Mjside3/vue.js | 160++-----------------------------------------------------------------------------
13 files changed, 478 insertions(+), 356 deletions(-)

diff --git a/jside3/index.html b/jside3/index.html @@ -29,12 +29,21 @@ <!-- jQuery - mes extensions --> <script type="text/javascript" src="extensions-jQuery.js"></script> - <!-- Modèle --> + <!-- Modèle / Vue - fonctions utilitaires et explications --> <script type="text/javascript" src="modele.js"></script> - - <!-- Vue --> <script type="text/javascript" src="vue.js"></script> + <!-- MVC --> + <script type="text/javascript" src="mvc/monde.js"></script> + <script type="text/javascript" src="mvc/barre-outils.js"></script> + <script type="text/javascript" src="mvc/log.js"></script> + <script type="text/javascript" src="mvc/instance-log.js"></script> + <script type="text/javascript" src="mvc/bloc.js"></script> + <script type="text/javascript" src="mvc/instance-bloc.js"></script> + <script type="text/javascript" src="mvc/definition.js"></script> + <script type="text/javascript" src="mvc/connexion.js"></script> + <script type="text/javascript" src="mvc/port.js"></script> + <!-- Test --> <script type="text/javascript" src="test.js"></script> @@ -56,7 +65,8 @@ <h2 class="barre-outils barre-titre titre">Barre d'outils</h2> <!--</div>--> <input type="button" value="Nouveau bloc" class="barre-outils nouveau-bloc"/> - <input type="button" value="Coucou"/> + <input type="button" value="Recherche" class="barre-outils recherche"/> + <input type="button" value="Log" class="barre-outils log"/> </div> ]]> </script> @@ -64,7 +74,7 @@ <![CDATA[ <div class="log fenetre"> <div class="log barre-titre"> - <input type="button" class="log pause" value="▌▌" style="padding-right: 0.1em;" /> + <input type="button" class="log pause" value="▌▌" style="padding-right: 0.2em;" /> <input type="button" class="log play" value="▶"/> <h2 class="titre">Log</h2> </div> @@ -79,19 +89,27 @@ <div class="bloc fenetre"> <h2 class="bloc barre-titre titre">Nom du bloc</h2> <div class="bloc tabs titres"> - <h3 class="définition titre">Définition A</h3> - <h3 class="définition titre">Définition B</h3> - <h3 class="définition titre">Définition C</h3> + <h3 class="définition titre aucune-définition">Aucune définition</h3> <input type="button" class="nouvelle-définition" value="+"/> </div> <div class="bloc définitions"> + <div class="définition contenu aucune-définition"> + Aucune définition. + <br/> + Cliquez sur le + ci-dessus pour en créer une. + </div> </div> </div> ]]> </script> + <script type="text/x-jqote-template" id="vue-définition-titre"> + <![CDATA[ + <h3 class="définition titre">Nom de la définition</h3> + ]]> + </script> <script type="text/x-jqote-template" id="vue-définition"> <![CDATA[ - <div class="définition"> + <div class="définition contenu"> </div> ]]> diff --git a/jside3/modele.js b/jside3/modele.js @@ -29,195 +29,6 @@ function faireCallbacks(liste) { } } -function Monde(nom) { - $.extend(this, { - uid: singleton.uid(), - // Propriétés - nom: nom, - // Parents - // Enfants - log: null, - barreOutils: null, // J'ai des doutes sur la présence de barreOutils… - blocs: [], - scratch: null, - // Ajout - ajouterBloc: function(b) { - b.monde = this; - this.blocs.push(b); - }, - définirBarreOutils: function(bo) { - bo.monde = this; - this.barreOutils = bo; - }, - définirLog: function(l) { - l.monde = this; - this.log = l; - }, - // Suppression - supprimerBloc: function(b) { - this.blocs.remove(b); - } - }); - /*this.scratch = new Bloc("Scratch"); - this.ajouterBloc(this.scratch); - var iscratch = new InstanceBloc(this.scratch, {vues: this.vues}); // Attention, devrait utiliser une définition !!! - this.scratch.ajouterInstance(iscratch);*/ - this.scratch = new Définition(); // this.scratch.bloc == null; -} - -function BarreOutils() { - $.extend(this, { - monde: null, - }); -} - -function Log() { - $.extend(this, { - monde: null, - messages: [], - cbMessage: [], - // Ajout - envoiMessage: function(msg) { - this.messages.push(msg); - faireCallbacks(this.cbMessage, msg); - }, - // Évènements - onMessage: function(callback) { - this.cbMessage.push(callback); - } - }); -} - -function Bloc(nom) { - $.extend(this, { - uid: singleton.uid(), - // Propriétés - nom: nom, - description: '', // Est une définition ? - // Parents - monde: null, - // Utilisation - instances: [], - // Enfants - définitions: [], - portsEntree: [], - portsSortie: [], - // Ajout - /*ajouterInstance: function(ib) { - //ib.bloc = this; - this.instances.push(ib); - },*/ - demanderInstance: function() { - var ib = new InstanceBloc(); - ib.bloc = this; - this.instances.push(ib); - return ib; - }, - // Modification - /*déplacerDéfinition: function(def, position) { - var pos = définitions.remove(def); - if (pos < position) position--; - définitions.insert(def,position); - }, - déplacerPortEntree: function(port, position) { - var pos = portsEntree.remove(port); - if (pos < position) position--; - portsEntree.insert(port,position); - }, - déplacerPortSortie: function(port, position) { - var pos = portsSortie.remove(port); - if (pos < position) position--; - portsSortie.insert(port,position); - },*/ - ajouterDéfinition: function(d) { - d.bloc = this; - this.définitions.push(d); - faireCallbacks(this.cbAjoutDéfinition, d); - }, - cbAjoutDéfinition: [], - onAjoutDéfinition: function(callback) { - this.cbAjoutDéfinition.push(callback); - } - }); -} - -function InstanceBloc() { - $.extend(this, { - uid: singleton.uid(), - // Propriétés - bloc: null, - // Parents - définition: null, - // Enfants - //instancesPorts: [], - // Ajout - }); -} - -function Définition(nom) { - $.extend(this, { - uid: singleton.uid(), - // Propriétés - nom: nom, - type: null, - //description: '', - // Parents - bloc: null, - // Enfants - connexions: [], - instancesBlocs: [], - // Ajout - ajouterInstanceBloc: function(ib) { - ib.définition = this; - this.instancesBlocs.push(ib); - faireCallbacks(this.cbAjoutInstanceBloc, ib); - }, - ajouterConnexion: function(c) { - c.définition = this; - this.connexion.push(c); - }, - cbAjoutInstanceBloc: [], - onAjoutInstanceBloc: function(callback) { - this.cbAjoutInstanceBloc.push(callback); - } - }); -} - -function Connexions(de, vers, définitionParente) { - $.extend(this, { - uid: singleton.uid(), - // Propriétés - de: de, - vers: vers, - // Parents - définition: définitionParente, - // Enfants - // Modification - modifierDe: function(nouveauDe) { - this.de = nouveauDe; - }, - modifierVers: function(nouveauVers) { - this.vers = nouveauVers; - } - }); -} - -function Port(sens, blocParent) { - $.extend(this, { - uid: singleton.uid(), - // Propriétés - sens: sens, /* entrée / sortie */ - nom: '', - description: '', - // ? - instances: [], - // Parents - bloc: blocParent, - // Enfants - connexions: [] - }); -} - /*function InstancePort(port, instanceBlocParente) { $.extend(this, { uid: singleton.uid(), diff --git a/jside3/mvc/barre-outils.js b/jside3/mvc/barre-outils.js @@ -0,0 +1,44 @@ +function MBarreOutils() { + $.extend(this, { + monde: null, + }); +} + +function VBarreOutils(vMondeParente) { + $.extend(this,( + $('#vue-barre-outils') + .jqote({}) + .appendTo(vMondeParente))); + + this.vBarreTitre = this.find('.barre-titre'); + this.vTitre = this.find('.titre'); + this.vBoutonNouveauBloc = this.find('.nouveau-bloc'); + this.vBoutonRecherche = this.find('.recherche'); + this.vBoutonLog = this.find('.log'); + + this.draggable(); + this.resizable(); +} + +function CBarreOutils(mBarreOutils, vMondeParente) { + this.modèle = mBarreOutils; + this.vue = new VBarreOutils(vMondeParente); + + var that = this; + (this.vue.vBoutonNouveauBloc) + .click(function() { + that.modèle.monde.log.envoiMessage("Nouveau bloc."); + var mb = new MBloc(); + that.modèle.monde.ajouterBloc(mb); + var mib = mb.demanderInstance(); + that.modèle.monde.scratch.ajouterInstanceBloc(mib); + }); + + (this.vue.vBoutonLog) + .click(function() { + that.modèle.monde.log.envoiMessage("Nouveau log."); + var ml = that.modèle.monde.log; + var mil = ml.demanderInstance(); + that.modèle.monde.ajouterInstanceLog(mil); + }); +} diff --git a/jside3/mvc/bloc.js b/jside3/mvc/bloc.js @@ -0,0 +1,54 @@ +function MBloc() { + $.extend(this, { + uid: singleton.uid(), + + // Propriétés + nom: "Nouveau bloc", + description: '', /* Est une définition ? */ + + // Parents + monde: null, + + // Enfants + définitions: [], + portsEntree: [], + portsSortie: [], + + // Instanciation + instances: [], + demanderInstance: function() { + var mib = new MInstanceBloc(); + mib.bloc = this; + this.instances.push(mib); + return mib; + }, + + // Modification + /*déplacerDéfinition: function(def, position) { + var pos = définitions.remove(def); + if (pos < position) position--; + définitions.insert(def,position); + }, + déplacerPortEntree: function(port, position) { + var pos = portsEntree.remove(port); + if (pos < position) position--; + portsEntree.insert(port,position); + }, + déplacerPortSortie: function(port, position) { + var pos = portsSortie.remove(port); + if (pos < position) position--; + portsSortie.insert(port,position); + },*/ + + // Ajout + ajouterDéfinition: function(d) { + d.bloc = this; + this.définitions.push(d); + faireCallbacks(this.cbAjoutDéfinition, d); + }, + cbAjoutDéfinition: [], + onAjoutDéfinition: function(callback) { + this.cbAjoutDéfinition.push(callback); + } + }); +} diff --git a/jside3/mvc/connexion.js b/jside3/mvc/connexion.js @@ -0,0 +1,19 @@ +function MConnexion(de, vers, définitionParente) { + $.extend(this, { + uid: singleton.uid(), + // Propriétés + de: de, + vers: vers, + // Parents + définition: définitionParente, + // Enfants + // Modification + modifierDe: function(nouveauDe) { + this.de = nouveauDe; + }, + modifierVers: function(nouveauVers) { + this.vers = nouveauVers; + } + }); +} + diff --git a/jside3/mvc/definition.js b/jside3/mvc/definition.js @@ -0,0 +1,47 @@ +function MDéfinition() { + $.extend(this, { + uid: singleton.uid(), + // Propriétés + nom: "Nouvelle définition", + type: null, + //description: '', + // Parents + bloc: null, + // Enfants + connexions: [], + instancesBloc: [], + // Ajout + ajouterInstanceBloc: function(ib) { + ib.définition = this; + this.instancesBloc.push(ib); + faireCallbacks(this.cbAjoutInstanceBloc, ib); + }, + ajouterConnexion: function(c) { + c.définition = this; + this.connexion.push(c); + }, + cbAjoutInstanceBloc: [], + onAjoutInstanceBloc: function(callback) { + this.cbAjoutInstanceBloc.push(callback); + } + }); +} + +blablabla = 0; +function VDéfinition(vInstanceBlocParente) { + var t = $('#vue-définition-titre').jqote({}); + var d = $('#vue-définition').jqote({}).toDom(); + d.append(blablabla++); + vInstanceBlocParente.ajoutVDéfinition(t, d) + $.extend(this,d); + + this.mousedown(function(e) { + console.log("mousedown"); + return false; + }); +} + +function CDéfinition(mDéfinition, vInstanceBlocParente) { + this.modèle = mDéfinition; + this.vue = new VDéfinition(vInstanceBlocParente); +} diff --git a/jside3/mvc/instance-bloc.js b/jside3/mvc/instance-bloc.js @@ -0,0 +1,74 @@ +function MInstanceBloc() { + $.extend(this, { + uid: singleton.uid(), + // Propriétés + bloc: null, + // Parents + définition: null, + // Enfants + //instancesPorts: [], + // Ajout + }); +} + +function VInstanceBloc(vDéfinitionParente) { + $.extend(this,( + $('#vue-bloc') + .jqote({}) + .appendTo(vDéfinitionParente))); + + this.vBarreTitre = this.find('.barre-titre'); + this.vTitre = this.find('.titre'); + this.vBoutonNouvelleDéfinition = this.find('.nouvelle-définition'); + this.vTitresTabs = this.find('.bloc.tabs.titres'); + this.vDéfinitions = this.find('.définitions'); + this.vAucuneDéfinition = this.find('.aucune-définition'); + + this.aucuneDéfinition = true; + + var that = this; + this.ajoutVDéfinition = function(vTitreDéfinition, vDéfinition) { + if (this.aucuneDéfinition) { + this.vAucuneDéfinition.hide(); + this.aucuneDéfinition = false; + } + var vD = vDéfinition.appendTo(this.vDéfinitions); + var vTD = vTitreDéfinition.appendTo(this.vTitresTabs); + + vTD.click(function() { + that.changerTab(vTD, vD); + }); + this.changerTab(vTD, vD); + return vD; + }; + + this.changerTab = function(titreTab, contenuTab) { + this.vDéfinitions.children().hide(); + this.vTitresTabs.children().removeClass("active"); + titreTab.addClass("active"); + contenuTab.show(); + }; + + this.draggable(); + this.resizable(); + this.vTitresTabs.css('top', this.vBarreTitre.outerHeight()); + this.vDéfinitions.css('top', this.vBarreTitre.outerHeight() + this.vTitresTabs.outerHeight()); +} + +function CInstanceBloc(mInstanceBloc, vDéfinitionParente) { + this.modèle = mInstanceBloc; + this.vue = new VInstanceBloc(vDéfinitionParente); + + var that = this; + (this.vue.vBoutonNouvelleDéfinition) + .click(function() { + that.modèle.bloc.monde.log.envoiMessage("Nouvelle définition."); + var md = new MDéfinition(); + that.modèle.bloc.ajouterDéfinition(md); + }); + + this.modèle.bloc.onAjoutDéfinition(function(définition) { + that.modèle.bloc.monde.log.envoiMessage("Ajout de définition", définition); + new CDéfinition(définition, that.vue); + }); +} diff --git a/jside3/mvc/instance-log.js b/jside3/mvc/instance-log.js @@ -0,0 +1,62 @@ +function MInstanceLog() { + $.extend(this, { + uid: singleton.uid(), + // Propriétés + log: null, + pause: false + }); +} + +function VInstanceLog(vMondeParente) { + $.extend(this,( + $('#vue-log') + .jqote({}) + .appendTo(vMondeParente))); + + this.vBarreTitre = this.find('.barre-titre'); + this.vTitre = this.find('.titre'); + this.vBoutonPause = this.find('.log.pause'); + this.vBoutonPlay = this.find('.log.play'); + this.vMessages = this.find('.messages'); + + this.doPlay = function() { + this.vMessages.stop().scrollToLast(200); + this.vBoutonPause.show(); + this.vBoutonPlay.hide(); + }; + this.doPause = function() { + this.vMessages.stop(); + this.vBoutonPause.hide(); + this.vBoutonPlay.show(); + }; + this.ajoutMessage = function(msg, scroll) { + this.vMessages.append($('<div/>').text(msg)); + if (scroll) this.vMessages.stop().scrollToLast(100); + } + + this.draggable(); + this.resizable(); + this.vMessages.css('top', this.vBarreTitre.outerHeight()); + this.doPlay(); +} + +function CInstanceLog(mInstanceLog, vMondeParente) { + this.modèle = mInstanceLog; + this.vue = new VInstanceLog(vMondeParente); + + var that = this; + this.vue.vBoutonPause.add(this.vue.vBoutonPlay) + .click(function() { + if (that.modèle.pause) { + that.modèle.pause = false; + that.vue.doPlay(); + } else { + that.modèle.pause = true; + that.vue.doPause(); + } + }); + + this.modèle.log.onMessage(function(msg) { + that.vue.ajoutMessage(msg, !that.modèle.pause) + }); +} diff --git a/jside3/mvc/log.js b/jside3/mvc/log.js @@ -0,0 +1,32 @@ +function MLog() { + $.extend(this, { + uid: singleton.uid(), + + // Parents + monde: null, + + // Enfants + messages: [], + + // Instanciation + instances: [], + demanderInstance: function() { + var mil = new MInstanceLog(); + mil.log = this; + this.instances.push(mil); + return mil; + }, + + // Ajout + envoiMessage: function(msg) { + this.messages.push(msg); + faireCallbacks(this.cbMessage, msg); + }, + + // Évènements + cbMessage: [], + onMessage: function(callback) { + this.cbMessage.push(callback); + } + }); +} diff --git a/jside3/mvc/monde.js b/jside3/mvc/monde.js @@ -0,0 +1,74 @@ +function MMonde(nom) { + $.extend(this, { + uid: singleton.uid(), + // Propriétés + nom: nom, + // Parents + // Enfants + log: null, + barreOutils: null, // J'ai des doutes sur la présence de barreOutils… + blocs: [], + scratch: null, + // Ajout + ajouterBloc: function(b) { + b.monde = this; + this.blocs.push(b); + }, + définirBarreOutils: function(bo) { + bo.monde = this; + this.barreOutils = bo; + }, + définirLog: function(l) { + l.monde = this; + this.log = l; + }, + instancesLog: [], + ajouterInstanceLog: function(il) { + this.instancesLog.push(il); + faireCallbacks(this.cbAjoutInstanceLog, il); + }, + cbAjoutInstanceLog: [], + onAjoutInstanceLog: function(callback) { + this.cbAjoutInstanceLog.push(callback); + }, + // Suppression + supprimerBloc: function(b) { + this.blocs.remove(b); + } + }); + /*this.scratch = new Bloc("Scratch"); + this.ajouterBloc(this.scratch); + var iscratch = new InstanceBloc(this.scratch, {vues: this.vues}); // Attention, devrait utiliser une définition !!! + this.scratch.ajouterInstance(iscratch);*/ + this.scratch = new MDéfinition(); // this.scratch.bloc == null; + this.définirBarreOutils(new MBarreOutils()); + this.définirLog(new MLog()); +} + +function VMonde(appendToElement) { + $.extend(this, ( + $('#vue-monde') + .jqote({}) + .appendTo(appendToElement))); + + this.vBarreOutils = null; + this.vLog = null; + this.vScratch = this.find('.scratch'); +} + +function CMonde(mMonde, appendToElement) { + this.modèle = mMonde; + this.vue = new VMonde(appendToElement, mMonde); + this.vue.vBarreOutils = new CBarreOutils(this.modèle.barreOutils, this.vue); + //this.vue.vLog = new CLog(this.modèle.log, this.vue); + + var that = this; + this.modèle.scratch.onAjoutInstanceBloc(function(instanceBloc) { + var cib = new CInstanceBloc(instanceBloc, that.vue.vScratch); + }); + + this.modèle.onAjoutInstanceLog(function (instanceLog) { + var cil = new CInstanceLog(instanceLog, that.vue); + }); +} + diff --git a/jside3/mvc/port.js b/jside3/mvc/port.js @@ -0,0 +1,15 @@ +function MPort(sens, blocParent) { + $.extend(this, { + uid: singleton.uid(), + // Propriétés + sens: sens, /* entrée / sortie */ + nom: '', + description: '', + // ? + instances: [], + // Parents + bloc: blocParent, + // Enfants + connexions: [] + }); +} diff --git a/jside3/style.css b/jside3/style.css @@ -4,6 +4,7 @@ } body { + cursor: default; position:absolute; top: 0; left: 0; @@ -92,7 +93,7 @@ body { left: 0; right: 0; background: lightgray; - padding-bottom: .1em; + padding-bottom: 0; border: medium solid white; border-style: none solid none solid; @@ -105,10 +106,35 @@ body { float: left; } +.définition.titre.active { + background-color: #eee; + border-bottom: thin solid white; +} + .nouvelle-définition { float: right; } +.définitions { + position: absolute; + top: 2.9em; + left: 0; + right: 0; + bottom: 0; + background: white; + padding-bottom: .1em; +} + +/* Définitions */ +.définition.contenu { + height: 100%; +} + +.définition.contenu.aucune-définition { + text-align: center; + padding-top: 1em; +} + /* Fenêtres */ .barre-titre { background-color: #eef; diff --git a/jside3/vue.js b/jside3/vue.js @@ -10,163 +10,9 @@ Le contrôleur peut dialoguer avec son modèle, sa vue, et les enfants de sa vue Le contrôleur peut transmettre la vue parente reçue en paramètre à sa vue. */ -function VMonde(appendToElement) { - $.extend(this, ( - $('#vue-monde') - .jqote({}) - .appendTo(appendToElement))); - - this.vBarreOutils = null; - this.vLog = null; - this.vScratch = this.find('.scratch'); -} - -function CMonde(mMonde, appendToElement) { - this.modèle = mMonde; - this.modèle.définirBarreOutils(new BarreOutils()); - this.modèle.définirLog(new Log()); - this.vue = new VMonde(appendToElement, mMonde); - - this.vue.vBarreOutils = new CBarreOutils(this.modèle.barreOutils, this.vue); - this.vue.vLog = new CLog(this.modèle.log, this.vue); - - var that = this; - this.modèle.scratch.onAjoutInstanceBloc(function(instanceBloc) { - var cib = new CInstanceBloc(instanceBloc, that.vue.vScratch); - }) -} - -function VBarreOutils(vMondeParente) { - $.extend(this,( - $('#vue-barre-outils') - .jqote({}) - .appendTo(vMondeParente))); - - this.vBarreTitre = this.find('.barre-titre'); - this.vTitre = this.find('.titre'); - this.vBoutonNouveauBloc = this.find('.nouveau-bloc'); - - this.draggable(); - this.resizable(); -} - -function CBarreOutils(mBarreOutils, vMondeParente) { - this.modèle = mBarreOutils; - this.vue = new VBarreOutils(vMondeParente); - - var that = this; - (this.vue.vBoutonNouveauBloc) - .click(function() { - that.modèle.monde.log.envoiMessage("Nouveau bloc."); - var b = new Bloc("Bloc 2"); - var ib = b.demanderInstance(); - that.modèle.monde.scratch.ajouterInstanceBloc(ib); - - /* new CInstanceBloc(null, ib); // TODO */ - }); -} - -function VLog(vMondeParente) { - $.extend(this,( - $('#vue-log') - .jqote({}) - .appendTo(vMondeParente))); - - this.vBarreTitre = this.find('.barre-titre'); - this.vTitre = this.find('.titre'); - this.vBoutonPause = this.find('.log.pause'); - this.vBoutonPlay = this.find('.log.play'); - this.vMessages = this.find('.messages'); - - this.doPlay = function() { - this.vMessages.stop().scrollToLast(200); - this.vBoutonPause.show(); - this.vBoutonPlay.hide(); - }; - this.doPause = function() { - this.vMessages.stop(); - this.vBoutonPause.hide(); - this.vBoutonPlay.show(); - }; - - this.draggable(); - this.resizable(); - this.vMessages.css('top', this.vBarreTitre.outerHeight()); - this.doPlay(); -} - -function CLog(mLog, vMondeParente) { - this.modèle = mLog; - this.vue = new VLog(vMondeParente); - - var that = this; - this.vue.vBoutonPause.add(this.vue.vBoutonPlay) - .click(function() { - if (that.modèle.pause) { - that.modèle.pause = false; - that.vue.doPlay(); - } else { - that.modèle.pause = true; - that.vue.doPause(); - } - }); - - this.modèle.onMessage(function(msg) { - that.vue.vMessages.append($('<div/>').text(msg)); - if (!that.modèle.pause) { - that.vue.vMessages.stop().scrollToLast(100); - } - }); -} - -function VInstanceBloc(vDéfinitionParente) { - $.extend(this,( - $('#vue-bloc') - .jqote({}) - .appendTo(vDéfinitionParente))); - - this.vBarreTitre = this.find('.barre-titre'); - this.vTitre = this.find('.titre'); - this.vTitresTabs = this.find('.bloc.tabs.titres'); - this.vBoutonNouvelleDéfinition = this.find('.nouvelle-définition'); - - this.draggable(); - this.resizable(); - this.vTitresTabs.css('top', this.vBarreTitre.outerHeight()); -} - -function CInstanceBloc(mInstanceBloc, vDéfinitionParente) { - this.modèle = mInstanceBloc; - this.vue = new VInstanceBloc(vDéfinitionParente); - - (this.vue.vBoutonNouvelleDéfinition) - .click(function() { - elem.modèle.bloc.monde.log.envoiMessage("Nouvelle définition."); - var d = new Définition(); - elem.modèle.bloc.ajouterDéfinition(d); - }); - - this.modèle.bloc.onAjoutDéfinition(function(définition) { - console.log("Ajout de définition", définition); - }); -} - -function VDéfinition(d, vInstanceBlocParente) { - this.modèle = d; - this.vInstanceBloc = vInstanceBlocParente; - var elem = $.extend(this,( - $('#vue-définition') - .jqote(d) - .appendTo(vueInstanceBloc))); - - //d.bloc.instances[0].vues.titres - - this.modèle.ajouterVue(this); -} - function test() { - var m = new Monde("Le Monde"); - var cm = new CMonde(m, '#editeur'); + var mMonde = new MMonde("Le Monde"); + var cMonde = new CMonde(mMonde, '#editeur'); /* var b = new Bloc("Bloc 1"); m.ajouterBloc(b); @@ -176,7 +22,7 @@ function test() { new VInstanceBloc(null, ib); // TODO */ - testlog(m, 6); + testlog(mMonde, 6); } $(function(){ test(); });