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
27035d47
Commit
27035d47
authored
Nov 03, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remember toggle state of bookmarks list.
parent
55c2c383
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
3 deletions
+51
-3
spec/bookmarks.js
spec/bookmarks.js
+29
-0
src/converse-bookmarks.js
src/converse-bookmarks.js
+22
-3
No files found.
spec/bookmarks.js
View file @
27035d47
...
...
@@ -15,6 +15,7 @@
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
...
...
@@ -151,6 +152,7 @@
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
...
...
@@ -240,6 +242,7 @@
describe
(
"
and when autojoin is set
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
...
...
@@ -270,6 +273,7 @@
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
...
...
@@ -392,6 +396,7 @@
describe
(
"
The rooms panel
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
...
...
@@ -426,6 +431,30 @@
converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
$
(
'
#chatrooms dl.bookmarks dd
'
).
length
).
toBe
(
3
);
}));
it
(
"
remembers the toggle state of the bookmarks list
"
,
mock
.
initConverse
(
function
(
converse
)
{
runs
(
function
()
{
converse
.
bookmarks
.
create
({
'
jid
'
:
'
theplay@conference.shakespeare.lit
'
,
'
autojoin
'
:
false
,
'
name
'
:
'
The Play
'
,
'
nick
'
:
''
});
converse
.
emit
(
'
chatBoxesFetched
'
);
test_utils
.
openControlBox
().
openRoomsPanel
(
converse
);
});
waits
(
100
);
runs
(
function
()
{
expect
(
$
(
'
#chatrooms dl.bookmarks dd:visible
'
).
length
).
toBe
(
1
);
expect
(
converse
.
bookmarksview
.
list_model
.
get
(
'
toggle-state
'
)).
toBe
(
converse
.
OPENED
);
$
(
'
#chatrooms .bookmarks-toggle
'
).
click
();
expect
(
$
(
'
#chatrooms dl.bookmarks dd:visible
'
).
length
).
toBe
(
0
);
expect
(
converse
.
bookmarksview
.
list_model
.
get
(
'
toggle-state
'
)).
toBe
(
converse
.
CLOSED
);
$
(
'
#chatrooms .bookmarks-toggle
'
).
click
();
expect
(
$
(
'
#chatrooms dl.bookmarks dd:visible
'
).
length
).
toBe
(
1
);
expect
(
converse
.
bookmarksview
.
list_model
.
get
(
'
toggle-state
'
)).
toBe
(
converse
.
OPENED
);
});
}));
});
});
}));
src/converse-bookmarks.js
View file @
27035d47
...
...
@@ -175,6 +175,12 @@
converse
.
Bookmark
=
Backbone
.
Model
;
converse
.
BookmarksList
=
Backbone
.
Model
.
extend
({
defaults
:
{
"
toggle-state
"
:
converse
.
OPENED
}
});
converse
.
Bookmarks
=
Backbone
.
Collection
.
extend
({
model
:
converse
.
Bookmark
,
...
...
@@ -330,15 +336,26 @@
initialize
:
function
()
{
this
.
model
.
on
(
'
add
'
,
this
.
renderBookmarkListElement
,
this
);
this
.
model
.
on
(
'
remove
'
,
this
.
removeBookmarkListElement
,
this
);
var
cachekey
=
'
converse.room-bookmarks
'
+
converse
.
bare_jid
+
'
-list-model
'
;
this
.
list_model
=
new
converse
.
BookmarksList
();
this
.
list_model
.
id
=
cachekey
;
this
.
list_model
.
browserStorage
=
new
Backbone
.
BrowserStorage
[
converse
.
storage
](
b64_sha1
(
cachekey
)
);
this
.
list_model
.
fetch
();
this
.
render
();
},
render
:
function
(
cfg
)
{
this
.
$el
.
html
(
converse
.
templates
.
bookmarks_list
({
'
toggle_state
'
:
converse
.
OPENED
,
'
toggle_state
'
:
this
.
list_model
.
get
(
'
toggle-state
'
)
,
'
desc_bookmarks
'
:
__
(
'
Click to toggle the bookmarks list
'
),
'
label_bookmarks
'
:
__
(
'
Bookmarked Rooms
'
)
})).
hide
();
if
(
this
.
list_model
.
get
(
'
toggle-state
'
)
!==
converse
.
OPENED
)
{
this
.
$
(
'
.bookmarks
'
).
hide
();
}
this
.
model
.
each
(
this
.
renderBookmarkListElement
,
this
);
var
controlboxview
=
converse
.
chatboxviews
.
get
(
'
controlbox
'
);
if
(
!
_
.
isUndefined
(
controlboxview
))
{
...
...
@@ -381,11 +398,13 @@
if
(
ev
&&
ev
.
preventDefault
)
{
ev
.
preventDefault
();
}
var
$el
=
$
(
ev
.
target
);
if
(
$el
.
hasClass
(
"
icon-opened
"
))
{
this
.
$
(
'
.bookmarks
'
).
slideUp
();
this
.
$
(
'
.bookmarks
'
).
slideUp
(
'
fast
'
);
this
.
list_model
.
save
({
'
toggle-state
'
:
converse
.
CLOSED
});
$el
.
removeClass
(
"
icon-opened
"
).
addClass
(
"
icon-closed
"
);
}
else
{
$el
.
removeClass
(
"
icon-closed
"
).
addClass
(
"
icon-opened
"
);
this
.
$
(
'
.bookmarks
'
).
slideDown
();
this
.
$
(
'
.bookmarks
'
).
slideDown
(
'
fast
'
);
this
.
list_model
.
save
({
'
toggle-state
'
:
converse
.
OPENED
});
}
}
});
...
...
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