2015-07-12 20:51:24 -04:00
|
|
|
/*
|
2016-01-06 23:17:56 -05:00
|
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
2017-05-05 09:26:13 -04:00
|
|
|
Copyright 2017 Vector Creations Ltd
|
2015-07-12 20:51:24 -04:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2017-05-04 10:38:53 -04:00
|
|
|
import React from 'react';
|
2017-04-26 14:41:16 -04:00
|
|
|
import ReactDOM from 'react-dom';
|
2017-05-04 10:38:53 -04:00
|
|
|
import sdk from 'matrix-react-sdk';
|
2017-04-26 14:41:16 -04:00
|
|
|
import dis from 'matrix-react-sdk/lib/dispatcher';
|
|
|
|
import Velocity from 'velocity-vector';
|
|
|
|
import 'velocity-vector/velocity.ui';
|
2017-10-29 03:51:02 -04:00
|
|
|
import SettingsStore from "matrix-react-sdk/lib/settings/SettingsStore";
|
2017-04-26 14:41:16 -04:00
|
|
|
|
|
|
|
const CALLOUT_ANIM_DURATION = 1000;
|
2015-07-15 10:04:24 -04:00
|
|
|
|
2015-07-12 20:51:24 -04:00
|
|
|
module.exports = React.createClass({
|
2015-07-20 23:11:24 -04:00
|
|
|
displayName: 'BottomLeftMenu',
|
2015-07-15 10:04:24 -04:00
|
|
|
|
2016-09-03 08:44:00 -04:00
|
|
|
propTypes: {
|
|
|
|
collapsed: React.PropTypes.bool.isRequired,
|
|
|
|
},
|
|
|
|
|
2017-04-26 14:41:16 -04:00
|
|
|
getInitialState: function() {
|
|
|
|
return({
|
|
|
|
directoryHover : false,
|
|
|
|
roomsHover : false,
|
|
|
|
homeHover: false,
|
|
|
|
peopleHover : false,
|
|
|
|
settingsHover : false,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
componentWillMount: function() {
|
|
|
|
this._dispatcherRef = dis.register(this.onAction);
|
|
|
|
this._peopleButton = null;
|
|
|
|
this._directoryButton = null;
|
|
|
|
this._createRoomButton = null;
|
|
|
|
this._lastCallouts = {};
|
|
|
|
},
|
|
|
|
|
|
|
|
componentWillUnmount: function() {
|
|
|
|
dis.unregister(this._dispatcherRef);
|
|
|
|
},
|
|
|
|
|
|
|
|
// Room events
|
|
|
|
onDirectoryClick: function() {
|
|
|
|
dis.dispatch({ action: 'view_room_directory' });
|
|
|
|
},
|
|
|
|
|
|
|
|
onDirectoryMouseEnter: function() {
|
|
|
|
this.setState({ directoryHover: true });
|
|
|
|
},
|
|
|
|
|
|
|
|
onDirectoryMouseLeave: function() {
|
|
|
|
this.setState({ directoryHover: false });
|
|
|
|
},
|
|
|
|
|
|
|
|
onRoomsClick: function() {
|
|
|
|
dis.dispatch({ action: 'view_create_room' });
|
|
|
|
},
|
|
|
|
|
|
|
|
onRoomsMouseEnter: function() {
|
|
|
|
this.setState({ roomsHover: true });
|
|
|
|
},
|
|
|
|
|
|
|
|
onRoomsMouseLeave: function() {
|
|
|
|
this.setState({ roomsHover: false });
|
|
|
|
},
|
|
|
|
|
|
|
|
// Home button events
|
|
|
|
onHomeClick: function() {
|
|
|
|
dis.dispatch({ action: 'view_home_page' });
|
|
|
|
},
|
|
|
|
|
|
|
|
onHomeMouseEnter: function() {
|
|
|
|
this.setState({ homeHover: true });
|
|
|
|
},
|
|
|
|
|
|
|
|
onHomeMouseLeave: function() {
|
|
|
|
this.setState({ homeHover: false });
|
|
|
|
},
|
|
|
|
|
|
|
|
// People events
|
|
|
|
onPeopleClick: function() {
|
|
|
|
dis.dispatch({ action: 'view_create_chat' });
|
|
|
|
},
|
|
|
|
|
|
|
|
onPeopleMouseEnter: function() {
|
|
|
|
this.setState({ peopleHover: true });
|
|
|
|
},
|
|
|
|
|
|
|
|
onPeopleMouseLeave: function() {
|
|
|
|
this.setState({ peopleHover: false });
|
|
|
|
},
|
|
|
|
|
|
|
|
// Settings events
|
|
|
|
onSettingsClick: function() {
|
|
|
|
dis.dispatch({ action: 'view_user_settings' });
|
|
|
|
},
|
|
|
|
|
|
|
|
onSettingsMouseEnter: function() {
|
|
|
|
this.setState({ settingsHover: true });
|
|
|
|
},
|
|
|
|
|
|
|
|
onSettingsMouseLeave: function() {
|
|
|
|
this.setState({ settingsHover: false });
|
|
|
|
},
|
|
|
|
|
|
|
|
onAction: function(payload) {
|
|
|
|
let calloutElement;
|
|
|
|
switch (payload.action) {
|
|
|
|
// Incoming instruction: dance!
|
|
|
|
case 'callout_start_chat':
|
|
|
|
calloutElement = this._peopleButton;
|
|
|
|
break;
|
|
|
|
case 'callout_room_directory':
|
|
|
|
calloutElement = this._directoryButton;
|
|
|
|
break;
|
|
|
|
case 'callout_create_room':
|
|
|
|
calloutElement = this._createRoomButton;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (calloutElement) {
|
|
|
|
const lastCallout = this._lastCallouts[payload.action];
|
|
|
|
const now = Date.now();
|
|
|
|
if (lastCallout == undefined || lastCallout < now - CALLOUT_ANIM_DURATION) {
|
|
|
|
this._lastCallouts[payload.action] = now;
|
|
|
|
Velocity(ReactDOM.findDOMNode(calloutElement), "callout.bounce", CALLOUT_ANIM_DURATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// Get the label/tooltip to show
|
|
|
|
getLabel: function(label, show) {
|
|
|
|
if (show) {
|
|
|
|
var RoomTooltip = sdk.getComponent("rooms.RoomTooltip");
|
|
|
|
return <RoomTooltip className="mx_BottomLeftMenu_tooltip" label={label} />;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_collectPeopleButton: function(e) {
|
|
|
|
this._peopleButton = e;
|
|
|
|
},
|
|
|
|
|
|
|
|
_collectDirectoryButton: function(e) {
|
|
|
|
this._directoryButton = e;
|
|
|
|
},
|
|
|
|
|
|
|
|
_collectCreateRoomButton: function(e) {
|
|
|
|
this._createRoomButton = e;
|
|
|
|
},
|
|
|
|
|
2017-05-04 10:38:53 -04:00
|
|
|
render: function() {
|
2017-05-05 09:26:13 -04:00
|
|
|
const HomeButton = sdk.getComponent('elements.HomeButton');
|
|
|
|
const StartChatButton = sdk.getComponent('elements.StartChatButton');
|
|
|
|
const RoomDirectoryButton = sdk.getComponent('elements.RoomDirectoryButton');
|
|
|
|
const CreateRoomButton = sdk.getComponent('elements.CreateRoomButton');
|
2017-09-27 12:46:53 -04:00
|
|
|
const GroupsButton = sdk.getComponent('elements.GroupsButton');
|
2017-05-05 09:26:13 -04:00
|
|
|
const SettingsButton = sdk.getComponent('elements.SettingsButton');
|
2017-05-16 11:27:58 -04:00
|
|
|
|
2015-07-12 20:51:24 -04:00
|
|
|
return (
|
2015-07-20 23:11:24 -04:00
|
|
|
<div className="mx_BottomLeftMenu">
|
|
|
|
<div className="mx_BottomLeftMenu_options">
|
2017-05-26 05:33:48 -04:00
|
|
|
<HomeButton tooltip={true} />
|
2017-05-25 08:49:41 -04:00
|
|
|
<div ref={this._collectPeopleButton}>
|
|
|
|
<StartChatButton tooltip={true} />
|
|
|
|
</div>
|
|
|
|
<div ref={this._collectDirectoryButton}>
|
|
|
|
<RoomDirectoryButton tooltip={true} />
|
|
|
|
</div>
|
|
|
|
<div ref={this._collectCreateRoomButton}>
|
|
|
|
<CreateRoomButton tooltip={true} />
|
|
|
|
</div>
|
2017-11-10 10:38:32 -05:00
|
|
|
<GroupsButton tooltip={true} />
|
2017-05-04 10:38:53 -04:00
|
|
|
<span className="mx_BottomLeftMenu_settings">
|
2017-05-05 09:26:13 -04:00
|
|
|
<SettingsButton tooltip={true} />
|
2017-05-04 10:38:53 -04:00
|
|
|
</span>
|
2015-07-12 20:51:24 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2017-11-10 10:38:32 -05:00
|
|
|
},
|
2015-07-12 20:51:24 -04:00
|
|
|
});
|