FIX optimisation de certaine requête : il faut trier après pas avant, banane !
[euphorik.git] / js / pageMinichat.js
index 07d5d8f..adf5c5a 100755 (executable)
@@ -87,26 +87,11 @@ PageMinichat.prototype.charger = function()
          $(this).click(
             function(event)
             {
-               thisPage.util.replaceSelection($("form input.message")[0], thisPage.formateur.smiles[$(this).attr("class")][0].source.replace(/\\/g, ""))
-            }
-         )
-         .hover(
-            function()
-            {
-               $(this).animate(
-                  {
-                     opacity: 1
-                  }, 200
-               )
-            },
-            function()
-            {
-               $(this).animate(
-                  {
-                     opacity: opacityBase
-                  }, 200
-               )
+               thisPage.util.replaceSelection($("form#posterMessage input.message")[0], thisPage.formateur.smiles[$(this).attr("class")][0].source.replace(/\\/g, ""))
             }
+         ).hover(
+            function() { $(this).animate({opacity: 1}, 200) },
+            function() { $(this).animate({opacity: opacityBase}, 200) }
          )
       }
    )
@@ -543,12 +528,6 @@ Conversation.prototype.flush = function(funClickOuvrirConv)
             
          messagePair = !messagePair
       }
-      
-   // enlève les messages exedentaires
-   var nbMessagesAffiche = $("#conversations #" + this.getId() + " .message").size()
-   
-   if (nbMessagesAffiche > this.nbMessageMax)
-      $("#conversations #" + this.getId() + " .message").slice(this.nbMessageMax, nbMessagesAffiche).empty()
    
    var DOM = $(XHTML)
    DOM.each(
@@ -618,7 +597,7 @@ Conversation.prototype.flush = function(funClickOuvrirConv)
          $(this).click(
             function(event)
             {
-               if ($(event.target).is("a") || $(event.target).parents().is("#outilsBan")) return
+               if ($(event.target).is("a") || $(event.target).parents("#outilsBan").length > 0) return
                
                // l'id du message
                var idMess = $(this).attr("id").substr(4)
@@ -654,6 +633,11 @@ Conversation.prototype.flush = function(funClickOuvrirConv)
    )
    DOM.prependTo("#conversations #" + this.getId())
    
+   // enlève les messages exedentaires
+   var nbMessagesAffiche = $("#conversations #" + this.getId() + " .message").size()   
+   if (nbMessagesAffiche > this.nbMessageMax)
+      $("#conversations #" + this.getId() + " .message").slice(this.nbMessageMax, nbMessagesAffiche).remove()
+   
    if (this.messages.length > 0)
       this.idDernierMessageAffiche = this.messages[this.messages.length-1].id
 }
@@ -807,7 +791,7 @@ Messages.prototype.ajouterMessage = function(element, numConversation)
          function(num) // insertion du lien vers la conversation
          {
                thisPage.util.replaceSelection(
-                  $("form input.message")[0],
+                  $("form#posterMessage input.message")[0],
                   "{" + thisMessages.client.conversations[num-1].root.toString(36) + "}"
                )
          }
@@ -878,7 +862,7 @@ Messages.prototype.ajusterLargeurConversations = function()
    var largeurPourcent = (100 / this.conversations.length)   \r
    // le "- 0.01" evite que IE se chie dessus lamentablement et affiche les conversations les unes au dessus des autres\r
    if($.browser["msie"])\r
-      largeurPourcent -= 0.01
+      largeurPourcent -= 0.05
    $("#conversations .conversation").css("width", largeurPourcent + "%")
 }
 
@@ -935,11 +919,11 @@ Messages.prototype.rafraichirMessages = function(vider)
    if (vider)
       for (var i = 0; i < this.conversations.length; i++)
          this.conversations[i].idDernierMessageAffiche = 0
-         
+   
    this.pageEvent.waitEvent(
       function() { return thisMessages.getJSONrafraichirMessages() },
       function(data)
-      {
+      {   
          if (vider)
          {
             thisMessages.viderMessages()
@@ -961,7 +945,7 @@ Messages.prototype.rafraichirMessages = function(vider)
                $("#trollCourant .troll a[@rel*=lightbox]").lightBox()
                break
                
-            case "new_messages" :                        
+            case "new_messages" :   
                // ajoute les messages reçus à leur conversation respective
                for (var numConv = 0; numConv < data["conversations"].length; numConv++)
                {