www

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

commit 6da66d41fdad15b4596e4a582210befed9fb8f38
parent 72871c61c7e24d3029c59e331ea1897ca637cb16
Author: gduperon <gduperon@5d9ba3ac-444b-4713-9fb3-0b58e79229a2>
Date:   Tue, 18 May 2010 22:18:44 +0000

ref

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

Diffstat:
Djside4/mvc/barre-outils.js | 49-------------------------------------------------
Djside4/mvc/bloc.js | 53-----------------------------------------------------
Djside4/mvc/connexion.js | 19-------------------
Djside4/mvc/definition.js | 57---------------------------------------------------------
Djside4/mvc/definitions.js | 103-------------------------------------------------------------------------------
Djside4/mvc/instance-bloc.js | 100-------------------------------------------------------------------------------
Djside4/mvc/instance-log.js | 62--------------------------------------------------------------
Djside4/mvc/instance-recherche.js | 271-------------------------------------------------------------------------------
Djside4/mvc/log.js | 32--------------------------------
Djside4/mvc/monde.js | 139-------------------------------------------------------------------------------
Djside4/mvc/port-in-ports.js | 73-------------------------------------------------------------------------
Djside4/mvc/port.js | 47-----------------------------------------------
Djside4/mvc/ports.js | 103-------------------------------------------------------------------------------
Djside4/mvc/recherche.js | 23-----------------------
Djside4/mvc/resultat-recherche.js | 81-------------------------------------------------------------------------------
15 files changed, 0 insertions(+), 1212 deletions(-)

diff --git a/jside4/mvc/barre-outils.js b/jside4/mvc/barre-outils.js @@ -1,49 +0,0 @@ -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("Cliquez-glissez pour créer un nouveau bloc."); - that.modèle.monde.outilZone = that.modèle.monde.actionNouveauBloc; - }); - - (this.vue.vBoutonRecherche) - .click(function() { - that.modèle.monde.log.envoiMessage("Nouvelle recherche."); - var mr = that.modèle.monde.recherche; - var mir = mr.demanderInstance(); - that.modèle.monde.ajouterInstanceRecherche(mir); - }); - - (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/jside4/mvc/bloc.js b/jside4/mvc/bloc.js @@ -1,53 +0,0 @@ -function MBloc() { - $.extend(this, { - uid: singleton.uid(), - - // Propriétés - nom: "Nouveau bloc", - description: '', /* Est une définition ? */ - - // Parents - monde: null, - - // Enfants - définitions: [], - mPortsEntrée: null, - mPortsSortie: null, - - // Instanciation - instances: [], - demanderInstance: function() { - var mib = new MInstanceBloc(); - mib.bloc = this; - this.instances.push(mib); - return mib; - }, - // Modification - changeNom: function(nouveauNom) { - this.nom = nouveauNom; - faireCallbacks(this.cbChangeNom, this); - faireCallbacks(this.cbModification, this); - }, - // Ajout - ajouterDéfinition: function(d) { - d.bloc = this; - this.définitions.push(d); - faireCallbacks(this.cbAjoutDéfinition, d); - faireCallbacks(this.cbModification, this); - }, - cbAjoutDéfinition: [], - onAjoutDéfinition: function(callback) { - this.cbAjoutDéfinition.push(callback); - }, - cbChangeNom: [], - onChangeNom: function(callback) { - this.cbChangeNom.push(callback); - }, - cbModification: [], - onModification: function(callback) { - this.cbModification.push(callback); - }, - }); - this.mPortsEntrée = new MPorts(this, true); - this.mPortsSortie = new MPorts(this, false); -} diff --git a/jside4/mvc/connexion.js b/jside4/mvc/connexion.js @@ -1,19 +0,0 @@ -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/jside4/mvc/definition.js b/jside4/mvc/definition.js @@ -1,57 +0,0 @@ -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); - } - }); -} - -function VDéfinition(vDéfinitionsParente) { - $.extend(this,( - $('#vue-définition') - .jqote({}) - .toDom())); - this.vTitre = $('#vue-définition-titre').jqote({}); - vDéfinitionsParente.ajoutVDéfinition(this.vTitre, this); -} - -function CDéfinition(mDéfinition, vDéfinitionsParente) { - this.modèle = mDéfinition; - this.vue = new VDéfinition(vDéfinitionsParente); - - var that = this; - this.vue.zonable({ - start: function() { - }, - zone: function() { - }, - end: function(start, end, rect) { - that.modèle.bloc.monde.outilZone(that, rect, getRectangle(that.vue)); - } - }); - - this.modèle.onAjoutInstanceBloc(function(instanceBloc) { - var cib = new CInstanceBloc(instanceBloc, that.vue); - }); -} diff --git a/jside4/mvc/definitions.js b/jside4/mvc/definitions.js @@ -1,103 +0,0 @@ -/* Pas de modèle pour définitions: c'est juste une partie de instanceBloc */ - -function VDéfinitions(vInstanceBlocParente) { - $.extend(this,( - $('#vue-définitions') - .jqote({}) - .toDom())); - vInstanceBlocParente.setVDéfinitions(this); - - this.vTitresTabs = this.find('.définitions.vTitresTabs'); - this.vBoutonNouvelleDéfinition = this.find('.définitions.vNouvelle-définition'); - - this.vContenus = this.find('.définitions.vContenus'); - this.vContenusTabs = this.find('.définitions.vContenusTabs'); - this.vTitreAucuneDéfinition = this.find('.définition.vTitre.vAucune-définition'); - this.vCorpsAucuneDéfinition = this.find('.définition.vCorps.vAucune-définition'); - - this.vPortsEntrée = this.find('.définitions.vPorts-entrée'); - this.vPortsSortie = this.find('.définitions.vPorts-sortie'); - - this.aucuneDéfinition = true; - - - var that = this; - jQuery.event.special.drag.not = ''; // accept drag on all elements. - this.vBoutonNouvelleDéfinition.bind('dragstart', function(event){ - $.dropManage({ mode:'intersect', filter:'.port-target' }); - return $('#vue-port-drag').jqote({}).appendTo('body'); - }); - - this.vBoutonNouvelleDéfinition.bind('drag', function(event){ - $(event.dragProxy).position({my: 'center', at: 'center', of: event}); - return true; - }); - - this.vBoutonNouvelleDéfinition.bind('dragend', function(event){ - $(event.dragProxy).fadeOut(); - }); - - this.ajoutVDéfinition = function(vTitreDéfinition, vCorpsDéfinition) { - if (this.aucuneDéfinition) { - this.vTitreAucuneDéfinition.hide(); - this.aucuneDéfinition = false; - } - var vtd = $(vTitreDéfinition).insertBefore(this.vTitresTabs.children('.clearfloat')); // hack… - var vcd = vCorpsDéfinition.appendTo(this.vContenusTabs); - - vtd.click(function() { - that.changerTab(vtd, vcd); - }); - this.changerTab(vtd, vcd); - this.ajusterBarreTitres(); - return vcd; - }; - - this.changerTab = function(titreTab, contenuTab) { - this.vTitresTabs.children().removeClass("active"); - this.vContenusTabs.children().hide(); - titreTab.addClass("active"); - contenuTab.show(); - }; - - this.setVPorts = function(vPorts, sens) { - if (sens == 'entrée') - this.vPortsEntrée.replaceWith(vPorts); - else - this.vPortsSortie.replaceWith(vPorts); - }; - - this.ajusterBarreTitres = function() { - that.vContenus.css('top', that.vTitresTabs.outerHeight()); - } - - this.ajusterBarreTitres(); -} - -function CDéfinitions(mInstanceBloc, vInstanceBlocParente) { - this.modèle = mInstanceBloc; - this.vue = new VDéfinitions(vInstanceBlocParente); - - 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); - }); - - var that = this; - this.vue.vBoutonNouvelleDéfinition[0].droppedOn = function(destination, position) { // Using [0] is a bit of a hack - if (destination.entrée) - destination.bloc.mPortsEntrée.ajouterPort(new MPort(true, destination.bloc.mPortsEntrée)); - else - destination.bloc.mPortsSortie.ajouterPort(new MPort(true, destination.bloc.mPortsSortie)); - } - - new CPorts(this.modèle, this.vue); -} diff --git a/jside4/mvc/instance-bloc.js b/jside4/mvc/instance-bloc.js @@ -1,100 +0,0 @@ -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-instance-bloc') - .jqote({}) - .appendTo(vDéfinitionParente))); - - var that = this; - this.click(function() { - that.appendTo(vDéfinitionParente); - }); - - this.vBarreTitre = this.find('.instance-bloc.vBarre-titre'); - this.vTitre = this.find('.instance-bloc.vTitre'); - this.vVueTitre = this.find('.instance-bloc.vVue-titre'); - this.vÉditionTitre = this.find('.instance-bloc.vÉdition-titre'); - this.vChampTitre = this.find('.instance-bloc.vChamp-titre'); - this.vBoutonValiderTitre = this.find('.instance-bloc.vBoutonValiderTitre'); - this.vDéfinitionsFille = null; - this.vDéfinitions = this.find('.instance-bloc.vDéfinitions'); - - this.setVDéfinitions = function(vDéfinitions) { - this.vDéfinitions.append(vDéfinitions); - this.vDéfinitionsFille = vDéfinitions; - } - - this.titre = function(val) { - if (typeof val != "function") { - this.vTitre.text(val); - this.ajusterBarreTitre(); - return true; - } - this.vTitre.hide(); - this.vChampTitre.val(this.vTitre.text()); - this.vÉditionTitre.show(); - this.ajusterBarreTitre(); - this.vChampTitre.select(); - var cbModifTitre = val; - this.vÉditionTitre.submit(function(ev) { - that.vTitre.show(); - that.vÉditionTitre.hide(); - that.ajusterBarreTitre(); - window.setTimeout(function() {cbModifTitre(that.vChampTitre.val());}, 0); - return false; - }); - } - - this.ajusterBarreTitre = function() { - that.vDéfinitions.css('top', that.vBarreTitre.outerHeight()); - } - - this.draggable(); - this.resizable({ - resize: function() { - that.ajusterBarreTitre(); - if (that.vDéfinitionsFille) - that.vDéfinitionsFille.ajusterBarreTitres(); - } - }); - this.vÉditionTitre.hide(); - this.ajusterBarreTitre(); -} - -function CInstanceBloc(mInstanceBloc, vDéfinitionParente) { - this.modèle = mInstanceBloc; - this.vue = new VInstanceBloc(vDéfinitionParente); - - var that = this; - (this.vue.vTitre) - .dblclick(function() { - that.vue.titre(function(nouveauNom) { - that.modèle.bloc.changeNom(nouveauNom); - }); - }); - - (this.modèle.bloc) - .onChangeNom(function(nouveauNom) { - that.vue.titre(that.modèle.bloc.nom); - }); - - this.vue.titre(this.modèle.bloc.nom); - this.vue.css('left', (this.modèle.rect.x1 - this.modèle.rectParent.x1) / this.modèle.rectParent.width * vDéfinitionParente.width()); - this.vue.css('top', (this.modèle.rect.y1 - this.modèle.rectParent.y1) / this.modèle.rectParent.height * vDéfinitionParente.height()); - this.vue.width(this.modèle.rect.width / this.modèle.rectParent.width * vDéfinitionParente.width()); - this.vue.height(this.modèle.rect.height / this.modèle.rectParent.height * vDéfinitionParente.height()); - - new CDéfinitions(this.modèle, this.vue); -} diff --git a/jside4/mvc/instance-log.js b/jside4/mvc/instance-log.js @@ -1,62 +0,0 @@ -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/jside4/mvc/instance-recherche.js b/jside4/mvc/instance-recherche.js @@ -1,271 +0,0 @@ -function MInstanceRecherche() { - $.extend(this, { - uid: singleton.uid(), - // Propriétés - mRecherche: null, - termes: '', - sélection: [], - ajouterRésultatSélection: function(s) { - this.sélection.push(s); - s.ajoutSélection(); - }, - supprimerRésultatSélection: function(s) { - this.sélection.remove(s); - s.suppressionSélection(); - }, - effacerSélection: function(s) { - for (var i = 0; i < this.sélection.length; i++) - this.sélection[i].suppressionSélection(); - this.sélection = []; - } - }); -} - -function VInstanceRecherche(vMondeParente) { - $.extend(this,( - $('#vue-recherche') - .jqote({}) - .appendTo(vMondeParente))); - - this.vBarreTitre = this.find('.barre-titre'); - this.vTitre = this.find('.titre'); - this.vChampTermes = this.find('.termes'); - this.vRésultats = this.find('.résultats'); - this.premièreFois = true; - this.addClass('première-fois'); - - var that = this; - (this.vChampTermes) - .focus(function() { - if (that.premièreFois) { - that.premièreFois = false; - that.vChampTermes.val(""); - // TODO : unbind focus - } - }); - - this.ajoutVRésultatRecherche = function(vrr, position) { - if (position === undefined || position >= this.vRésultats.children().size() - 1) { - this.vRésultats.append(vrr); - } else { - this.vRésultats.children().eq(position).before(vrr); - } - }; - - this.sélection = function(s) { - this.vRésultats.children.removeClass('sélectionné'); - s.addClass('sélectionné'); - }; - - this.termes = function(val) { - if (val !== undefined) { - this.vChampTermes.val(val); - this.removeClass('première-fois'); - this.premièreFois = false; - // TODO : unbind focus - } else if (this.premièreFois) { - return ""; - } else { - return this.vChampTermes.val(); - } - }; - - /*this.effacerRésultats = function() { - this.vRésultats.empty(); - };*/ - - this.draggable(); - this.resizable(); - this.vRésultats.css('top', this.vBarreTitre.outerHeight()); -} - -function CInstanceRecherche(mInstanceRecherche, vMondeParente) { - this.modèle = mInstanceRecherche; - this.vue = new VInstanceRecherche(vMondeParente); - this.ancienTerme = ""; - this.anciensRésultats = []; - - var that = this; - (this.vue.vChampTermes) - .keyup(function() { // keypress ne prend pas en compte le backspace - that.actualiserRecherche(); - }); - - (this.modèle.mRecherche.monde) - .onAjoutBloc(function(bloc) { - that.actualiserRecherche([bloc], true, true); - }); - - (this.modèle.mRecherche.monde) - .onModificationBloc(function(bloc) { - that.actualiserRecherche([bloc], true, true); - }); - - this.actualiserRecherche = function(domaine, animAjout, animSuppression) { - var termes = this.vue.termes().toLowerCase().split(" "); - var domaine = domaine || this.modèle.mRecherche.monde.blocs; - var résultats = filtrerValeurs(mInstanceRecherche, domaine, termes, function(b) { - return { - original: b.nom, - searchOn: b.nom.toLowerCase() - }; - }); - - this.anciensRésultats = fusionRésultats(this.anciensRésultats, domaine, résultats, this.vue, this.modèle, animAjout, animSuppression); - } - - this.actualiserRecherche(null, true, true); -} - -/* Fonctions auxiliaires */ - -function filtrerValeurs(mInstanceRecherche, ensemble, termes, getTexte) { - var maxres = 50; - var résultats = []; - var nbres = 0; - var ensemble_length = ensemble.length; - termes = termes.filter(function (e) { return e != ""; }); - - for (var i = 0; i < ensemble_length; i++) { - var texte = getTexte(ensemble[i]); - var mrr = searchAndReturnFormatted(mInstanceRecherche, texte.searchOn, texte.original, termes); - - if (mrr !== false) { - mrr.objet = ensemble[i]; - mrr.uid = ensemble[i].uid; - résultats.push(mrr); - nbres++; - if (nbres >= maxres) break; - } - } - - résultats.sort(function(a,b){return a.score - b.score}); - for (var i = 0; i<résultats.length; i++) { résultats[i].position = i; } - return résultats; -} - -/* searchAndReturnFormatted("abcdefghijkabcxyz", ["abc", "ef", "cxy"]); */ -function searchAndReturnFormatted(mInstanceRecherche, haystack, original, needles) { - var status = new Array(haystack.length); - for (var i = 0; i < status.length; i++) { - status[i] = 0; - } - - for (var n = 0; n < needles.length; n++) { - var nl = needles[n].length; - var idx = haystack.indexOf(needles[n]); - if (idx < 0) { - // Aucune occurence de needles[n] - return false; - } - while (idx >= 0) { - for (var i = idx; i < idx + nl; i++) { - if (status[i] > 0) { - for (j = idx; j < idx + nl; j++) { - if (j >= i && status[j] >= 1) { - status[j] = 3; - } else { - status[j] = 2; - } - } - i = idx + nl; - break; - } - status[i] = 1; - } - idx = haystack.indexOf(needles[n], i); - } - } - - var old = -1; - var str = ""; - for (var i = 0; i < status.length; i++) { - if (old != status[i]) { - if (old >= 1) - str += '</span>'; - if (status[i] == 1) { - str += '<span class="occurence">'; - } else if (status[i] == 2) { - str += '<span class="superposée">'; - } else if (status[i] == 3) { - str += '<span class="superposition">'; - } - } - str += original[i]; - old = status[i]; - } - - if (old >= 1) - str += '</span>'; - var mrr = new MRésultatRecherche(); - mrr.mInstanceRecherche = mInstanceRecherche; - mrr.html = str; - mrr.score = $.sum(status); // We definitely need a better score calculation… - return mrr; -} - -/* anciens = [] of CRésultatRecherche; - * domaine = [] of MBloc; - * nouveaux = [] of MRésultatRecherche; - * vRechercheParente is a VRechercheParente - * mInstanceRecherche is a MInstanceRecherche - * animAjout is a boolean - * animSuppression is a boolean - */ - -function fusionRésultats(anciens, domaine, nouveaux, vRechercheParente, mInstanceRecherche, animAjout, animSuppression) { - anciens.sort(function(a,b) { return a.modèle.objet.uid - b.modèle.objet.uid; }); - domaine.sort(function(a,b) { return a.uid - b.uid; }); - nouveaux.sort(function(a,b) { return a.objet.uid - b.objet.uid; }); - - // Ceci est une sorte de tri fusion à trois tableaux… aaaaaarrrgggh ! - - /* anciens domaine nouveaux || Action - * oui non non (obligé) || = Reste - * oui oui oui || = Reste - * oui oui non || - Supprime - * non oui oui || + Ajoute - * non oui non || 0 Aucune - */ - - var fusion = []; - var iD = 0; - var iN = 0; - var iA = 0; - var lA = anciens.length; - var lD = domaine.length; - var lN = nouveaux.length; - while ((iA < lA) || (iD < lD) || (iN < lN)) { - var uidA = (iA < lA) ? anciens[iA].modèle.objet.uid : Infinity; - var uidD = (iD < lD) ? domaine[iD].uid : Infinity; - var uidN = (iN < lN) ? nouveaux[iN].objet.uid : Infinity; - - var a = (iA < lA && uidA <= uidD); - var d = (iD < lD && uidA >= uidD); - var n = (iN < lN && uidD == uidN) && d; - - //console.log([iA,iD,iN], [uidA,uidD,uidN], [a,d,n]); - - if (a && !(d && !n)) { // Reste - if (n) { - anciens[iA].setModèle(nouveaux[iN]); - } - fusion.push(anciens[iA]); - } - if (a && d && !n) { // Supprime - anciens[iA].suppression(animSuppression); - } - if (!a && d && n) { // Ajoute - var cr = new CRésultatRecherche(nouveaux[iN], vRechercheParente); - if (animAjout) { - cr.vue.animAjout(); - } - fusion.push(cr); - } - - if (a) iA++; - if (d) iD++; - if (n) iN++; - } - return fusion; -} diff --git a/jside4/mvc/log.js b/jside4/mvc/log.js @@ -1,32 +0,0 @@ -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/jside4/mvc/monde.js b/jside4/mvc/monde.js @@ -1,139 +0,0 @@ -function MMonde(nom) { - $.extend(this, { - uid: singleton.uid(), - // Propriétés - nom: nom, - // Parents - // Enfants - log: null, - recherche: null, - barreOutils: null, // J'ai des doutes sur la présence de barreOutils… - blocs: [], - mBlocScratch: null, - mDéfinitionScratch: null, - // Ajout - ajouterBloc: function(b) { - b.monde = this; - this.blocs.push(b); - var that = this; - b.onModification(function(b) { - faireCallbacks(that.cbModificationBloc, b); - }); - faireCallbacks(this.cbAjoutBloc, b); - }, - cbAjoutBloc: [], - onAjoutBloc: function(callback) { - this.cbAjoutBloc.push(callback); - }, - cbModificationBloc: [], - onModificationBloc: function(callback) { - this.cbModificationBloc.push(callback); - }, - instancesLog: [], - ajouterInstanceLog: function(il) { - this.instancesLog.push(il); - faireCallbacks(this.cbAjoutInstanceLog, il); - }, - cbAjoutInstanceLog: [], - onAjoutInstanceLog: function(callback) { - this.cbAjoutInstanceLog.push(callback); - }, - instancesRecherche: [], - ajouterInstanceRecherche: function(ir) { - this.instancesRecherche.push(ir); - faireCallbacks(this.cbAjoutInstanceRecherche, ir); - }, - cbAjoutInstanceRecherche: [], - onAjoutInstanceRecherche: function(callback) { - this.cbAjoutInstanceRecherche.push(callback); - }, - // Suppression - supprimerBloc: function(b) { - this.blocs.remove(b); - } - }); - - var that = this; - - /* Actions */ - this.actionAucune = function() {}; - this.actionNouveauBloc = function(cDéfinition, rect, rectParent) { - that.outilZone = that.actionAucune; - if (rect.width < 10 || rect.height < 10) { - return; - } - - var mb = new MBloc(); - that.ajouterBloc(mb); - var mib = mb.demanderInstance(); - mib.rect = rect; - mib.rectParent = rectParent - cDéfinition.modèle.ajouterInstanceBloc(mib); - }; - - this.actionInstanceBloc_mBloc = null; - this.actionInstanceBloc = function(cDéfinition, rect, rectParent) { - that.outilZone = that.actionAucune; - if (rect.width < 10 || rect.height < 10 || that.actionInstanceBloc_mBloc === null) { - return; - } - - console.log(that); - var mib = that.actionInstanceBloc_mBloc.demanderInstance(); - mib.rect = rect; - mib.rectParent = rectParent - cDéfinition.modèle.ajouterInstanceBloc(mib); - }; - - /* Outils */ - this.outilZone = this.actionNouveauBloc; - - /* Scratch */ - this.mBlocScratch = new MBloc(); - this.mBlocScratch.changeNom("Scratch"); - this.ajouterBloc(this.mBlocScratch); - this.mDéfinitionScratch = new MDéfinition(); - this.mBlocScratch.ajouterDéfinition(this.mDéfinitionScratch); - - /* this.scratch = new MDéfinition(); // this.scratch.bloc == null; */ - this.barreOutils = new MBarreOutils(); - this.barreOutils.monde = this; - this.recherche = new MRecherche(); - this.recherche.monde = this; - this.log = new MLog(); - this.log.monde = this; -} - -function VMonde(appendToElement) { - $.extend(this, ( - $('#vue-monde') - .jqote({}) - .appendTo(appendToElement))); - - this.vBarreOutils = null; - this.vScratch = this.find('.scratch'); - - this.ajoutVDéfinition = function(vTitreDéfinition, vCorpsDéfinition) { - this.vScratch.replaceWith(vCorpsDéfinition); - this.vScratch = vCorpsDéfinition; - } -} - -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); - - var that = this; - - CDéfinition(this.modèle.mDéfinitionScratch, this.vue); - - this.modèle.onAjoutInstanceLog(function (instanceLog) { - var cil = new CInstanceLog(instanceLog, that.vue); - }); - - this.modèle.onAjoutInstanceRecherche(function (instanceRecherche) { - var cil = new CInstanceRecherche(instanceRecherche, that.vue); - }); -} - diff --git a/jside4/mvc/port-in-ports.js b/jside4/mvc/port-in-ports.js @@ -1,72 +0,0 @@ -function VPortInPorts(vPortsParente, vPortFille, modèle) { - var pip = $('#vue-port-in-ports').jqote({}).toDom(); - var ph1 = $('#vue-port-placeholder').jqote().toDom(); - var ph2 = $('#vue-port-placeholder').jqote().toDom(); - $.extend(this, pip.add(ph1).add(ph2)); - this.pip = pip; - this.ph1 = ph1; - this.ph2 = ph2; - - vPortsParente.vPorts.append(this.ph1).append(this.pip).append(this.ph2); - - this.pip.target = this.pip.find('.port-target'); - this.ph1.box = ph1.find('.port.placeholder.vBox'); - this.ph2.box = ph2.find('.port.placeholder.vBox'); - this.ph1.td = ph1.find('.port.placeholder.vTd'); - this.ph2.td = ph2.find('.port.placeholder.vTd'); - - this.pip.target.append(vPortFille); - this.ph1.hide(); - this.ph2.hide(); - - var a1 = ph1.box.stepAnimateClass('active', ''); - var a2 = ph2.box.stepAnimateClass('active', ''); - //var animProxy = function() {}; - var targetMiddle = 0; - var insertBefore = false; - var dragProxy = null; - - var that = this; - var upOrDown = function(e) { - if (e.pageY < targetMiddle) { - insertBefore = true; - // Glow when we get close - var h1 = that.ph1.td.height() / 2; - var dist1 = e.pageY - that.ph1.box.offY() + (that.ph1.box.height() / 2); - var factor1 = Math.min(1, Math.abs(dist1 / h1)); - a1(Math.sqrt(factor1)); - //animProxy(Math.sqrt(factor1)); - // Hide and seek - that.ph1.show(); - that.ph2.hide(); - } else { - insertBefore = false; - // Glow when we get close - var h2 = that.ph2.td.height() / 2; - var dist2 = e.pageY - that.ph2.box.offY() + (that.ph2.box.height() / 2); - var factor2 = Math.min(1, Math.abs(dist2 / h2)); - a2(Math.sqrt(factor2)); - //animProxy(Math.sqrt(factor2)); - // Hide and seek - that.ph1.hide(); - that.ph2.show(); - } - }; - - this.pip.target.bind('dropstart', function(e) { - targetMiddle = that.pip.target.offY() - + (that.pip.target.height() / 2); - /* dragProxy = e.dragProxy; - * animProxy = $(dragProxy).stepAnimateClass('active', ''); */ - $('body').bind('mousemove', upOrDown); - upOrDown(e); - }); - this.pip.target.bind('drop', function(e) { - e.dragTarget.droppedOn(modèle, 1); // il faut mettre la vraie position (utiliser insertBefore) - }); - this.pip.target.bind('dropend', function(e) { - that.ph1.hide(); - that.ph2.hide(); - $('body').unbind('mousemove', upOrDown); - }); -} -\ No newline at end of file diff --git a/jside4/mvc/port.js b/jside4/mvc/port.js @@ -1,47 +0,0 @@ -function MPort(estEntrée, mPortsParent) { - $.extend(this, { - uid: singleton.uid(), - // Propriétés - entrée: true, /* entrée / sortie */ - nom: '', - description: '', - // ? - //instances: [], - // Parents - mPorts: mPortsParent, - // Enfants - //connexions: [] - }); -} - -function VPort(vPortsParente, mPorts) { - $.extend(this, ( - $('#vue-port') - .jqote({}) - .toDom())); - - this.bind('dragstart', function(event){ - $.dropManage({ mode:'intersect', filter:'.port-target' }); - return $('#vue-port-drag').jqote({}).appendTo('body'); - }); - - this.bind('drag', function(event){ - $(event.dragProxy).position({my: 'center', at: 'center', of: event}); - return true; - }); - - this.bind('dragend', function(event){ - $(event.dragProxy).fadeOut(); - }); - - vPortsParente.addVPort(this, mPorts); -} - -function CPort(mPort, vPortsParente) { - this.modèle = mPort; - this.vue = new VPort(vPortsParente, this.modèle.mPorts); - - this.vue[0].droppedOn = function(destination, insertBefore) { // unsing this.vue[0] is a bit of a hack… - console.log("dropped on", destination, insertBefore); - }; -} diff --git a/jside4/mvc/ports.js b/jside4/mvc/ports.js @@ -1,103 +0,0 @@ -function MPorts(mBlocParent, estEntrée) { - $.extend(this, { - uid: singleton.uid(), - // Propriétés - entrée: estEntrée, /* entrée / sortie */ - // Parents - bloc: mBlocParent, - // Ajout - ports: [], - ajouterPort: function(p) { - p.bloc = this; - p.entrée = estEntrée; - this.ports.push(p); - faireCallbacks(this.cbAjoutPort, p); - //faireCallbacks(this.cbModification, this); - }, - cbAjoutPort: [], - onAjoutPort: function(callback) { - this.cbAjoutPort.push(callback); - } - }); -} - -function VPorts(vDéfinitionsParente, sens, mPorts) { - $.extend(this,( - $('#vue-ports-'+sens) - .jqote({}) - .toDom())); - - this.vVerticalBar = this.find('.ports.vVerticalBar'); - this.vPorts = this.find('.ports.vPorts'); - - var that = this; - this.addVPort = function(vPort, mPorts) { - new VPortInPorts(this, vPort, mPorts); - }; - - vDéfinitionsParente.setVPorts(this, sens); - - var ph0 = $('#vue-port-placeholder').jqote().appendTo(this.vPorts); - this.ph0 = ph0; - this.ph0.box = this.ph0.find('.port.placeholder.vBox'); - this.ph0.td = ph0.find('.port.placeholder.vTd'); - var a0 = ph0.box.stepAnimateClass('active', ''); - this.ph0.hide(); - var dragProxy = null; - - var showDistance = function (e) { - // Glow when we get close - var h0 = that.ph0.td.height() / 2; - var dist0 = e.pageY - that.ph0.box.offY() + (that.ph0.box.height() / 2); - var factor0 = Math.min(1, Math.abs(dist0 / h0)); - a0(Math.sqrt(factor0)); - }; - this.addClass('port-target'); - var dropstartFunc = function(e) { - that.ph0.show(); - $('body').bind('mousemove', showDistance); - showDistance(e); - }; - var dropFunc = function(e) { - e.dragTarget.droppedOn(mPorts, 0); // Position 0, car actuellement il n'y a rien. - }; - var dropendFunc = function(e) { - that.ph0.hide(); - $('body').unbind('mousemove', showDistance); - }; - - this.bindForDrops = function(bind) { - if (bind) { - this.bind('dropstart', dropstartFunc); - this.bind('drop', dropFunc); - this.bind('dropend', dropendFunc); - } else { - this.unbind('dropstart', dropstartFunc); - this.unbind('drop', dropFunc); - this.unbind('dropend', dropendFunc); - } - } - this.bindForDrops(true); -} - -function CPorts(mInstanceBloc, vDéfinitionsParente) { - this.modèle= mInstanceBloc; - this.mEntrée = mInstanceBloc.bloc.mPortsEntrée; - this.mSortie = mInstanceBloc.bloc.mPortsSortie; - this.vEntrée = new VPorts(vDéfinitionsParente, 'entrée', this.mEntrée); - this.vSortie = new VPorts(vDéfinitionsParente, 'sortie', this.mSortie); - - var that = this; - this.mEntrée.onAjoutPort(function(mPort) { - console.log("Ajout de port d'entrée", mPort); - that.modèle.bloc.monde.log.envoiMessage("Ajout de port d'entrée " + mPort); - new CPort(mPort, that.vEntrée); - window.setTimeout(function() {that.vEntrée.bindForDrops(false)}, 0); - }); - this.mSortie.onAjoutPort(function(mPort) { - console.log("Ajout de port de sortie", mPort); - that.modèle.bloc.monde.log.envoiMessage("Ajout de port de sortie " + mPort); - new CPort(mPort, that.vSortie); - window.setTimeout(function() {that.vSortie.bindForDrops(false);}, 0); - }); -} diff --git a/jside4/mvc/recherche.js b/jside4/mvc/recherche.js @@ -1,23 +0,0 @@ -function MRecherche() { - $.extend(this, { - uid: singleton.uid(), - - // Parents - monde: null, - - // Enfants - - // Instanciation - instances: [], - demanderInstance: function() { - var mir = new MInstanceRecherche(); - mir.mRecherche = this; - this.instances.push(mir); - return mir; - }, - - // Ajout - - // Évènements - }); -} diff --git a/jside4/mvc/resultat-recherche.js b/jside4/mvc/resultat-recherche.js @@ -1,80 +0,0 @@ -function MRésultatRecherche() { - $.extend(this, { - objet: null, - html: "", - score: 0, - position: null, - mInstanceRecherche: null - }); -} - -function VRésultatRecherche(vInstanceRechercheParente, position) { - var vrr = $('#vue-résultat-recherche').jqote({}).toDom(); - vInstanceRechercheParente.ajoutVRésultatRecherche(vrr, position); - $.extend(this,vrr); - - this.vTexte = this.find('.résultat-recherche.vTexte'); - this.vUid = this.find('.résultat-recherche.vUid'); - - var that = this; - this.animAjout = function() { - that.addClass("ajout") - .delay(2000) - .queue(function(next){ - that.removeClass("ajout", 1000); - next(); - }); - }; - - this.animSuppression = function() { - that.addClass("suppression", 500) - .height(that.height) // hauteur fixée - .animate({height: 0, opacity: 0}, 500, function() { - that.suppression(false); - }); - }; - - this.suppression = function(anim) { - if (anim) { return this.animSuppression(); } - this.remove(); - } -} - -function CRésultatRecherche(mRésultatRecherche, vInstanceRechercheParente) { - this.vue = new VRésultatRecherche(vInstanceRechercheParente, mRésultatRecherche.position); - this.setModèle = function(mRésultatRecherche) { - this.modèle = mRésultatRecherche; - this.vue.vTexte.html(this.modèle.html); - this.vue.vUid.text(this.modèle.uid); - } - - var that = this; - this.vue.toggle(function() { - var mir = that.modèle.mInstanceRecherche; - mir.ajouterRésultatSélection(that); - var monde = mir.mRecherche.monde; - monde.actionInstanceBloc_mBloc = that.modèle.objet; - monde.outilZone = monde.actionInstanceBloc; - }, function() { - var mir = that.modèle.mInstanceRecherche; - mir.supprimerRésultatSélection(that); - var monde = mir.mRecherche.monde; - monde.actionInstanceBloc_mBloc = null; - monde.outilZone = monde.actionAucune; - }); - - this.ajoutSélection = function() { - this.vue.addClass('sélectionné'); - }; - - this.suppressionSélection = function() { - this.vue.removeClass('sélectionné'); - }; - - this.suppression = function(anim) { - that.modèle.mInstanceRecherche.supprimerRésultatSélection(that); - that.vue.suppression(anim); - } - - this.setModèle(mRésultatRecherche); -} -\ No newline at end of file