cartodb-4.42/lib/assets/javascripts/builder/editor/layers/basemap-content-views/basemap-header-view.js

37 lines
794 B
JavaScript
Raw Normal View History

2024-04-06 13:25:13 +08:00
var CoreView = require('backbone/core-view');
var template = require('./basemap-header.tpl');
var DEFAULT_NAME = _t('editor.layers.basemap.custom-basemap');
module.exports = CoreView.extend({
initialize: function (opts) {
if (!opts.category) throw new Error('category is required');
this.category = opts.category;
},
render: function () {
this.$el.html(
template({
title: _t('editor.layers.basemap.title-label'),
description: this._getName()
})
);
return this;
},
_getName: function () {
var name = this.model.getName();
if (!name) {
name = DEFAULT_NAME;
} else {
name = this.model.getName().replace(/_/g, '') + ' ' + _t('editor.layers.basemap.by') + ' ' + this.category;
}
return name;
}
});