Merge branch 'develop' of https://github.com/CartoDB/cartodb20 into develop

2.0
Javier Alvarez 12 years ago
commit 1c18695adc

@ -11,9 +11,11 @@ javascripts:
- public/js/lib/cdb.js/vendor/underscore-min.js
- public/js/lib/cdb.js/vendor/backbone.js
- public/js/lib/cdb.js/vendor/leaflet.js
- public/js/lib/cdb.js/vendor/*.js
- public/js/lib/cdb.js/src/cartodb.js
- public/js/lib/cdb.js/src/core/**/*.js
- public/js/lib/cdb.js/src/ui/**/*.js
- public/js/lib/cdb.js/src/geo/map.js
- public/js/lib/cdb.js/src/geo/**/*.js
dashboard:

@ -0,0 +1,57 @@
/**
* menu bar carto module
* this module allows to edit Carto style
*/
cdb.admin.mod = cdb.admin.mod || {};
(function() {
cdb.admin.mod.Carto = cdb.core.View.extend({
buttonClass: 'carto_mod',
type: 'tool',
events: {
'click button': 'applyStyle'
},
initialize: function() {
this.template = this.getTemplate('table/menu_modules/views/carto');
this.model.bind('change:style', this._updateStyle, this);
},
activated: function() {
this.$('textarea').focus();
},
render: function() {
this.$el.append(this.template({}));
this._updateStyle();
return this;
},
_updateStyle: function(){
this.$('textarea').val(this.model.get('style'));
},
_parseError: function(err) {
this.$('.error').html(err.errors.join('<br/>'));
},
_clearErrors: function() {
this.$('.error').html('');
},
applyStyle: function() {
cdb.log.debug("compiling carto");
var style = this.$('textarea').val();
// compile and validate
this.model.set({ style: style });
}
});
}());

@ -0,0 +1,13 @@
<div>
<h1>Carto</h1>
<textarea cols=50 rows= 10></textarea>
<div>
<button>Apply style</button>
</div>
<div class="error">
</div>
</div>

@ -54,20 +54,27 @@ cdb.admin.RightMenu = cdb.core.View.extend({
this.panels.addTab(v.buttonClass, v);
var buttons;
if(v.type == 'tool') {
buttons = this.$('.tools')
buttons = this.$('.tools');
} else {
buttons = this.$('.edit')
buttons = this.$('.edit');
}
var b = new Button();
b.className = v.buttonClass;
buttons.append(b.render().el);
buttons.append(b.render().$el.css({ display: 'block'}));
this.addView(b);
b.bind('click', this.panels.active, this.panels);
// call togle before activate panel
b.bind('click', this.toggle, this);
b.bind('click', this.panels.active, this.panels);
},
active: function(modName) {
this.panels.active(modName);
},
toggle: function() {
if(this.isOpen) {
toggle: function(modName) {
// only hide if we click on active tab
if(this.isOpen && modName == this.panels.activeTab) {
this.hide();
} else {
this.show();
@ -78,14 +85,14 @@ cdb.admin.RightMenu = cdb.core.View.extend({
this.isOpen = false;
this.$el.animate({
right: -535
})
});
},
show: function() {
this.isOpen = true;
this.$el.animate({
right: 0
})
});
}
});

@ -9,11 +9,14 @@ $(function() {
var Table = cdb.core.View.extend({
el: document.body,
events: {
'keypress': 'keyPress'
'keypress': 'keyPress',
'keyup': 'keyUp'
},
initialize: function() {
this.ctrlPressed = false;
this._initModels();
this._initViews();
@ -61,10 +64,22 @@ $(function() {
// when the table name is known the tiles from
// the tile server can be fetched
this.table.bind('change:name', function() {
self.dataLayer.set({ table_name: self.table.get('name') });
self.dataLayer.set({table_name: this.get('name')});
self.map.addLayer(self.dataLayer);
});
this.table.bind('change:dataSource', function() {
var sql = '';
if(this.isInSQLView()) {
sql = this.data().options.get('sql');
}
cdb.log.info("tiler: sql: " + sql);
self.dataLayer.set({
query: sql
});
});
},
_initViews: function() {
@ -97,7 +112,9 @@ $(function() {
// lateral menu modules
var sql = new cdb.admin.mod.SQL({ model: this.table });
var carto = new cdb.admin.mod.Carto({ model: this.dataLayer });
this.menu.addModule(sql.render());
this.menu.addModule(carto.render());
//sql.bind('sqlQuery', this.table.sql);
@ -111,14 +128,16 @@ $(function() {
},
keyUp: function(e) {
},
keyPress: function(e) {
//TODO: do keystroke properly
if(String.fromCharCode(e.keyCode) === 's') {
if(e.which == 19) {
this.menu.show();
this.menu.active('sql');
this.menu.active('sql_mod');
e.preventDefault();
return false;
}
return 0;
}
});

@ -1 +1 @@
Subproject commit 4961334b4c8ebae72aff74de42d13307862ac308
Subproject commit fb8a9c54709d1500cc96314c0694d7bd708abdf4
Loading…
Cancel
Save