diff --git a/app/assets/stylesheets/application.scss.erb b/app/assets/stylesheets/application.scss.erb index 14457520..52b0fc29 100644 --- a/app/assets/stylesheets/application.scss.erb +++ b/app/assets/stylesheets/application.scss.erb @@ -786,7 +786,6 @@ label { width: 32px; } .sidebarAccountBox { - display: none; height: auto; } .authenticated .sidebarAccountBox { diff --git a/frontend/src/Metamaps/GlobalUI/Account.js b/frontend/src/Metamaps/GlobalUI/Account.js deleted file mode 100644 index 59d9527d..00000000 --- a/frontend/src/Metamaps/GlobalUI/Account.js +++ /dev/null @@ -1,44 +0,0 @@ -/* global $ */ - -import Filter from '../Filter' - -const Account = { - isOpen: false, - changing: false, - init: function() { - var self = Account - $('body').click(self.close) - }, - toggleBox: function(event) { - var self = Account - if (self.isOpen) self.close() - else self.open() - event.stopPropagation() - }, - open: function() { - var self = Account - $('.sidebarAccountIcon .tooltipsUnder').addClass('hide') - if (!self.isOpen && !self.changing) { - self.changing = true - $('.sidebarAccountBox').fadeIn(200, function() { - self.changing = false - self.isOpen = true - $('.sidebarAccountBox #user_email').focus() - }) - } - }, - close: function() { - var self = Account - $('.sidebarAccountIcon .tooltipsUnder').removeClass('hide') - if (!self.changing) { - self.changing = true - $('.sidebarAccountBox #user_email').blur() - $('.sidebarAccountBox').fadeOut(200, function() { - self.changing = false - self.isOpen = false - }) - } - } -} - -export default Account diff --git a/frontend/src/Metamaps/GlobalUI/ReactApp.js b/frontend/src/Metamaps/GlobalUI/ReactApp.js index 8539adee..eccdaa8a 100644 --- a/frontend/src/Metamaps/GlobalUI/ReactApp.js +++ b/frontend/src/Metamaps/GlobalUI/ReactApp.js @@ -7,7 +7,6 @@ import { merge } from 'lodash' import { notifyUser } from './index.js' import ImportDialog from './ImportDialog' -import Account from './Account' import Active from '../Active' import DataModel from '../DataModel' import { ExploreMaps, ChatView, TopicCard } from '../Views' @@ -103,8 +102,7 @@ const ReactApp = { mobileTitle: self.mobileTitle, mobileTitleWidth: self.mobileTitleWidth, mobileTitleClick: (e) => Active.Map && InfoBox.toggleBox(e), - openInviteLightbox: () => self.openLightbox('invite'), - toggleAccountBox: Account.toggleBox + openInviteLightbox: () => self.openLightbox('invite') }, self.getMapProps(), self.getTopicProps(), diff --git a/frontend/src/Metamaps/GlobalUI/index.js b/frontend/src/Metamaps/GlobalUI/index.js index 7e77ff7d..b2dd6654 100644 --- a/frontend/src/Metamaps/GlobalUI/index.js +++ b/frontend/src/Metamaps/GlobalUI/index.js @@ -7,7 +7,6 @@ import Create from '../Create' import ReactApp from './ReactApp' import Search from './Search' import CreateMap from './CreateMap' -import Account from './Account' import ImportDialog from './ImportDialog' const GlobalUI = { @@ -20,7 +19,6 @@ const GlobalUI = { self.ReactApp.init(serverData, self.openLightbox) self.CreateMap.init(serverData) - self.Account.init(serverData) self.ImportDialog.init(serverData, self.openLightbox, self.closeLightbox) self.Search.init(serverData) @@ -153,5 +151,5 @@ const GlobalUI = { } } -export { ReactApp, Search, CreateMap, Account, ImportDialog } +export { ReactApp, Search, CreateMap, ImportDialog } export default GlobalUI diff --git a/frontend/src/Metamaps/index.js b/frontend/src/Metamaps/index.js index 7a55017a..12fcbe60 100644 --- a/frontend/src/Metamaps/index.js +++ b/frontend/src/Metamaps/index.js @@ -9,7 +9,7 @@ import DataModel from './DataModel' import Debug from './Debug' import Filter from './Filter' import GlobalUI, { - ReactApp, Search, CreateMap, ImportDialog, Account as GlobalUIAccount + ReactApp, Search, CreateMap, ImportDialog } from './GlobalUI' import Import from './Import' import JIT from './JIT' @@ -45,7 +45,6 @@ Metamaps.GlobalUI = GlobalUI Metamaps.GlobalUI.ReactApp = ReactApp Metamaps.GlobalUI.Search = Search Metamaps.GlobalUI.CreateMap = CreateMap -Metamaps.GlobalUI.Account = GlobalUIAccount Metamaps.GlobalUI.ImportDialog = ImportDialog Metamaps.Import = Import Metamaps.JIT = JIT diff --git a/frontend/src/components/App/AccountMenu.js b/frontend/src/components/App/AccountMenu.js index d1f772ec..99ab9301 100644 --- a/frontend/src/components/App/AccountMenu.js +++ b/frontend/src/components/App/AccountMenu.js @@ -1,9 +1,16 @@ import React, { Component, PropTypes } from 'react' +import onClickOutsideAddon from 'react-onclickoutside' + class AccountMenu extends Component { static propTypes = { currentUser: PropTypes.object, - onInviteClick: PropTypes.func + onInviteClick: PropTypes.func, + closeBox: PropTypes.func + } + + handleClickOutside = () => { + this.props.closeBox() } render () { @@ -37,4 +44,4 @@ class AccountMenu extends Component { } } -export default AccountMenu +export default onClickOutsideAddon(AccountMenu) diff --git a/frontend/src/components/App/LoginForm.js b/frontend/src/components/App/LoginForm.js index a6b3ae77..670b2bcb 100644 --- a/frontend/src/components/App/LoginForm.js +++ b/frontend/src/components/App/LoginForm.js @@ -1,8 +1,11 @@ import React, { Component, PropTypes } from 'react' +import onClickOutsideAddon from 'react-onclickoutside' + class LoginForm extends Component { static propTypes = { - loginFormAuthToken: PropTypes.string + loginFormAuthToken: PropTypes.string, + closeBox: PropTypes.func } constructor(props) { @@ -15,13 +18,21 @@ class LoginForm extends Component { this.setState({token}) } + emailInputDidMount(node) { + node.focus() + } + + handleClickOutside = () => { + this.props.closeBox() + } + render () { return