From ce0096de331b296d56a0b90115171e31cd628006 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Sun, 3 Aug 2014 20:48:49 +0200 Subject: [PATCH] Remember toggle state of group headers. updates #83 --- converse.js | 2 ++ spec/controlbox.js | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/converse.js b/converse.js index 5299bef1e..c524a1617 100644 --- a/converse.js +++ b/converse.js @@ -3286,9 +3286,11 @@ var $el = $(ev.target); this.$el.nextUntil('dt').slideToggle(); if ($el.hasClass("icon-opened")) { + this.model.set({state: CLOSED}); $el.removeClass("icon-opened").addClass("icon-closed"); } else { $el.removeClass("icon-closed").addClass("icon-opened"); + this.model.set({state: OPENED}); } }, diff --git a/spec/controlbox.js b/spec/controlbox.js index 8b31c22e0..0780432be 100644 --- a/spec/controlbox.js +++ b/spec/controlbox.js @@ -124,7 +124,7 @@ describe("The Contacts Roster", $.proxy(function (mock, utils) { - describe("Roster Groups", $.proxy(function () { + describe("A Roster Group", $.proxy(function () { beforeEach(function () { converse.roster_groups = true; @@ -188,7 +188,7 @@ }, converse)); }, converse)); - it("can share contacts among them (values aren't distinct)", $.proxy(function () { + it("can share contacts with other roster groups", $.proxy(function () { _clearContacts(); var i=0, j=0, t; spyOn(converse, 'emit'); @@ -213,8 +213,36 @@ expect(names.length).toEqual(mock.cur_names.length); }, converse)); }, converse)); - }, converse)); + it("remembers whether it is closed or opened", $.proxy(function () { + var i=0, j=0, t; + var groups = { + 'colleagues': 3, + 'friends & acquaintences': 3, + 'Ungrouped': 2 + }; + _.each(_.keys(groups), $.proxy(function (name) { + j = i; + for (i=j; i