Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
4b6f2dfb
Commit
4b6f2dfb
authored
Jul 19, 2012
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add separate view classes for the users/chatrooms/settings panels
parent
5f440dc7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
57 deletions
+68
-57
chat.js
chat.js
+68
-57
No files found.
chat.js
View file @
4b6f2dfb
var
helpers
=
(
function
(
helpers
)
{
helpers
.
hash
=
function
(
str
)
{
// FIXME
if
(
str
==
'
online-users-container
'
)
{
return
str
;
}
var
shaobj
=
new
jsSHA
(
str
);
return
shaobj
.
getHash
(
"
HEX
"
);
};
return
helpers
;
})(
helpers
||
{});
var
xmppchat
=
(
function
(
jarnxmpp
,
$
,
console
)
{
var
ob
=
jarnxmpp
;
/* FIXME: XEP-0136 specifies 'urn:xmpp:archive' but the mod_archive_odbc
...
...
@@ -86,33 +73,6 @@ var xmppchat = (function (jarnxmpp, $, console) {
xmppchat
.
connection
.
sendIQ
(
iq
,
callback
);
});
};
ob
.
Taskbuffer
=
(
function
(
$
)
{
// Executes tasks one after another (i.e next task is started only when
// the previous one has been completed).
buffer
=
{};
// Tasks must be objects with keys: 'that', 'method' and 'parameters'
// 'that' the context for the method, while 'parameters' is the list of arguments
// passed to it.
buffer
.
tasks
=
[];
buffer
.
deferred
=
$
.
when
();
buffer
.
handleTasks
=
function
()
{
var
task
;
// If the current deferred task is resolved and there are more tasks
if
(
buffer
.
deferred
.
isResolved
()
&&
buffer
.
tasks
.
length
>
0
)
{
// Get the next task in the queue and set the new deferred.
task
=
buffer
.
tasks
.
shift
();
buffer
.
deferred
=
$
.
when
(
task
.
method
.
apply
(
task
.
that
,
task
.
parameters
));
if
(
buffer
.
tasks
.
length
>
0
)
{
buffer
.
deferred
.
done
(
buffer
.
handleTasks
);
}
}
};
return
buffer
;
})(
jQuery
);
return
ob
;
})(
jarnxmpp
||
{},
jQuery
,
console
||
{
log
:
function
(){}});
...
...
@@ -406,21 +366,9 @@ xmppchat.ChatBoxView = Backbone.View.extend({
}
});
xmppchat
.
ControlBox
=
xmppchat
.
ChatBox
.
extend
({
initialize
:
function
()
{
this
.
set
({
'
chat_id
'
:
'
online-users-container
'
});
}
});
xmppchat
.
ControlBoxView
=
xmppchat
.
ChatBoxView
.
extend
({
el
:
'
#online-users-container
'
,
xmppchat
.
ContactsPanel
=
Backbone
.
View
.
extend
({
el
:
'
#users
'
,
events
:
{
'
click a.close-controlbox-button
'
:
'
closeChat
'
,
'
click div.add-xmpp-contact
'
:
'
toggleContactForm
'
,
'
submit form.search-xmpp-contact
'
:
'
searchContacts
'
,
'
click a.subscribe-to-user
'
:
'
subscribeToContact
'
...
...
@@ -461,10 +409,41 @@ xmppchat.ControlBoxView = xmppchat.ChatBoxView.extend({
});
$
(
ev
.
target
).
parent
().
remove
();
$
(
'
form.search-xmpp-contact
'
).
hide
();
}
});
xmppchat
.
RoomsPanel
=
Backbone
.
View
.
extend
({
el
:
'
#chatrooms
'
,
initialize
:
function
()
{
}
});
xmppchat
.
SettingsPanel
=
Backbone
.
View
.
extend
({
el
:
'
#settings
'
});
xmppchat
.
ControlBox
=
xmppchat
.
ChatBox
.
extend
({
initialize
:
function
()
{
this
.
set
({
'
chat_id
'
:
'
online-users-container
'
});
}
});
xmppchat
.
ControlBoxView
=
xmppchat
.
ChatBoxView
.
extend
({
el
:
'
#online-users-container
'
,
events
:
{
'
click a.close-controlbox-button
'
:
'
closeChat
'
},
initialize
:
function
()
{
// Override to avoid chatbox's initialization.
var
userspanel
;
$
(
'
ul.tabs
'
).
tabs
(
'
div.panes > div
'
);
this
.
contactspanel
=
new
xmppchat
.
ContactsPanel
();
this
.
roomspanel
=
new
xmppchat
.
RoomsPanel
();
this
.
settingspanel
=
new
xmppchat
.
SettingsPanel
();
},
render
:
function
()
{
...
...
@@ -477,9 +456,41 @@ xmppchat.ControlBoxView = xmppchat.ChatBoxView.extend({
}
});
xmppchat
.
ChatBoxes
=
Backbone
.
Collection
.
extend
({
xmppchat
.
ChatRoom
=
Backbone
.
Model
.
extend
();
xmppchat
.
ChatRoomView
=
Backbone
.
Model
.
extend
({
tagName
:
'
div
'
,
className
:
'
chatroom
'
,
template
:
_
.
template
(
'
<div class="chat-head chat-head-chatroom">
'
+
'
<div id="toolbar">
'
+
'
<input id="leave" type="button" value="Leave Room" disabled="disabled">
'
+
'
</div>
'
+
'
</div>
'
+
'
<div>
'
+
'
<div id="chat-area">
'
+
'
<div>
'
+
'
<div id="room-name"></div>
'
+
'
<div id="room-topic"></div>
'
+
'
</div>
'
+
'
<div id="chat">
'
+
'
</div>
'
+
'
<textarea
'
+
'
type="text"
'
+
'
class="chat-textarea"
'
+
'
placeholder="Message"/>
'
+
'
</div>
'
+
'
<div id="participants">
'
+
'
<ul id="participant-list"></ul>
'
+
'
</div>
'
+
'
</div>
'
)
});
xmppchat
.
ChatBoxes
=
Backbone
.
Collection
.
extend
();
xmppchat
.
ChatBoxesView
=
Backbone
.
View
.
extend
({
chatbox_width
:
212
,
...
...
@@ -505,6 +516,7 @@ xmppchat.ChatBoxesView = Backbone.View.extend({
},
createChat
:
function
(
jid
)
{
var
chatbox
;
if
(
jid
===
'
online-users-container
'
)
{
chatbox
=
new
xmppchat
.
ControlBox
({
'
id
'
:
jid
,
'
jid
'
:
jid
});
view
=
new
xmppchat
.
ControlBoxView
({
...
...
@@ -1087,7 +1099,6 @@ $(document).ready(function () {
$toggle
=
$
(
'
a#toggle-online-users
'
);
$toggle
.
unbind
(
'
click
'
);
$
(
'
ul.tabs
'
).
tabs
(
'
div.panes > div
'
);
xmppchat
.
username
=
chatdata
.
attr
(
'
username
'
);
xmppchat
.
base_url
=
chatdata
.
attr
(
'
base_url
'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment