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
d8c68449
Commit
d8c68449
authored
Jul 21, 2012
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add event handler for closing chatrooms. Some refactoring.
parent
b088f997
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
30 deletions
+18
-30
chat.js
chat.js
+18
-30
No files found.
chat.js
View file @
d8c68449
...
@@ -87,7 +87,7 @@ xmppchat.ChatBox = Backbone.Model.extend({
...
@@ -87,7 +87,7 @@ xmppchat.ChatBox = Backbone.Model.extend({
initialize
:
function
()
{
initialize
:
function
()
{
this
.
set
({
this
.
set
({
'
user_id
'
:
Strophe
.
getNodeFromJid
(
this
.
get
(
'
jid
'
)),
'
user_id
'
:
Strophe
.
getNodeFromJid
(
this
.
get
(
'
jid
'
)),
'
chat
_id
'
:
this
.
hash
(
this
.
get
(
'
jid
'
))
'
box
_id
'
:
this
.
hash
(
this
.
get
(
'
jid
'
))
});
});
}
}
...
@@ -295,7 +295,7 @@ xmppchat.ChatBoxView = Backbone.View.extend({
...
@@ -295,7 +295,7 @@ xmppchat.ChatBoxView = Backbone.View.extend({
closeChat
:
function
()
{
closeChat
:
function
()
{
var
that
=
this
;
var
that
=
this
;
$
(
'
#
'
+
this
.
model
.
get
(
'
chat
_id
'
)).
hide
(
'
fast
'
,
function
()
{
$
(
'
#
'
+
this
.
model
.
get
(
'
box
_id
'
)).
hide
(
'
fast
'
,
function
()
{
that
.
removeChatFromCookie
(
that
.
model
.
get
(
'
id
'
));
that
.
removeChatFromCookie
(
that
.
model
.
get
(
'
id
'
));
});
});
},
},
...
@@ -335,7 +335,7 @@ xmppchat.ChatBoxView = Backbone.View.extend({
...
@@ -335,7 +335,7 @@ xmppchat.ChatBoxView = Backbone.View.extend({
'
</form>
'
),
'
</form>
'
),
render
:
function
()
{
render
:
function
()
{
$
(
this
.
el
).
attr
(
'
id
'
,
this
.
model
.
get
(
'
chat
_id
'
));
$
(
this
.
el
).
attr
(
'
id
'
,
this
.
model
.
get
(
'
box
_id
'
));
$
(
this
.
el
).
html
(
this
.
template
(
this
.
model
.
toJSON
()));
$
(
this
.
el
).
html
(
this
.
template
(
this
.
model
.
toJSON
()));
this
.
insertClientStoredMessages
();
this
.
insertClientStoredMessages
();
return
this
;
return
this
;
...
@@ -422,7 +422,7 @@ xmppchat.RoomsPanel = Backbone.View.extend({
...
@@ -422,7 +422,7 @@ xmppchat.RoomsPanel = Backbone.View.extend({
// FIXME:
// FIXME:
var
name
=
$
(
ev
.
target
).
find
(
'
input.new-chatroom-name
'
).
val
(),
var
name
=
$
(
ev
.
target
).
find
(
'
input.new-chatroom-name
'
).
val
(),
jid
=
name
+
'
@conference.devbox
'
;
jid
=
name
+
'
@conference.devbox
'
;
xmppchat
.
chatboxesview
.
createChatRoom
(
jid
);
xmppchat
.
chatboxesview
.
renderChat
(
jid
);
}
}
});
});
...
@@ -434,7 +434,7 @@ xmppchat.SettingsPanel = Backbone.View.extend({
...
@@ -434,7 +434,7 @@ xmppchat.SettingsPanel = Backbone.View.extend({
xmppchat
.
ControlBox
=
xmppchat
.
ChatBox
.
extend
({
xmppchat
.
ControlBox
=
xmppchat
.
ChatBox
.
extend
({
initialize
:
function
()
{
initialize
:
function
()
{
this
.
set
({
this
.
set
({
'
chat
_id
'
:
'
online-users-container
'
'
box
_id
'
:
'
online-users-container
'
});
});
}
}
});
});
...
@@ -483,7 +483,7 @@ xmppchat.ChatRoom = xmppchat.ChatBox.extend({
...
@@ -483,7 +483,7 @@ xmppchat.ChatRoom = xmppchat.ChatBox.extend({
'
id
'
:
jid
,
'
id
'
:
jid
,
'
name
'
:
Strophe
.
getNodeFromJid
(
jid
),
'
name
'
:
Strophe
.
getNodeFromJid
(
jid
),
'
jid
'
:
jid
,
'
jid
'
:
jid
,
'
room
_id
'
:
this
.
hash
(
jid
)
'
box
_id
'
:
this
.
hash
(
jid
)
},
{
'
silent
'
:
true
});
},
{
'
silent
'
:
true
});
var
result
=
xmppchat
.
connection
.
muc
.
join
(
jid
,
nick
,
this
.
onMessage
,
this
.
onPresence
,
this
.
onRoomMessage
);
var
result
=
xmppchat
.
connection
.
muc
.
join
(
jid
,
nick
,
this
.
onMessage
,
this
.
onPresence
,
this
.
onRoomMessage
);
}
}
...
@@ -494,6 +494,13 @@ xmppchat.ChatRoomView = xmppchat.ChatBoxView.extend({
...
@@ -494,6 +494,13 @@ xmppchat.ChatRoomView = xmppchat.ChatBoxView.extend({
length
:
300
,
length
:
300
,
tagName
:
'
div
'
,
tagName
:
'
div
'
,
className
:
'
chatroom
'
,
className
:
'
chatroom
'
,
events
:
{
'
click .close-chatbox-button
'
:
'
closeChatRoom
'
},
closeChatRoom
:
function
()
{
this
.
closeChat
();
},
template
:
_
.
template
(
template
:
_
.
template
(
'
<div class="chat-head chat-head-chatroom">
'
+
'
<div class="chat-head chat-head-chatroom">
'
+
...
@@ -520,7 +527,7 @@ xmppchat.ChatRoomView = xmppchat.ChatBoxView.extend({
...
@@ -520,7 +527,7 @@ xmppchat.ChatRoomView = xmppchat.ChatBoxView.extend({
'
</div>
'
),
'
</div>
'
),
render
:
function
()
{
render
:
function
()
{
$
(
this
.
el
).
attr
(
'
id
'
,
this
.
model
.
get
(
'
room
_id
'
));
$
(
this
.
el
).
attr
(
'
id
'
,
this
.
model
.
get
(
'
box
_id
'
));
$
(
this
.
el
).
html
(
this
.
template
(
this
.
model
.
toJSON
()));
$
(
this
.
el
).
html
(
this
.
template
(
this
.
model
.
toJSON
()));
return
this
;
return
this
;
}
}
...
@@ -593,30 +600,20 @@ xmppchat.ChatBoxesView = Backbone.View.extend({
...
@@ -593,30 +600,20 @@ xmppchat.ChatBoxesView = Backbone.View.extend({
if
(
!
this
.
model
.
get
(
jid
))
{
if
(
!
this
.
model
.
get
(
jid
))
{
this
.
renderChat
(
jid
);
this
.
renderChat
(
jid
);
}
else
{
}
else
{
this
.
positionNe
wChat
(
jid
);
this
.
sho
wChat
(
jid
);
}
}
},
},
positionNewChat
:
function
(
jid
)
{
showChat
:
function
(
jid
)
{
var
view
=
this
.
views
[
jid
],
var
view
=
this
.
views
[
jid
];
that
=
this
,
offset
=
0
;
if
(
view
.
isVisible
())
{
if
(
view
.
isVisible
())
{
view
.
focus
();
view
.
focus
();
}
else
{
}
else
{
if
(
jid
===
'
online-users-container
'
)
{
if
(
jid
===
'
online-users-container
'
)
{
$
(
view
.
el
).
css
({
'
right
'
:
(
offset
+
'
px
'
)});
$
(
view
.
el
).
show
(
'
fast
'
,
function
()
{
$
(
view
.
el
).
show
(
'
fast
'
,
function
()
{
view
.
el
.
focus
();
view
.
el
.
focus
();
});
});
}
else
{
}
else
{
for
(
var
i
=
0
;
i
<
this
.
model
.
models
.
length
;
i
++
)
{
if
(
$
(
"
#
"
+
this
.
model
.
models
[
i
].
get
(
'
chat_id
'
)).
is
(
'
:visible
'
))
{
offset
+=
this
.
views
[
this
.
model
.
models
[
i
].
get
(
'
jid
'
)].
length
;
}
}
// $(view.el).css({'right': (offset+'px')});
$
(
view
.
el
).
show
(
'
fast
'
,
function
()
{
$
(
view
.
el
).
show
(
'
fast
'
,
function
()
{
view
.
el
.
focus
();
view
.
el
.
focus
();
view
.
scrolldown
();
view
.
scrolldown
();
...
@@ -641,18 +638,9 @@ xmppchat.ChatBoxesView = Backbone.View.extend({
...
@@ -641,18 +638,9 @@ xmppchat.ChatBoxesView = Backbone.View.extend({
xmppchat
.
roster
.
addResource
(
bare_jid
,
resource
);
xmppchat
.
roster
.
addResource
(
bare_jid
,
resource
);
},
},
createChatRoom
:
function
(
jid
)
{
var
chatroom
=
new
xmppchat
.
ChatRoom
(
jid
),
chatroomview
=
new
xmppchat
.
ChatRoomView
({
'
model
'
:
chatroom
});
this
.
views
[
chatroom
.
get
(
'
jid
'
)]
=
chatroomview
.
render
();
this
.
options
.
model
.
add
(
chatroom
);
},
initialize
:
function
()
{
initialize
:
function
()
{
this
.
options
.
model
.
on
(
"
add
"
,
function
(
item
)
{
this
.
options
.
model
.
on
(
"
add
"
,
function
(
item
)
{
this
.
positionNe
wChat
(
item
.
get
(
'
id
'
));
this
.
sho
wChat
(
item
.
get
(
'
id
'
));
},
this
);
},
this
);
this
.
views
=
{};
this
.
views
=
{};
...
...
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