metamaps--metamaps/frontend/src/Metamaps/GlobalUI/Account.js

56 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-09-29 16:20:16 +00:00
/* global $ */
import Filter from '../Filter'
const Account = {
isOpen: false,
changing: false,
2016-11-07 20:25:08 +00:00
init: function() {
2016-09-29 16:20:16 +00:00
var self = Account
$('.sidebarAccountIcon').click(self.toggleBox)
2016-11-07 20:25:08 +00:00
$('.sidebarAccountBox').click(function(event) {
2016-09-29 16:20:16 +00:00
event.stopPropagation()
})
$('body').click(self.close)
},
2016-11-07 20:25:08 +00:00
toggleBox: function(event) {
2016-09-29 16:20:16 +00:00
var self = Account
if (self.isOpen) self.close()
else self.open()
event.stopPropagation()
},
2016-11-07 20:25:08 +00:00
open: function() {
2016-09-29 16:20:16 +00:00
var self = Account
Filter.close()
$('.sidebarAccountIcon .tooltipsUnder').addClass('hide')
if (!self.isOpen && !self.changing) {
self.changing = true
2016-11-07 20:25:08 +00:00
$('.sidebarAccountBox').fadeIn(200, function() {
2016-09-29 16:20:16 +00:00
self.changing = false
self.isOpen = true
$('.sidebarAccountBox #user_email').focus()
})
}
},
2016-11-07 20:25:08 +00:00
close: function() {
2016-09-29 16:20:16 +00:00
var self = Account
$('.sidebarAccountIcon .tooltipsUnder').removeClass('hide')
if (!self.changing) {
self.changing = true
$('.sidebarAccountBox #user_email').blur()
2016-11-07 20:25:08 +00:00
$('.sidebarAccountBox').fadeOut(200, function() {
2016-09-29 16:20:16 +00:00
self.changing = false
self.isOpen = false
})
}
}
}
export default Account