Skip to content
This repository has been archived by the owner on Nov 8, 2018. It is now read-only.

Commit

Permalink
make accounts collapsable and show only important folders
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristophWurst committed Apr 24, 2016
1 parent edeca8a commit ad57ca3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
8 changes: 8 additions & 0 deletions css/mail.css
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@
.mail-account-email:first-child {
padding-top: 50px;
}
.account-toggle-collapse {
margin-left: 43px;
opacity: .2;
cursor: pointer;
}
.account-toggle-collapse:hover {
opacity: .5;
}

.mail-account-color {
display: inline-block;
Expand Down
5 changes: 4 additions & 1 deletion js/templates/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
{{/if}}
<h2 class="mail-account-email" title="{{email}}">{{email}}</h2>
<ul id="mail_folders" class="mail_folders with-icon" data-account_id="{{id}}">
</ul>
</ul>
{{#unless isUnifiedInbox}}
<span class="account-toggle-collapse">{{toggleCollapseMessage}}</span>
{{/unless}}
31 changes: 29 additions & 2 deletions js/views/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* later. See the COPYING file.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @copyright Christoph Wurst 2015
* @copyright Christoph Wurst 2015, 2016
*/

define(function(require) {
Expand All @@ -16,16 +16,43 @@ define(function(require) {
var FolderView = require('views/folder');
var AccountTemplate = require('text!templates/account.html');

var SHOW_COLLAPSED = Object.seal([
'inbox',
'flagged',
'drafts',
]);

return Backbone.Marionette.CompositeView.extend({
collection: null,
model: null,
template: Handlebars.compile(AccountTemplate),
templateHelpers: function() {
var toggleCollapseMessage = this.collapsed ? t('mail', 'Show all folders') : t('mail', 'Collapse folders');
return {
isUnifiedInbox: this.model.get('accountId') === -1,
toggleCollapseMessage: toggleCollapseMessage
};
},
collapsed: true,
events: {
'click .account-toggle-collapse': 'toggleCollapse'
},
childView: FolderView,
childViewContainer: '#mail_folders',
initialize: function(options) {
this.model = options.model;
this.collection = this.model.get('folders');
},
filter: function(child) {
if (!this.collapsed) {
return true;
}
var specialRole = child.get('specialRole');
return SHOW_COLLAPSED.indexOf(specialRole) !== -1;
},
toggleCollapse: function() {
this.collapsed = !this.collapsed;
this.render();
}

});
});

0 comments on commit ad57ca3

Please sign in to comment.