cartodb-4.42/lib/assets/javascripts/cartodb/public_dashboard/entry.js

78 lines
2.3 KiB
JavaScript
Raw Normal View History

2024-04-06 13:25:13 +08:00
var $ = require('jquery-cdb-v3');
var cdb = require('cartodb.js-v3');
var FavMapView = require('./fav_map_view');
var UserInfoView = require('./user_info_view');
var PaginationModel = require('../common/views/pagination/model');
var PaginationView = require('../common/views/pagination/view');
var UserSettingsView = require('../public_common/user_settings_view');
var UserIndustriesView = require('../public_common/user_industries_view');
var MapCardPreview = require('../common/views/mapcard_preview');
var ScrollableHeader = require('../common/views/scrollable_header');
$(function() {
cdb.init(function() {
cdb.templates.namespace = 'cartodb/';
cdb.config.set(window.config);
cdb.config.set('url_prefix', window.base_url);
var scrollableHeader = new ScrollableHeader({
el: $('.js-Navmenu'),
anchorPoint: 350
});
var userIndustriesView = new UserIndustriesView({
el: $('.js-user-industries')
});
$(document.body).bind('click', function() {
cdb.god.trigger('closeDialogs');
});
var authenticatedUser = new cdb.open.AuthenticatedUser();
authenticatedUser.bind('change', function() {
if (authenticatedUser.get('username')) {
var user = new cdb.admin.User(authenticatedUser.attributes);
var userSettingsView = new UserSettingsView({
el: $('.js-user-settings'),
model: user
});
userSettingsView.render();
$('.js-login').hide();
$('.js-learn').show();
}
});
var favMapView = new FavMapView(window.favMapViewAttrs);
favMapView.render();
var userInfoView = new UserInfoView({
el: $('.js-user-info')
});
userInfoView.render();
var paginationView = new PaginationView({
el: '.js-content-footer',
model: new PaginationModel(window.paginationModelAttrs)
});
paginationView.render();
$('.MapCard').each(function() {
var visId = $(this).data('visId');
if (visId) {
var username = $(this).data('visOwnerName');
var mapCardPreview = new MapCardPreview({
el: $(this).find('.js-header'),
height: 220,
visId: $(this).data('visId'),
username: username,
mapsApiResource: cdb.config.getMapsResourceName(username)
});
mapCardPreview.load();
}
});
authenticatedUser.fetch();
});
});