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
1567b212
Commit
1567b212
authored
Mar 04, 2014
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add closure get/set methods for rosteritem views
parent
d20ca106
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
18 deletions
+44
-18
converse.js
converse.js
+11
-6
spec/chatbox.js
spec/chatbox.js
+1
-1
spec/controlbox.js
spec/controlbox.js
+30
-9
tests/utils.js
tests/utils.js
+2
-2
No files found.
converse.js
View file @
1567b212
...
...
@@ -442,7 +442,7 @@
return
converse
.
default_box_height
;
}
var
resistance
=
10
;
if
((
height
!==
converse
.
default_box_height
)
&&
if
((
height
!==
converse
.
default_box_height
)
&&
(
Math
.
abs
(
height
-
converse
.
default_box_height
)
<
resistance
))
{
return
converse
.
default_box_height
;
}
...
...
@@ -2925,9 +2925,14 @@
this
.
RosterView
=
Backbone
.
View
.
extend
({
tagName
:
'
dl
'
,
id
:
'
converse-roster
'
,
rosteritemviews
:
{},
initialize
:
function
()
{
var
views
=
{};
this
.
get
=
function
(
id
)
{
return
views
[
id
];
};
this
.
set
=
function
(
id
,
view
)
{
views
[
id
]
=
view
;
};
this
.
model
.
on
(
"
add
"
,
function
(
item
)
{
this
.
addRosterItemView
(
item
).
render
(
item
);
if
(
!
item
.
get
(
'
vcard_updated
'
))
{
...
...
@@ -2983,15 +2988,15 @@
addRosterItemView
:
function
(
item
)
{
var
view
=
new
converse
.
RosterItemView
({
model
:
item
});
this
.
rosteritemviews
[
item
.
id
]
=
view
;
this
.
set
(
item
.
id
,
view
)
;
return
this
;
},
removeRosterItemView
:
function
(
item
)
{
var
view
=
this
.
rosteritemviews
[
item
.
id
]
;
var
view
=
this
.
get
(
item
.
id
)
;
if
(
view
)
{
view
.
$el
.
remove
();
delete
this
.
rosteritemviews
[
item
.
id
]
;
delete
this
.
get
(
item
.
id
)
;
this
.
render
();
}
return
this
;
...
...
@@ -3018,7 +3023,7 @@
$count
,
changed_presence
;
if
(
item
)
{
var
jid
=
item
.
id
,
view
=
this
.
rosteritemviews
[
item
.
id
]
,
view
=
this
.
get
(
item
.
id
)
,
ask
=
item
.
get
(
'
ask
'
),
subscription
=
item
.
get
(
'
subscription
'
),
requesting
=
item
.
get
(
'
requesting
'
),
...
...
spec/chatbox.js
View file @
1567b212
...
...
@@ -39,7 +39,7 @@
for
(
i
=
0
;
i
<
online_contacts
.
length
;
i
++
)
{
$el
=
$
(
online_contacts
[
i
]);
jid
=
$el
.
text
().
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
rosteritemviews
[
jid
]
;
view
=
this
.
rosterview
.
get
(
jid
)
;
spyOn
(
view
,
'
openChat
'
).
andCallThrough
();
view
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
$el
.
click
();
...
...
spec/controlbox.js
View file @
1567b212
...
...
@@ -9,6 +9,14 @@
}
(
this
,
function
(
mock
,
utils
)
{
describe
(
"
The Control Box
"
,
$
.
proxy
(
function
(
mock
,
utils
)
{
beforeEach
(
function
()
{
runs
(
function
()
{
utils
.
openControlBox
();
});
waits
(
250
);
runs
(
function
()
{});
});
it
(
"
can be opened by clicking a DOM element with class 'toggle-online-users'
"
,
$
.
proxy
(
function
()
{
runs
(
function
()
{
utils
.
closeControlBox
();
...
...
@@ -35,6 +43,15 @@
},
converse
));
describe
(
"
The Status Widget
"
,
$
.
proxy
(
function
()
{
beforeEach
(
function
()
{
runs
(
function
()
{
utils
.
openControlBox
();
});
waits
(
250
);
runs
(
function
()
{});
});
it
(
"
shows the user's chat status, which is online by default
"
,
$
.
proxy
(
function
()
{
var
view
=
this
.
xmppstatusview
;
expect
(
view
.
$el
.
find
(
'
a.choose-xmpp-status
'
).
hasClass
(
'
online
'
)).
toBe
(
true
);
...
...
@@ -96,6 +113,9 @@
},
converse
,
mock
,
utils
));
describe
(
"
The Contacts Roster
"
,
$
.
proxy
(
function
(
mock
,
utils
)
{
// FIXME: These tests are dependent on being run in order and cannot be
// run independently
describe
(
"
Pending Contacts
"
,
$
.
proxy
(
function
()
{
beforeEach
(
function
()
{
runs
(
function
()
{
...
...
@@ -134,7 +154,8 @@
},
converse
));
it
(
"
can be removed by the user
"
,
$
.
proxy
(
function
()
{
var
view
=
_
.
toArray
(
this
.
rosterview
.
rosteritemviews
).
pop
();
var
jid
=
mock
.
pend_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
view
=
this
.
rosterview
.
get
(
jid
);
spyOn
(
window
,
'
confirm
'
).
andReturn
(
true
);
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
connection
.
roster
,
'
remove
'
).
andCallThrough
();
...
...
@@ -234,7 +255,7 @@
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
for
(
i
=
0
;
i
<
3
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
rosteritemviews
[
jid
]
;
view
=
this
.
rosterview
.
get
(
jid
)
;
spyOn
(
view
,
'
render
'
).
andCallThrough
();
item
=
view
.
model
;
item
.
set
(
'
chat_status
'
,
'
online
'
);
...
...
@@ -253,7 +274,7 @@
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
for
(
i
=
3
;
i
<
6
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
rosteritemviews
[
jid
]
;
view
=
this
.
rosterview
.
get
(
jid
)
;
spyOn
(
view
,
'
render
'
).
andCallThrough
();
item
=
view
.
model
;
item
.
set
(
'
chat_status
'
,
'
dnd
'
);
...
...
@@ -272,7 +293,7 @@
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
for
(
i
=
6
;
i
<
9
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
rosteritemviews
[
jid
]
;
view
=
this
.
rosterview
.
get
(
jid
)
;
spyOn
(
view
,
'
render
'
).
andCallThrough
();
item
=
view
.
model
;
item
.
set
(
'
chat_status
'
,
'
away
'
);
...
...
@@ -291,7 +312,7 @@
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
for
(
i
=
9
;
i
<
12
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
rosteritemviews
[
jid
]
;
view
=
this
.
rosterview
.
get
(
jid
)
;
spyOn
(
view
,
'
render
'
).
andCallThrough
();
item
=
view
.
model
;
item
.
set
(
'
chat_status
'
,
'
xa
'
);
...
...
@@ -310,7 +331,7 @@
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
for
(
i
=
12
;
i
<
15
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
rosteritemviews
[
jid
]
;
view
=
this
.
rosterview
.
get
(
jid
)
;
spyOn
(
view
,
'
render
'
).
andCallThrough
();
item
=
view
.
model
;
item
.
set
(
'
chat_status
'
,
'
unavailable
'
);
...
...
@@ -388,7 +409,7 @@
// actually not accepted/authorized because of
// mock_connection.
var
jid
=
mock
.
req_names
.
sort
()[
0
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
view
=
this
.
rosterview
.
rosteritemviews
[
jid
]
;
var
view
=
this
.
rosterview
.
get
(
jid
)
;
spyOn
(
this
.
connection
.
roster
,
'
authorize
'
);
spyOn
(
view
,
'
acceptRequest
'
).
andCallThrough
();
view
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
...
...
@@ -400,7 +421,7 @@
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
.
rosteritemviews
[
jid
]
;
var
view
=
this
.
rosterview
.
get
(
jid
)
;
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
connection
.
roster
,
'
unauthorize
'
);
spyOn
(
this
.
rosterview
,
'
removeRosterItemView
'
).
andCallThrough
();
...
...
@@ -451,7 +472,7 @@
// we make some online now
for
(
i
=
0
;
i
<
5
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
rosteritemviews
[
jid
]
;
view
=
this
.
rosterview
.
get
(
jid
)
;
view
.
model
.
set
(
'
chat_status
'
,
'
online
'
);
}
},
converse
));
...
...
tests/utils.js
View file @
1567b212
...
...
@@ -81,13 +81,13 @@
var
i
=
0
,
jid
,
views
=
[];
for
(
i
;
i
<
amount
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
views
[
i
]
=
converse
.
rosterview
.
rosteritemviews
[
jid
]
.
openChat
(
mock
.
event
);
views
[
i
]
=
converse
.
rosterview
.
get
(
jid
)
.
openChat
(
mock
.
event
);
}
return
views
;
};
utils
.
openChatBoxFor
=
function
(
jid
)
{
converse
.
rosterview
.
rosteritemviews
[
jid
]
.
openChat
(
mock
.
event
);
converse
.
rosterview
.
get
(
jid
)
.
openChat
(
mock
.
event
);
};
utils
.
clearChatBoxMessages
=
function
(
jid
)
{
...
...
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