Commit 6e5bf44a authored by JC Brand's avatar JC Brand

This branch marks the start of a significant conceptual change.

Instead of differentiating between trimmed chats and minimized chats, the two
are now combined into the same thing.

This commit contains some initial work, but functionality is still impaired.
parent 88d20d03
This diff is collapsed.
...@@ -77,14 +77,14 @@ ...@@ -77,14 +77,14 @@
expect(this.chatboxviews.trimChats).toHaveBeenCalled(); expect(this.chatboxviews.trimChats).toHaveBeenCalled();
chatboxview = this.chatboxviews.get(jid); chatboxview = this.chatboxviews.get(jid);
spyOn(chatboxview, 'trim').andCallThrough(); spyOn(chatboxview, 'hide').andCallThrough();
chatboxview.model.set({'trimmed': true}); chatboxview.model.set({'minimized': true});
expect(trimmed_chatboxes.onChanged).toHaveBeenCalled(); expect(trimmed_chatboxes.onChanged).toHaveBeenCalled();
expect(chatboxview.trim).toHaveBeenCalled(); expect(chatboxview.hide).toHaveBeenCalled();
trimmedview = trimmed_chatboxes.get(jid); trimmedview = trimmed_chatboxes.get(jid);
expect(trimmedview.$el.is(":visible")).toBeTruthy(); expect(trimmedview.$el.is(":visible")).toBeTruthy();
} }
// Test that they can be restored/grown again // Test that they can be maximized again
var chatboxviews = this.chatboxviews.getAll(); var chatboxviews = this.chatboxviews.getAll();
var keys = _.keys(chatboxviews); var keys = _.keys(chatboxviews);
for (i=0; i<keys.length; i++) { for (i=0; i<keys.length; i++) {
...@@ -94,10 +94,10 @@ ...@@ -94,10 +94,10 @@
} }
chatboxview = chatboxviews[key]; chatboxview = chatboxviews[key];
trimmedview = trimmed_chatboxes.get(key); trimmedview = trimmed_chatboxes.get(key);
spyOn(chatboxview, 'grow').andCallThrough(); spyOn(chatboxview, 'maximize').andCallThrough();
trimmedview.$("a.restore-chat").click(); trimmedview.$("a.restore-chat").click();
expect(trimmed_chatboxes.onChanged).toHaveBeenCalled(); expect(trimmed_chatboxes.onChanged).toHaveBeenCalled();
expect(chatboxview.grow).toHaveBeenCalled(); expect(chatboxview.maximize).toHaveBeenCalled();
} }
}, converse)); }, converse));
...@@ -183,35 +183,38 @@ ...@@ -183,35 +183,38 @@
it("can be toggled by clicking a DOM element with class 'toggle-chatbox-button'", function () { it("can be toggled by clicking a DOM element with class 'toggle-chatbox-button'", function () {
var chatbox = utils.openChatBoxes(1)[0], var chatbox = utils.openChatBoxes(1)[0],
chatview = this.chatboxviews.get(chatbox.get('jid')); chatview = this.chatboxviews.get(chatbox.get('jid')),
trimmed_chatboxes = this.chatboxviews.trimmed_chatboxes_view;
spyOn(chatview, 'maximize').andCallThrough();
spyOn(chatview, 'toggle').andCallThrough(); spyOn(chatview, 'toggle').andCallThrough();
spyOn(converse, 'emit'); spyOn(converse, 'emit');
spyOn(trimmed_chatboxes, 'onChanged').andCallThrough();
// We need to rebind all events otherwise our spy won't be called // We need to rebind all events otherwise our spy won't be called
chatview.delegateEvents(); chatview.delegateEvents();
runs(function () { runs(function () {
chatview.$el.find('.toggle-chatbox-button').click(); chatview.$el.find('.toggle-chatbox-button').click();
}); });
waits(250); waits(50);
runs(function () { runs(function () {
expect(chatview.toggle).toHaveBeenCalled(); expect(chatview.toggle).toHaveBeenCalled();
expect(converse.emit).toHaveBeenCalledWith('onChatBoxToggled', jasmine.any(Object)); expect(converse.emit).toHaveBeenCalledWith('onChatBoxToggled', jasmine.any(Object));
expect(converse.emit.callCount, 2); expect(converse.emit.callCount, 2);
expect(chatview.$el.find('.chat-body').is(':visible')).toBeFalsy(); expect(chatview.$el.is(':visible')).toBeFalsy();
expect(chatview.$el.find('.toggle-chatbox-button').hasClass('icon-minus')).toBeFalsy();
expect(chatview.$el.find('.toggle-chatbox-button').hasClass('icon-plus')).toBeTruthy();
expect(chatview.model.get('minimized')).toBeTruthy(); expect(chatview.model.get('minimized')).toBeTruthy();
chatview.$el.find('.toggle-chatbox-button').click(); chatview.$el.find('.toggle-chatbox-button').click();
trimmedview = trimmed_chatboxes.get(chatview.model.get('id'));
trimmedview.$("a.restore-chat").click();
}); });
waits(250); waits(50);
runs(function () { runs(function () {
expect(chatview.toggle).toHaveBeenCalled(); expect(trimmed_chatboxes.onChanged).toHaveBeenCalled();
expect(converse.emit).toHaveBeenCalledWith('onChatBoxToggled', jasmine.any(Object)); expect(chatview.maximize).toHaveBeenCalled();
expect(chatview.$el.find('.chat-body').is(':visible')).toBeTruthy(); expect(chatview.$el.find('.chat-body').is(':visible')).toBeTruthy();
expect(chatview.$el.find('.toggle-chatbox-button').hasClass('icon-minus')).toBeTruthy(); expect(chatview.$el.find('.toggle-chatbox-button').hasClass('icon-minus')).toBeTruthy();
expect(chatview.$el.find('.toggle-chatbox-button').hasClass('icon-plus')).toBeFalsy(); expect(chatview.$el.find('.toggle-chatbox-button').hasClass('icon-plus')).toBeFalsy();
expect(chatview.model.get('minimized')).toBeFalsy(); expect(chatview.model.get('minimized')).toBeFalsy();
expect(converse.emit.callCount, 3);
}); });
}.bind(converse)); }.bind(converse));
......
<div class="box-flyout {[if (minimized) {]} minimized {[}]}" <div class="box-flyout" style="height: {{height}}px">
{[if (!minimized) {]} style="height: {{height}}px" {[}]}> <div class="dragresize dragresize-tm"></div>
<div class="dragresize dragresize-tm" {[ if (minimized) { ]} style="display:none" {[ } ]}></div>
<div class="chat-head chat-head-chatbox"> <div class="chat-head chat-head-chatbox">
<div class="chat-head-message-count">0</div> <div class="chat-head-message-count">0</div>
<a class="close-chatbox-button icon-close"></a> <a class="close-chatbox-button icon-close"></a>
<a class="toggle-chatbox-button <a class="toggle-chatbox-button icon-minus"></a>
{[ if (minimized) { ]} icon-plus {[ } ]}
{[ if (!minimized) { ]} icon-minus {[ } ]}
"></a>
<div class="chat-title"> <div class="chat-title">
{[ if (url) { ]} {[ if (url) { ]}
<a href="{{url}}" target="_blank" class="user"> <a href="{{url}}" target="_blank" class="user">
...@@ -19,7 +15,7 @@ ...@@ -19,7 +15,7 @@
</div> </div>
<p class="user-custom-message"><p/> <p class="user-custom-message"><p/>
</div> </div>
<div class="chat-body" {[ if (minimized) { ]} style="display:none" {[ } ]}> <div class="chat-body">
<div class="chat-content"></div> <div class="chat-content"></div>
<form class="sendXMPPMessage" action="" method="post"> <form class="sendXMPPMessage" action="" method="post">
{[ if (show_toolbar) { ]} {[ if (show_toolbar) { ]}
......
<div class="box-flyout {[if (minimized) {]} minimized {[}]}" <div class="box-flyout" style="height: {{height}}px"
{[if (!minimized) {]} style="height: {{height}}px" {[}]}> {[ if (minimized) { ]} style="display:none" {[ } ]}>
<div class="dragresize dragresize-tm" {[ if (minimized) { ]} style="display:none" {[ } ]}></div> <div class="dragresize dragresize-tm"></div>
<div class="chat-head chat-head-chatroom"> <div class="chat-head chat-head-chatroom">
<div class="chat-head-message-count">0</div> <div class="chat-head-message-count">0</div>
<a class="close-chatbox-button icon-close"></a> <a class="close-chatbox-button icon-close"></a>
<a class="toggle-chatbox-button <a class="toggle-chatbox-button icon-minus"></a>
{[ if (minimized) { ]} icon-plus {[ } ]}
{[ if (!minimized) { ]} icon-minus {[ } ]}
"></a>
<a class="configure-chatroom-button icon-wrench" style="display:none"></a> <a class="configure-chatroom-button icon-wrench" style="display:none"></a>
<div class="chat-title"> {{ name }} </div> <div class="chat-title"> {{ name }} </div>
<p class="chatroom-topic"><p/> <p class="chatroom-topic"><p/>
</div> </div>
<div class="chat-body" {[ if (minimized) { ]} style="display:none" {[ } ]}> <div class="chat-body"><span class="spinner centered"/></div>
<span class="spinner centered"/>
</div>
</div> </div>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment