cartodb-4.42/lib/assets/javascripts/builder/components/modals/publish/share/user-view.js

43 lines
929 B
JavaScript
Raw Normal View History

2024-04-06 13:25:13 +08:00
var $ = require('jquery');
var _ = require('underscore');
var CoreView = require('backbone/core-view');
var template = require('./user.tpl');
var TipsyTooltipView = require('builder/components/tipsy-tooltip-view');
var REQUIRED_OPTS = [
'username',
'avatar'
];
module.exports = CoreView.extend({
initialize: function (opts) {
_.each(REQUIRED_OPTS, function (item) {
if (opts[item] === undefined) throw new Error(item + ' is required');
this['_' + item] = opts[item];
}, this);
},
render: function () {
this.clearSubViews();
this.$el.html(template({
avatar: this._avatar,
username: this._username
}));
this._initViews();
return this;
},
_initViews: function () {
var tooltip = new TipsyTooltipView({
el: this.$('.js-avatar'),
title: function () {
return $(this).attr('data-title');
}
});
this.addView(tooltip);
}
});