X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=js%2Feuphorik.js;h=1b78ba8294365fa1a2cf0e6dbc9cae9e5cd7fd73;hb=874434add86031d5f23991e78fb2072eac996458;hp=36a2f06de77d99f6d7eb95da3ddf217698cb1c0c;hpb=327c3bd99f586f3cf3af55f9adb10a71eb78cdd4;p=euphorik.git
diff --git a/js/euphorik.js b/js/euphorik.js
index 36a2f06..1b78ba8 100755
--- a/js/euphorik.js
+++ b/js/euphorik.js
@@ -1,4 +1,20 @@
// coding: utf-8
+// Copyright 2008 Grégory Burri
+//
+// This file is part of Euphorik.
+//
+// Euphorik is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Euphorik is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Euphorik. If not, see .
/**
* Contient la base javascript pour le site euphorik.ch.
@@ -118,6 +134,49 @@ Util.prototype.messageDialogue = function(message, type, boutons, formate)
this.timeoutMessageDialogue = setTimeout(fermer, conf.tempsAffichageMessageDialogue)
}
+/**
+ * Affiche un info bulle lorsque le curseur survole l'élément donné.
+ * FIXME : le width de element ne tient pas compte du padding !?
+ */
+Util.prototype.infoBulle = function(message, element)
+{
+ var virerMess = function()
+ {
+ $("#flecheBulle").remove()
+ $("#messageBulle").remove()
+ }
+
+ element.click(virerMess)
+
+ element.hover(
+ function(e)
+ {
+ f = $('
').appendTo("body")
+ m = $('').appendTo("body")
+ var positionFleche = {
+ left : element.offset().left + element.width() / 2 - f.width() / 2,
+ top : element.offset().top - f.height()
+ }
+ var positionMessage = {
+ left : element.offset().left + element.width() / 2 - m.width() / 2,
+ top : element.offset().top - f.height() - m.height()
+ }
+ var depassementDroit = (positionMessage.left + m.width()) - $("body").width()
+ if (depassementDroit > 0)
+ positionMessage.left -= depassementDroit
+ else
+ {
+ if (positionMessage.left < 0)
+ positionMessage.left = 0
+ }
+
+ m.css("top", positionMessage.top).css("left", positionMessage.left).show()
+ f.css("top", positionFleche.top).css("left", positionFleche.left).show()
+ },
+ virerMess
+ )
+}
+
/**
* Utilisé pour l'envoie de donnée avec la méthode ajax de jQuery.
*/
@@ -247,8 +306,8 @@ Pages.prototype.afficherPage = function(nomPage, forcerChargement)
if (this.pageCourante != null && this.pageCourante.decharger)
this.pageCourante.decharger()
- $("#menu div").removeClass("courante")
- $("#menu div." + nomPage).addClass("courante")
+ $("#menu li").removeClass("courante")
+ $("#menu li." + nomPage).addClass("courante")
this.pageCourante = page
$("#page").html(this.pageCourante.contenu()).removeClass().addClass(this.pageCourante.nom)
@@ -449,6 +508,9 @@ function Client(util)
this.resetDonneesPersonnelles()
this.setStatut(statutType.deconnected)
+
+ // si true alors chaque modification du client est mémorisé sur le serveur
+ this.autoflush = $.browser["opera"]
}
Client.prototype.resetDonneesPersonnelles = function()
@@ -478,7 +540,9 @@ Client.prototype.setCss = function(css)
this.css = css
$("link#cssPrincipale").attr("href", this.css)
- this.majMenu()
+ this.majMenu()
+
+ if (this.autoflush) this.flush(true)
}
Client.prototype.pageSuivante = function(numConv)
@@ -531,7 +595,10 @@ Client.prototype.ajouterConversation = function(racine)
if (this.conversations[i].root == racine)
return false
- this.conversations.push({root : racine, page : 1})
+ this.conversations.push({root : racine, page : 1})
+
+ if (this.autoflush) this.flush(true)
+
return true
}
@@ -542,7 +609,9 @@ Client.prototype.supprimerConversation = function(num)
// décalage TODO : supprimer le dernier élément
for (var i = num; i < this.conversations.length - 1; i++)
this.conversations[i] = this.conversations[i+1]
- this.conversations.pop()
+ this.conversations.pop()
+
+ if (this.autoflush) this.flush(true)
}
Client.prototype.getJSONLogin = function(login, password)
@@ -888,6 +957,9 @@ function PageEvent(page, util)
// l'objet JSONHttpRequest représentant la connexion d'attente
this.attenteCourante = null
+
+ // le multhreading du pauvre, merci javascript de m'offrire autant de primitives pour la gestion de la concurrence...
+ this.stop = false
}
/**
@@ -895,8 +967,12 @@ function PageEvent(page, util)
*/
PageEvent.prototype.stopAttenteCourante = function()
{
+ this.stop = true
+
if (this.attenteCourante != null)
+ {
this.attenteCourante.abort()
+ }
}
/**
@@ -906,11 +982,13 @@ PageEvent.prototype.stopAttenteCourante = function()
*/
PageEvent.prototype.waitEvent = function(funSend, funReceive)
{
- var thisPageEvent = this
-
this.stopAttenteCourante()
+
+ this.stop = false
+
+ var thisPageEvent = this
- // on doit conserver l'ordre des valeurs de l'objet JSON (le serveur les veux dans l'ordre définit dans le protocole)
+ // on doit conserver l'ordre des valeurs de l'objet JSON (le serveur les veut dans l'ordre définit dans le protocole)
// TODO : ya pas mieux ?
var dataToSend =
{
@@ -922,6 +1000,7 @@ PageEvent.prototype.waitEvent = function(funSend, funReceive)
dataToSend[v] = poulpe[v]
;;; dumpObj(dataToSend)
+
this.attenteCourante = jQuery.ajax({
type: "POST",
url: "request",
@@ -935,15 +1014,24 @@ PageEvent.prototype.waitEvent = function(funSend, funReceive)
funReceive(data)
// rappel de la fonction dans 100 ms
- setTimeout(function(){ thisPageEvent.waitEvent(funSend, funReceive) }, 100);
+ setTimeout(function(){ thisPageEvent.waitEvent2(funSend, funReceive) }, 100)
},
error:
function(XMLHttpRequest, textStatus, errorThrown)
{
- setTimeout(function(){ thisPageEvent.waitEvent(funSend, funReceive) }, 1000);
+ setTimeout(function(){ thisPageEvent.waitEvent2(funSend, funReceive) }, 1000)
}
})
+}
+/**
+ * Si un stopAttenteCourante survient un peu n'importe quand il faut imédiatement arreter de boucler.
+ */
+PageEvent.prototype.waitEvent2 = function(funSend, funReceive)
+{
+ if (this.stop)
+ return
+ this.waitEvent(funSend, funReceive)
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1003,4 +1091,4 @@ $(document).ready(
pages.ajouterPage(new PageAbout(client, formateur, util))
pages.afficherPage("minichat")
}
-)
\ No newline at end of file
+)