Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / xmpp / widget / ChatSession.js @ 12

History | View | Annotate | Download (1.53 KB)

1
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6

    
7

    
8
if(!dojo._hasResource["dojox.xmpp.widget.ChatSession"]){
9
dojo._hasResource["dojox.xmpp.widget.ChatSession"]=true;
10
dojo.provide("dojox.xmpp.widget.ChatSession");
11
dojo.declare("dojox.xmpp.widget.ChatSession",[dijit.layout.LayoutContainer,dijit._Templated],{templateString:dojo.cache("dojox.xmpp.widget","templates/ChatSession.html","<div>\n<div dojoAttachPoint=\"messages\" dojoType=\"dijit.layout.ContentPane\" layoutAlign=\"client\" style=\"overflow:auto\">\n</div>\n<div dojoType=\"dijit.layout.ContentPane\" layoutAlign=\"bottom\" style=\"border-top: 2px solid #333333; height: 35px;\"><input dojoAttachPoint=\"chatInput\" dojoAttachEvent=\"onkeypress: onKeyPress\" style=\"width: 100%;height: 35px;\" /></div>\n</div>\n"),enableSubWidgets:true,widgetsInTemplate:true,widgetType:"ChatSession",chatWith:null,instance:null,postCreate:function(){
12
},displayMessage:function(_1,_2){
13
if(_1){
14
var _3=_1.from?this.chatWith:"me";
15
this.messages.domNode.innerHTML+="<b>"+_3+":</b> "+_1.body+"<br/>";
16
this.goToLastMessage();
17
}
18
},goToLastMessage:function(){
19
this.messages.domNode.scrollTop=this.messages.domNode.scrollHeight;
20
},onKeyPress:function(e){
21
var _4=e.keyCode||e.charCode;
22
if((_4==dojo.keys.ENTER)&&(this.chatInput.value!="")){
23
this.instance.sendMessage({body:this.chatInput.value});
24
this.displayMessage({body:this.chatInput.value},"out");
25
this.chatInput.value="";
26
}
27
}});
28
}