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
0640dd5a
Commit
0640dd5a
authored
Jul 25, 2014
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up the initialize method of RosterView
by moving event handers out
parent
434e21d0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
28 deletions
+37
-28
converse.js
converse.js
+28
-25
index.html
index.html
+1
-1
spec/controlbox.js
spec/controlbox.js
+8
-2
No files found.
converse.js
View file @
0640dd5a
...
...
@@ -645,8 +645,7 @@
}
});
this
.
Message
=
Backbone
.
Model
.
extend
();
this
.
Message
=
Backbone
.
Model
;
this
.
Messages
=
Backbone
.
Collection
.
extend
({
model
:
converse
.
Message
});
...
...
@@ -3238,29 +3237,11 @@
},
initialize
:
function
()
{
this
.
model
.
on
(
"
add
"
,
function
(
item
)
{
this
.
addRosterItemView
(
item
).
addRosterItem
(
item
).
updateRoster
();
if
(
item
.
get
(
'
is_last
'
))
{
this
.
sortRoster
().
showRoster
();
}
if
(
!
item
.
get
(
'
vcard_updated
'
))
{
// This will update the vcard, which triggers a change
// request which will rerender the roster item.
converse
.
getVCard
(
item
.
get
(
'
jid
'
));
}
},
this
);
this
.
model
.
on
(
'
change
'
,
function
(
item
)
{
if
((
_
.
size
(
item
.
changed
)
===
1
)
&&
_
.
contains
(
_
.
keys
(
item
.
changed
),
'
sorted
'
))
{
return
;
}
this
.
updateChatBox
(
item
).
renderRosterItem
(
item
).
updateRoster
();
if
(
item
.
changed
.
chat_status
)
{
// A changed chat status implies a new sort order
this
.
sortRoster
();
}
},
this
);
this
.
model
.
on
(
"
remove
"
,
function
(
item
)
{
this
.
removeRosterItemView
(
item
);
},
this
);
this
.
model
.
on
(
"
destroy
"
,
function
(
item
)
{
this
.
removeRosterItemView
(
item
);
},
this
);
this
.
model
.
on
(
"
reset
"
,
function
()
{
this
.
removeAllRosterItemViews
();
},
this
);
this
.
model
.
on
(
"
add
"
,
this
.
onAdd
,
this
);
this
.
model
.
on
(
'
change
'
,
this
.
onChange
,
this
);
this
.
model
.
on
(
"
remove
"
,
this
.
removeRosterItemView
,
this
);
this
.
model
.
on
(
"
destroy
"
,
this
.
removeRosterItemView
,
this
);
this
.
model
.
on
(
"
reset
"
,
this
.
removeAllRosterItemViews
,
this
);
this
.
render
();
this
.
model
.
fetch
({
add
:
true
});
// Get the cached roster items from localstorage
},
...
...
@@ -3288,6 +3269,28 @@
this
.
$el
.
hide
().
html
(
roster_markup
);
},
onAdd
:
function
(
item
)
{
this
.
addRosterItemView
(
item
).
addRosterItem
(
item
).
updateRoster
();
if
(
item
.
get
(
'
is_last
'
))
{
this
.
sortRoster
().
showRoster
();
}
if
(
!
item
.
get
(
'
vcard_updated
'
))
{
// This will update the vcard, which triggers a change
// request which will rerender the roster item.
converse
.
getVCard
(
item
.
get
(
'
jid
'
));
}
},
onChange
:
function
(
item
)
{
if
((
_
.
size
(
item
.
changed
)
===
1
)
&&
_
.
contains
(
_
.
keys
(
item
.
changed
),
'
sorted
'
))
{
return
;
}
this
.
updateChatBox
(
item
).
renderRosterItem
(
item
).
updateRoster
();
if
(
item
.
changed
.
chat_status
)
{
// A changed chat status implies a new sort order
this
.
sortRoster
();
}
},
updateChatBox
:
function
(
item
,
changed
)
{
var
chatbox
=
converse
.
chatboxes
.
get
(
item
.
get
(
'
jid
'
)),
changes
=
{};
...
...
index.html
View file @
0640dd5a
...
...
@@ -226,7 +226,7 @@
allow_otr
:
true
,
auto_list_rooms
:
false
,
auto_subscribe
:
false
,
bosh_service_url
:
'
http://
192.168.56.2:889
0/http-bind
'
,
// Please use this connection manager only for testing purposes
bosh_service_url
:
'
http://
conversejs.containers:528
0/http-bind
'
,
// Please use this connection manager only for testing purposes
debug
:
true
,
hide_muc_server
:
false
,
i18n
:
locales
[
'
en
'
],
// Refer to ./locale/locales.js to see which locales are supported
...
...
spec/controlbox.js
View file @
0640dd5a
...
...
@@ -440,6 +440,7 @@
describe
(
"
Requesting Contacts
"
,
$
.
proxy
(
function
()
{
beforeEach
(
$
.
proxy
(
function
()
{
runs
(
function
()
{
utils
.
clearBrowserStorage
();
converse
.
rosterview
.
model
.
reset
();
utils
.
createContacts
(
'
requesting
'
).
openControlBox
();
});
...
...
@@ -510,14 +511,19 @@
},
converse
));
it
(
"
can have their requests denied by the user
"
,
$
.
proxy
(
function
()
{
var
jid
=
mock
.
req_names
.
sort
()[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
view
=
this
.
rosterview
.
get
(
jid
);
this
.
rosterview
.
model
.
reset
();
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
connection
.
roster
,
'
unauthorize
'
);
spyOn
(
this
.
rosterview
,
'
removeRosterItemView
'
).
andCallThrough
();
spyOn
(
window
,
'
confirm
'
).
andReturn
(
true
);
this
.
rosterview
.
initialize
();
// Must be initialized only after the spy has been called
utils
.
createContacts
(
'
requesting
'
).
openControlBox
();
var
jid
=
mock
.
req_names
.
sort
()[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
view
=
this
.
rosterview
.
get
(
jid
);
spyOn
(
view
,
'
declineRequest
'
).
andCallThrough
();
view
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
var
accept_button
=
view
.
$el
.
find
(
'
.decline-xmpp-request
'
);
accept_button
.
click
();
expect
(
view
.
declineRequest
).
toHaveBeenCalled
();
...
...
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