cartodb-4.42/lib/assets/javascripts/dashboard/components/user-info/user-info-view.js

49 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-04-06 13:25:13 +08:00
const $ = require('jquery');
const CoreView = require('backbone/core-view');
const BreadcrumbDropdown = require('./dropdown-view.js');
/**
* View to render the user info section.
* Expected to be created from existing DOM element.
*/
module.exports = CoreView.extend({
events: {
'click .js-breadcrumb-dropdown-target': '_createBreadcrumbDropdown'
},
_previousDropDown: null,
_createBreadcrumbDropdown: function (ev) {
ev.preventDefault();
if (this._previousDropDown) {
this._previousDropDown.open();
return;
}
var dropdown = new BreadcrumbDropdown({
target: $(ev.target),
el: $('.js-breadcrumb-dropdown-content'),
horizontal_offset: 3, // to match the dropdown indicator/arrow
horizontal_position: 'right',
tick: 'right'
});
this._previousDropDown = dropdown;
this.addView(dropdown);
dropdown.on('onDropdownHidden', function () {
dropdown.clean();
}, this);
dropdown.render();
dropdown.open();
},
_closeAnyOtherOpenDialogs: function () {
if (this._previousDropDown) {
this._previousDropDown.hide();
}
}
});