X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=js%2FpageMinichat.js;h=c118c5415e72986b189e5bbafa2c363926d6418a;hb=a67d59e51fcca70497d1132327e14975be9383f3;hp=9e042e43e8389e396f5998b25941ea3fca669704;hpb=5f49b7e6af9be3e2415136013370af4ac99d59da;p=euphorik.git diff --git a/js/pageMinichat.js b/js/pageMinichat.js index 9e042e4..c118c54 100755 --- a/js/pageMinichat.js +++ b/js/pageMinichat.js @@ -14,14 +14,13 @@ function PageMinichat(client, formateur, util) PageMinichat.prototype.contenu = function() { -// \ return '\ -
\
\

\ \ \ \ + \ \

\
\ @@ -41,8 +40,10 @@ PageMinichat.prototype.charger = function() this.util.setCaretToEnd(jQuery("form input.message")[0]) + // + jQuery("body").append("
") // affichage des smiles - jQuery("#smiles").html(this.formateur.getSmilesHTML()).children().each( + jQuery("#smiles").append(this.formateur.getSmilesHTML()).children().each( function(i) { var opacityBase = jQuery(this).css("opacity") @@ -72,12 +73,28 @@ PageMinichat.prototype.charger = function() ) } ) + jQuery("form button.smiles").hover( + function(e) + { + var offset = jQuery(e.target).offset() + jQuery("#smiles").css("top", offset.top).css("left", offset.left).show() + }, + function(e){} + ) + jQuery("#smiles").hover( + function(){}, + function(e) + { + jQuery("#smiles").hide() + } + ) + //
- /// événements - jQuery("form button.return").click( + // événements + var nouveauMessage = function() - { - // captcha anti bot + { + // captcha anti bot if (jQuery("form input.captcha").val() != "") return thisPage.envoyerMessage( @@ -87,9 +104,19 @@ PageMinichat.prototype.charger = function() jQuery("form input.message")[0].focus() } + + jQuery("form").keypress( + function(e) + { + if (e.which == 13) // return + nouveauMessage() + } ) + + jQuery("form button.return").click(nouveauMessage) + // interdiction de submiter le formulaire - jQuery("form").submit(function(){return false}) + jQuery("form").submit(function(){ return false}) jQuery("input.pseudo").click( function() @@ -105,6 +132,8 @@ PageMinichat.prototype.decharger = function() { //alert(this.attenteCourante) this.messages.stopAttenteCourante() + + jQuery("body #smiles").remove() } PageMinichat.prototype.getJSONMessage = function(pseudo, message, repondA) @@ -413,7 +442,7 @@ Conversation.prototype.viderMessages = function() * d'afficher les messages non-affichés. * @param funClickExtract fonction (fun(numMess)) appellée lors du clic sur un bouton "extraire" */ -Conversation.prototype.flush = function(funClickExtract, funClickLienConv) +Conversation.prototype.flush = function(funClickOuvrirConv) { var thisConversation = this @@ -431,8 +460,9 @@ Conversation.prototype.flush = function(funClickExtract, funClickLienConv) // construit l'identifiant de la personne var identifiant = - this.client.nickFormat == "nick" ? message.pseudo : - (this.client.nickFormat == "login" ? message.login : message.pseudo + "(" + message.login +")" ) + this.client.nickFormat == "nick" ? this.formateur.traitementComplet(message.pseudo) : + (this.client.nickFormat == "login" ? this.formateur.traitementComplet(message.login) : + this.formateur.traitementComplet(message.pseudo) + "(" + this.formateur.traitementComplet(message.login) +")" ) var XHTMLrepondA = "" for (var id in message.repondA) @@ -448,7 +478,7 @@ Conversation.prototype.flush = function(funClickExtract, funClickLienConv) "\">" + "
>
" + "[" + message.date + "]" + - "" + this.formateur.traitementComplet(identifiant) + ":" + + "" + identifiant + ":" + XHTMLrepondA + "" + (message.systeme ? this.formateur.remplacerBalisesHTML(message.contenu) : this.formateur.traitementComplet(message.contenu, message.pseudo)) + "" + "" @@ -477,7 +507,7 @@ Conversation.prototype.flush = function(funClickExtract, funClickLienConv) { // FIXME : ya pas mieux ? var racine = jQuery(event.target).text() - funClickLienConv(parseInt(racine.substring(1, racine.length - 1), 36)) + funClickOuvrirConv(parseInt(racine.substring(1, racine.length - 1), 36)) return false } ) @@ -493,7 +523,7 @@ Conversation.prototype.flush = function(funClickExtract, funClickLienConv) // extraction d'une conversation if (jQuery(event.target).is(".extraire")) { - funClickExtract(parseInt(idMess, 36)) + funClickOuvrirConv(parseInt(idMess, 36)) return } @@ -520,8 +550,8 @@ Conversation.prototype.flush = function(funClickExtract, funClickLienConv) } ) - this.idDernierMessageAffiche = jQuery("#conversations #" + this.getId() + " div:first").attr("id") - this.idDernierMessageAffiche = (this.idDernierMessageAffiche == undefined ? 0 : parseInt(this.idDernierMessageAffiche, 36)) + if (this.messages.length > 0) + this.idDernierMessageAffiche = this.messages[this.messages.length-1].id } /** @@ -757,20 +787,21 @@ Messages.prototype.flush = function(numConv) var thisMessages = this this.conversations[numConv].flush( - // fonction appelée lors de la demande d'extraction d'une conversation - function(idMess) - { - if (thisMessages.client.ajouterConversation(idMess)) - thisMessages.rafraichirMessages(true) - }, function(racine) // appelé lorsqu'un utilisateur click sur un lien vers une conversation { - if (thisMessages.client.ajouterConversation(racine)) - thisMessages.rafraichirMessages(true) + thisMessages.ouvrirConversation(racine) } ) } +Messages.prototype.ouvrirConversation = function(racine) +{ + if (this.client.ajouterConversation(racine)) + this.rafraichirMessages(true) + else + this.util.messageDialogue("Cette conversation est déjà ouverte") +} + Messages.prototype.viderMessages = function() { // Obsolète