59 lines
2.4 KiB
JavaScript
59 lines
2.4 KiB
JavaScript
const React = require('react');
|
|
const AccountFolders = require('./AccountFolders.js');
|
|
const DropDownButton = require('./DropDownButton.js');
|
|
const Store = require('./Store.js');
|
|
|
|
var FolderList = module.exports = React.createClass({
|
|
render: function()
|
|
{
|
|
var self = this;
|
|
return <div className={"folder-list"+(this.props.progress !== undefined ? ' progress-visible' : '')}>
|
|
<div className="top-border-gradient"></div>
|
|
<div className="bottom-border-gradient"></div>
|
|
<div className="actions">
|
|
<a className="button"><img src="icons/compose.png" /> Compose</a>
|
|
<DropDownButton dropdownId="check-send" className="check-send" icon="mail_check_send" />
|
|
</div>
|
|
// TODO: keyboard navigation
|
|
<div className="listview" tabIndex="1">
|
|
{this.props.accounts.map(function(account, i) {
|
|
return <AccountFolders key={'a'+account.accountId} accountIndex={i} onSelect={self.onSelectFolder} {...account} />
|
|
})}
|
|
</div>
|
|
<div className="progress-bar" ref="pbar">
|
|
<div className="pending" style={{ width: this.state.pbarWidth }}>Loading database ({this.props.progress||0}%)</div>
|
|
<div className="clip" style={{ width: (this.props.progress||0)+'%', overflow: 'hidden' }}>
|
|
<div className="done" ref="pdone" style={{ width: this.state.pbarWidth }}>Loading database ({this.props.progress||0}%)</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
},
|
|
onSelectFolder: function(accIndex, folderIndex)
|
|
{
|
|
var acc = this.props.accounts[accIndex];
|
|
var folder = this.props.accounts[accIndex].folders[folderIndex];
|
|
if (folder.folderId)
|
|
Store.loadFolder(folder.folderId);
|
|
if (this.prevSelected && this.prevSelected != accIndex)
|
|
this.prevSelected.setState({ selected: -1 });
|
|
this.prevSelected = accIndex;
|
|
},
|
|
getInitialState: function()
|
|
{
|
|
return { pbarWidth: '' };
|
|
},
|
|
onResize: function()
|
|
{
|
|
this.setState({ pbarWidth: this.refs.pbar.offsetWidth });
|
|
},
|
|
componentDidMount: function()
|
|
{
|
|
window.addEventListener('resize', this.onResize);
|
|
this.onResize();
|
|
},
|
|
componentWillUnmount: function()
|
|
{
|
|
window.removeEventListener('resize', this.onResize);
|
|
}
|
|
});
|