source: Dev/trunk/src/client/dojox/xmpp/widget/ChatSession.js @ 487

Last change on this file since 487 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 1.2 KB
Line 
1dojo.provide("dojox.xmpp.widget.ChatSession");
2
3dojo.require("dijit.layout.LayoutContainer");
4dojo.require("dijit._Templated");
5
6dojo.declare("dojox.xmpp.widget.ChatSession",
7        [dijit.layout.LayoutContainer, dijit._Templated],
8        {
9                        templateString: dojo.cache("dojox.xmpp.widget", "templates/ChatSession.html"),
10                        enableSubWidgets: true,
11                        widgetsInTemplate: true,
12                       
13                        widgetType: "ChatSession",
14                        chatWith: null,
15                        instance: null,
16                        postCreate: function(){
17                                //console.log("Neato!");
18                        },
19       
20                        displayMessage: function(message, type) {
21                                //console.log("displayMessage", this, message);
22                                if(message) {
23                                        var name =  message.from ? this.chatWith : "me";
24                                        this.messages.domNode.innerHTML += "<b>" + name + ":</b> " +   message.body + "<br/>";
25                                        this.goToLastMessage();
26                                }
27                               
28                        },
29                       
30                        goToLastMessage: function() {
31                                this.messages.domNode.scrollTop = this.messages.domNode.scrollHeight;
32                        },
33                       
34                        onKeyPress: function(e){
35                                var key = e.keyCode || e.charCode;
36                                if ((key == dojo.keys.ENTER) && (this.chatInput.value != "")){
37                                        this.instance.sendMessage({body: this.chatInput.value});
38                                        this.displayMessage( {body: this.chatInput.value}, "out");
39                                        this.chatInput.value = "";
40                                }
41                        }
42});
Note: See TracBrowser for help on using the repository browser.