ADD possibilité de cacher les infos bulles
[euphorik.git] / js / euphorik.js
index 1b78ba8..ca84a02 100755 (executable)
@@ -90,7 +90,10 @@ function Util(formateur)
       $("#info").slideUp(50) 
    })
    
+   $("body").append('<div id="flecheBulle"></div>').append('<div id="messageBulle"><p></p></div>')
+   
    this.formateur = formateur
+   this.bulleActive = true
 }
 
 var messageType = {informatif: 0, question: 1, erreur: 2}
@@ -140,19 +143,25 @@ Util.prototype.messageDialogue = function(message, type, boutons, formate)
   */
 Util.prototype.infoBulle = function(message, element)
 {
-   var virerMess = function()
+   var thisUtil = this
+
+   var cacherBulle = function()
       {   
-         $("#flecheBulle").remove()
-         $("#messageBulle").remove()
+         $("#flecheBulle").hide()
+         $("#messageBulle").hide()
       }
 
-   element.click(virerMess)
-
    element.hover(
       function(e)
       {
-         f = $('<div id="flecheBulle"></div>').appendTo("body")
-         m = $('<div id="messageBulle"><p>' + message + '</p></div>').appendTo("body")
+         if (!thisUtil.bulleActive)
+            return
+         
+         var m = $("#messageBulle")
+         var f = $("#flecheBulle")
+         
+         $("p", m).html(message)
+      
          var positionFleche = {
             left : element.offset().left + element.width() / 2 - f.width() / 2,
             top : element.offset().top - f.height()
@@ -173,8 +182,8 @@ Util.prototype.infoBulle = function(message, element)
          m.css("top", positionMessage.top).css("left", positionMessage.left).show()
          f.css("top", positionFleche.top).css("left", positionFleche.left).show()
       },
-      virerMess
-   )
+      cacherBulle
+   ).click(cacherBulle)
 }
 
 /**
@@ -522,6 +531,8 @@ Client.prototype.resetDonneesPersonnelles = function()
    this.email = ""\r
    this.css = $("link#cssPrincipale").attr("href")
    this.nickFormat = "nick"
+   this.viewTimes = true
+   this.viewTooltips = true
    this.cookie = undefined
    
    this.pagePrincipale = 1
@@ -667,6 +678,8 @@ Client.prototype.getJSONProfile = function()
       "email" : this.email,
       "css" : this.css,
       "nick_format" : this.nickFormat,
+      "view_times" : this.viewTimes,
+      "view_tooltips" : this.viewTooltips,
       "main_page" : this.pagePrincipale < 1 ? 1 : this.pagePrincipale,
       "conversations" : this.getJSONConversations()
    }
@@ -808,12 +821,16 @@ Client.prototype.chargerDonnees = function(data)
       this.email = data["email"]\r
       this.setCss(data["css"])
       this.nickFormat = data["nick_format"]
+      this.viewTimes = data["view_times"]
+      this.viewTooltips = data["view_tooltips"]
       
       // la page de la conversation principale
       this.pagePrincipale = data["main_page"] == undefined ? 1 : data["main_page"]
       
       // les conversations
       this.conversations = data["conversations"]
+      
+      this.majBulle()
    }
 }
 
@@ -850,6 +867,10 @@ Client.prototype.flush = function(async)
                   thisClient.util.messageDialogue(data["error_message"])
                   ok = false
                }
+               else
+               {
+                  thisClient.majBulle()
+               }
             }
       }
    )
@@ -886,6 +907,14 @@ Client.prototype.majMenu = function()
    }
 }
 
+/**
+  * Met à jour l'affichage des infos bulles en fonction du profile.
+  */
+Client.prototype.majBulle = function()
+{
+   this.util.bulleActive = this.viewTooltips
+}
+
 Client.prototype.slap = function(userId, raison)
 {
    var thisClient = this