|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
var cdb = require('cartodb.js');
|
|
|
|
|
var $ = require('jquery');
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Change the privacy of the new dataset.
|
|
|
|
@ -8,19 +9,18 @@ var cdb = require('cartodb.js');
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
module.exports = cdb.core.View.extend({
|
|
|
|
|
|
|
|
|
|
events: {
|
|
|
|
|
'click': '_onClick'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
initialize: function() {
|
|
|
|
|
initialize: function () {
|
|
|
|
|
this.user = this.options.user;
|
|
|
|
|
this.createModel = this.options.createModel;
|
|
|
|
|
this.template = cdb.templates.getTemplate('common/dialogs/create/footer/privacy_toggler_template');
|
|
|
|
|
this._initBinds();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
|
render: function () {
|
|
|
|
|
this.clearSubViews();
|
|
|
|
|
this.$el.empty();
|
|
|
|
|
|
|
|
|
@ -28,7 +28,7 @@ module.exports = cdb.core.View.extend({
|
|
|
|
|
var canChangePrivacy = this.user.canCreatePrivateDatasets();
|
|
|
|
|
var privacy = this.model.get('privacy');
|
|
|
|
|
var nexPrivacy = privacy === "PUBLIC" ? "PRIVATE" : "PUBLIC";
|
|
|
|
|
var icon = privacy === "PUBLIC" ? 'Unlock' : 'Lock';
|
|
|
|
|
var icon = privacy === "PUBLIC" ? 'unlock' : 'lock';
|
|
|
|
|
var upgradeUrl = cdb.config.get('upgrade_url') || window.upgrade_url;
|
|
|
|
|
var canUpgrade = !cdb.config.get('custom_com_hosted') && !canChangePrivacy && upgradeUrl;
|
|
|
|
|
|
|
|
|
@ -49,27 +49,27 @@ module.exports = cdb.core.View.extend({
|
|
|
|
|
return this;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_initBinds: function() {
|
|
|
|
|
_initBinds: function () {
|
|
|
|
|
this.model.bind('change:privacy', this.render, this);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_initViews: function() {
|
|
|
|
|
_initViews: function () {
|
|
|
|
|
// Tooltip
|
|
|
|
|
this.addView(
|
|
|
|
|
new cdb.common.TipsyTooltip({
|
|
|
|
|
el: this.$('.js-toggler'),
|
|
|
|
|
html: true,
|
|
|
|
|
title: function() {
|
|
|
|
|
title: function () {
|
|
|
|
|
return $(this).attr('data-title');
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_onClick: function() {
|
|
|
|
|
_onClick: function () {
|
|
|
|
|
if (this.user.canCreatePrivateDatasets()) {
|
|
|
|
|
var privacy = this.model.get('privacy');
|
|
|
|
|
this.model.set('privacy', privacy === "PUBLIC" ? "PRIVATE" : "PUBLIC" );
|
|
|
|
|
this.model.set('privacy', privacy === 'PUBLIC' ? 'PRIVATE' : 'PUBLIC');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|