Last change
on this file since 256 was
256,
checked in by hendrikvanantwerpen, 13 years ago
|
Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).
|
File size:
1.2 KB
|
Line | |
---|
1 | dojo.provide("dojox.xmpp.widget.ChatSession"); |
---|
2 | |
---|
3 | dojo.require("dijit.layout.LayoutContainer"); |
---|
4 | dojo.require("dijit._Templated"); |
---|
5 | |
---|
6 | dojo.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.