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
69720660
Commit
69720660
authored
Sep 22, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bookmarked rooms will now be automatically opened
If configured for it.
parent
e80f001b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
10 deletions
+62
-10
spec/bookmarks.js
spec/bookmarks.js
+28
-4
src/converse-bookmarks.js
src/converse-bookmarks.js
+32
-5
src/converse-core.js
src/converse-core.js
+2
-1
No files found.
spec/bookmarks.js
View file @
69720660
...
...
@@ -2,11 +2,12 @@
(
function
(
root
,
factory
)
{
define
([
"
jquery
"
,
"
underscore
"
,
"
utils
"
,
"
mock
"
,
"
test_utils
"
],
factory
);
}
(
this
,
function
(
$
,
utils
,
mock
,
test_utils
)
{
}
(
this
,
function
(
$
,
_
,
utils
,
mock
,
test_utils
)
{
"
use strict
"
;
var
$iq
=
converse_api
.
env
.
$iq
,
Strophe
=
converse_api
.
env
.
Strophe
;
...
...
@@ -122,6 +123,26 @@
// nothing to test for here.
});
it
(
"
will be automatilly opened if 'autojoin' is set on the bookmark
"
,
function
()
{
var
jid
=
'
lounge@localhost
'
;
converse
.
bookmarks
.
create
({
'
jid
'
:
jid
,
'
autojoin
'
:
false
,
'
name
'
:
'
The Lounge
'
,
'
nick
'
:
'
Othello
'
});
expect
(
_
.
isUndefined
(
converse
.
chatboxviews
.
get
(
jid
))).
toBeTruthy
();
jid
=
'
theplay@conference.shakespeare.lit
'
;
converse
.
bookmarks
.
create
({
'
jid
'
:
jid
,
'
autojoin
'
:
true
,
'
name
'
:
'
The Play
'
,
'
nick
'
:
'
Othello
'
});
expect
(
_
.
isUndefined
(
converse
.
chatboxviews
.
get
(
jid
))).
toBeFalsy
();
});
describe
(
"
when bookmarked
"
,
function
()
{
beforeEach
(
function
()
{
test_utils
.
closeAllChatBoxes
();
...
...
@@ -145,7 +166,7 @@
});
it
(
"
can be unbookmarked
"
,
function
()
{
var
sent_stanza
,
IQ_id
;
var
view
,
sent_stanza
,
IQ_id
;
var
sendIQ
=
converse
.
connection
.
sendIQ
;
spyOn
(
converse
.
connection
,
'
sendIQ
'
).
andCallFake
(
function
(
iq
,
callback
,
errback
)
{
sent_stanza
=
iq
;
...
...
@@ -159,7 +180,7 @@
waits
(
100
);
runs
(
function
()
{
var
jid
=
'
theplay@conference.shakespeare.lit
'
;
v
ar
v
iew
=
converse
.
chatboxviews
.
get
(
jid
);
view
=
converse
.
chatboxviews
.
get
(
jid
);
spyOn
(
view
,
'
toggleBookmark
'
).
andCallThrough
();
spyOn
(
converse
.
bookmarks
,
'
sendBookmarkStanza
'
).
andCallThrough
();
view
.
delegateEvents
();
...
...
@@ -170,7 +191,10 @@
'
nick
'
:
'
Othello
'
});
expect
(
converse
.
bookmarks
.
length
).
toBe
(
1
);
view
.
model
.
save
(
'
bookmarked
'
,
true
);
});
waits
(
100
);
runs
(
function
()
{
expect
(
view
.
model
.
get
(
'
bookmarked
'
)).
toBeTruthy
();
var
$bookmark_icon
=
view
.
$
(
'
.icon-pushpin
'
);
expect
(
$bookmark_icon
.
hasClass
(
'
button-on
'
)).
toBeTruthy
();
$bookmark_icon
.
click
();
...
...
src/converse-bookmarks.js
View file @
69720660
...
...
@@ -52,6 +52,7 @@
initialize
:
function
()
{
this
.
__super__
.
initialize
.
apply
(
this
,
arguments
);
this
.
model
.
on
(
'
change:bookmarked
'
,
this
.
onBookmarked
,
this
);
this
.
setBookmarkState
();
},
render
:
function
(
options
)
{
...
...
@@ -65,7 +66,22 @@
},
onBookmarked
:
function
()
{
this
.
$
(
'
.icon-pushpin
'
).
toggleClass
(
'
button-on
'
);
if
(
this
.
model
.
get
(
'
bookmarked
'
))
{
this
.
$
(
'
.icon-pushpin
'
).
addClass
(
'
button-on
'
);
}
else
{
this
.
$
(
'
.icon-pushpin
'
).
removeClass
(
'
button-on
'
);
}
},
setBookmarkState
:
function
()
{
if
(
!
_
.
isUndefined
(
converse
.
bookmarks
))
{
var
models
=
converse
.
bookmarks
.
where
({
'
jid
'
:
this
.
model
.
get
(
'
jid
'
)});
if
(
!
models
.
length
)
{
this
.
model
.
save
(
'
bookmarked
'
,
false
);
}
else
{
this
.
model
.
save
(
'
bookmarked
'
,
true
);
}
}
},
renderBookmarkForm
:
function
()
{
...
...
@@ -129,15 +145,29 @@
*/
var
converse
=
this
.
converse
;
converse
.
Bookmark
=
Backbone
.
Model
;
converse
.
Bookmarks
=
Backbone
.
Collection
.
extend
({
model
:
converse
.
Bookmark
,
initialize
:
function
()
{
this
.
on
(
'
add
'
,
this
.
markRoomAsBookmarked
,
this
);
this
.
on
(
'
add
'
,
this
.
openBookmarkedRoom
,
this
);
this
.
on
(
'
remove
'
,
this
.
markRoomAsUnbookmarked
,
this
);
this
.
browserStorage
=
new
Backbone
.
BrowserStorage
[
converse
.
storage
](
b64_sha1
(
'
converse.room-bookmarks
'
+
converse
.
bare_jid
)
);
},
openBookmarkedRoom
:
function
(
bookmark
)
{
if
(
bookmark
.
get
(
'
autojoin
'
))
{
converse_api
.
rooms
.
open
(
bookmark
.
get
(
'
jid
'
),
bookmark
.
get
(
'
nick
'
));
}
},
fetchBookmarks
:
function
()
{
converse
.
bookmark
s
.
fetch
({
thi
s
.
fetch
({
'
add
'
:
true
,
'
success
'
:
this
.
onCachedBookmarksFetched
.
bind
(
this
),
'
error
'
:
this
.
onCachedBookmarksFetched
.
bind
(
this
)
...
...
@@ -247,9 +277,6 @@
converse
.
initBookmarks
=
function
()
{
converse
.
bookmarks
=
new
converse
.
Bookmarks
();
var
id
=
b64_sha1
(
'
converse.room-bookmarks
'
);
converse
.
bookmarks
.
id
=
id
;
converse
.
bookmarks
.
browserStorage
=
new
Backbone
.
BrowserStorage
[
converse
.
storage
](
id
);
converse
.
bookmarks
.
fetchBookmarks
();
};
converse
.
on
(
'
connected
'
,
converse
.
initBookmarks
);
...
...
src/converse-core.js
View file @
69720660
...
...
@@ -1676,7 +1676,8 @@
initialize
:
function
()
{
this
.
addClientIdentities
().
addClientFeatures
();
this
.
browserStorage
=
new
Backbone
.
BrowserStorage
[
converse
.
storage
](
b64_sha1
(
'
converse.features
'
+
converse
.
bare_jid
));
b64_sha1
(
'
converse.features
'
+
converse
.
bare_jid
)
);
this
.
on
(
'
add
'
,
this
.
onFeatureAdded
,
this
);
if
(
this
.
browserStorage
.
records
.
length
===
0
)
{
// browserStorage is empty, so we've likely never queried this
...
...
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