compile of dist/recline
This commit is contained in:
89
dist/recline.js
vendored
89
dist/recline.js
vendored
@@ -2501,18 +2501,18 @@ my.Map = Backbone.View.extend({
|
|||||||
|
|
||||||
// Listen to changes in the fields
|
// Listen to changes in the fields
|
||||||
this.model.fields.bind('change', function() {
|
this.model.fields.bind('change', function() {
|
||||||
self._setupGeometryField()
|
self._setupGeometryField();
|
||||||
self.render()
|
self.render();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Listen to changes in the records
|
// Listen to changes in the records
|
||||||
this.model.records.bind('add', function(doc){self.redraw('add',doc)});
|
this.model.records.bind('add', function(doc){self.redraw('add',doc);});
|
||||||
this.model.records.bind('change', function(doc){
|
this.model.records.bind('change', function(doc){
|
||||||
self.redraw('remove',doc);
|
self.redraw('remove',doc);
|
||||||
self.redraw('add',doc);
|
self.redraw('add',doc);
|
||||||
});
|
});
|
||||||
this.model.records.bind('remove', function(doc){self.redraw('remove',doc)});
|
this.model.records.bind('remove', function(doc){self.redraw('remove',doc);});
|
||||||
this.model.records.bind('reset', function(){self.redraw('reset')});
|
this.model.records.bind('reset', function(){self.redraw('reset');});
|
||||||
|
|
||||||
this.menu = new my.MapMenu({
|
this.menu = new my.MapMenu({
|
||||||
model: this.model,
|
model: this.model,
|
||||||
@@ -2612,7 +2612,7 @@ my.Map = Backbone.View.extend({
|
|||||||
|
|
||||||
var count = 0;
|
var count = 0;
|
||||||
var wrongSoFar = 0;
|
var wrongSoFar = 0;
|
||||||
_.every(docs,function(doc){
|
_.every(docs, function(doc){
|
||||||
count += 1;
|
count += 1;
|
||||||
var feature = self._getGeometryFromRecord(doc);
|
var feature = self._getGeometryFromRecord(doc);
|
||||||
if (typeof feature === 'undefined' || feature === null){
|
if (typeof feature === 'undefined' || feature === null){
|
||||||
@@ -2621,7 +2621,7 @@ my.Map = Backbone.View.extend({
|
|||||||
} else if (feature instanceof Object){
|
} else if (feature instanceof Object){
|
||||||
// Build popup contents
|
// Build popup contents
|
||||||
// TODO: mustache?
|
// TODO: mustache?
|
||||||
html = ''
|
html = '';
|
||||||
for (key in doc.attributes){
|
for (key in doc.attributes){
|
||||||
if (!(self.state.get('geomField') && key == self.state.get('geomField'))){
|
if (!(self.state.get('geomField') && key == self.state.get('geomField'))){
|
||||||
html += '<div><strong>' + key + '</strong>: '+ doc.attributes[key] + '</div>';
|
html += '<div><strong>' + key + '</strong>: '+ doc.attributes[key] + '</div>';
|
||||||
@@ -2634,7 +2634,11 @@ my.Map = Backbone.View.extend({
|
|||||||
feature.properties.cid = doc.cid;
|
feature.properties.cid = doc.cid;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
self.features.addGeoJSON(feature);
|
self.features.addData(feature);
|
||||||
|
|
||||||
|
if (feature.properties && feature.properties.popupContent) {
|
||||||
|
self.features.bindPopup(feature.properties.popupContent);
|
||||||
|
}
|
||||||
} catch (except) {
|
} catch (except) {
|
||||||
wrongSoFar += 1;
|
wrongSoFar += 1;
|
||||||
var msg = 'Wrong geometry value';
|
var msg = 'Wrong geometry value';
|
||||||
@@ -2644,7 +2648,7 @@ my.Map = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wrongSoFar += 1
|
wrongSoFar += 1;
|
||||||
if (wrongSoFar <= 10) {
|
if (wrongSoFar <= 10) {
|
||||||
self.trigger('recline:flash', {message: 'Wrong geometry value', category:'error'});
|
self.trigger('recline:flash', {message: 'Wrong geometry value', category:'error'});
|
||||||
}
|
}
|
||||||
@@ -2663,7 +2667,7 @@ my.Map = Backbone.View.extend({
|
|||||||
|
|
||||||
_.each(docs,function(doc){
|
_.each(docs,function(doc){
|
||||||
for (key in self.features._layers){
|
for (key in self.features._layers){
|
||||||
if (self.features._layers[key].cid == doc.cid){
|
if (self.features._layers[key].feature.properties.cid == doc.cid){
|
||||||
self.features.removeLayer(self.features._layers[key]);
|
self.features.removeLayer(self.features._layers[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2762,10 +2766,10 @@ my.Map = Backbone.View.extend({
|
|||||||
//
|
//
|
||||||
_zoomToFeatures: function(){
|
_zoomToFeatures: function(){
|
||||||
var bounds = this.features.getBounds();
|
var bounds = this.features.getBounds();
|
||||||
if (bounds){
|
if (bounds.getNorthEast()){
|
||||||
this.map.fitBounds(bounds);
|
this.map.fitBounds(bounds);
|
||||||
} else {
|
} else {
|
||||||
this.map.setView(new L.LatLng(0, 0), 2);
|
this.map.setView([0, 0], 2);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -2779,39 +2783,13 @@ my.Map = Backbone.View.extend({
|
|||||||
|
|
||||||
var mapUrl = "http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png";
|
var mapUrl = "http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png";
|
||||||
var osmAttribution = 'Map data © 2011 OpenStreetMap contributors, Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png">';
|
var osmAttribution = 'Map data © 2011 OpenStreetMap contributors, Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png">';
|
||||||
var bg = new L.TileLayer(mapUrl, {maxZoom: 18, attribution: osmAttribution, subdomains: '1234'});
|
var bg = new L.TileLayer(mapUrl, {maxZoom: 18, attribution: osmAttribution ,subdomains: '1234'});
|
||||||
this.map.addLayer(bg);
|
this.map.addLayer(bg);
|
||||||
|
|
||||||
this.features = new L.GeoJSON();
|
this.features = new L.GeoJSON();
|
||||||
this.features.on('featureparse', function (e) {
|
|
||||||
if (e.properties && e.properties.popupContent){
|
|
||||||
e.layer.bindPopup(e.properties.popupContent);
|
|
||||||
}
|
|
||||||
if (e.properties && e.properties.cid){
|
|
||||||
e.layer.cid = e.properties.cid;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// This will be available in the next Leaflet stable release.
|
|
||||||
// In the meantime we add it manually to our layer.
|
|
||||||
this.features.getBounds = function(){
|
|
||||||
var bounds = new L.LatLngBounds();
|
|
||||||
this._iterateLayers(function (layer) {
|
|
||||||
if (layer instanceof L.Marker){
|
|
||||||
bounds.extend(layer.getLatLng());
|
|
||||||
} else {
|
|
||||||
if (layer.getBounds){
|
|
||||||
bounds.extend(layer.getBounds().getNorthEast());
|
|
||||||
bounds.extend(layer.getBounds().getSouthWest());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, this);
|
|
||||||
return (typeof bounds.getNorthEast() !== 'undefined') ? bounds : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.map.addLayer(this.features);
|
this.map.addLayer(this.features);
|
||||||
|
|
||||||
this.map.setView(new L.LatLng(0, 0), 2);
|
this.map.setView([0, 0], 2);
|
||||||
|
|
||||||
this.mapReady = true;
|
this.mapReady = true;
|
||||||
},
|
},
|
||||||
@@ -3111,8 +3089,9 @@ my.MultiView = Backbone.View.extend({
|
|||||||
</div> \
|
</div> \
|
||||||
<div class="menu-right"> \
|
<div class="menu-right"> \
|
||||||
<div class="btn-group" data-toggle="buttons-checkbox"> \
|
<div class="btn-group" data-toggle="buttons-checkbox"> \
|
||||||
<a href="#" class="btn active" data-action="filters">Filters</a> \
|
{{#sidebarViews}} \
|
||||||
<a href="#" class="btn active" data-action="fields">Fields</a> \
|
<a href="#" data-action="{{id}}" class="btn active">{{label}}</a> \
|
||||||
|
{{/sidebarViews}} \
|
||||||
</div> \
|
</div> \
|
||||||
</div> \
|
</div> \
|
||||||
<div class="query-editor-here" style="display:inline;"></div> \
|
<div class="query-editor-here" style="display:inline;"></div> \
|
||||||
@@ -3142,28 +3121,28 @@ my.MultiView = Backbone.View.extend({
|
|||||||
view: new my.SlickGrid({
|
view: new my.SlickGrid({
|
||||||
model: this.model,
|
model: this.model,
|
||||||
state: this.state.get('view-grid')
|
state: this.state.get('view-grid')
|
||||||
}),
|
})
|
||||||
}, {
|
}, {
|
||||||
id: 'graph',
|
id: 'graph',
|
||||||
label: 'Graph',
|
label: 'Graph',
|
||||||
view: new my.Graph({
|
view: new my.Graph({
|
||||||
model: this.model,
|
model: this.model,
|
||||||
state: this.state.get('view-graph')
|
state: this.state.get('view-graph')
|
||||||
}),
|
})
|
||||||
}, {
|
}, {
|
||||||
id: 'map',
|
id: 'map',
|
||||||
label: 'Map',
|
label: 'Map',
|
||||||
view: new my.Map({
|
view: new my.Map({
|
||||||
model: this.model,
|
model: this.model,
|
||||||
state: this.state.get('view-map')
|
state: this.state.get('view-map')
|
||||||
}),
|
})
|
||||||
}, {
|
}, {
|
||||||
id: 'timeline',
|
id: 'timeline',
|
||||||
label: 'Timeline',
|
label: 'Timeline',
|
||||||
view: new my.Timeline({
|
view: new my.Timeline({
|
||||||
model: this.model,
|
model: this.model,
|
||||||
state: this.state.get('view-timeline')
|
state: this.state.get('view-timeline')
|
||||||
}),
|
})
|
||||||
}, {
|
}, {
|
||||||
id: 'transform',
|
id: 'transform',
|
||||||
label: 'Transform',
|
label: 'Transform',
|
||||||
@@ -3246,6 +3225,7 @@ my.MultiView = Backbone.View.extend({
|
|||||||
render: function() {
|
render: function() {
|
||||||
var tmplData = this.model.toTemplateJSON();
|
var tmplData = this.model.toTemplateJSON();
|
||||||
tmplData.views = this.pageViews;
|
tmplData.views = this.pageViews;
|
||||||
|
tmplData.sidebarViews = this.sidebarViews;
|
||||||
var template = Mustache.render(this.template, tmplData);
|
var template = Mustache.render(this.template, tmplData);
|
||||||
$(this.el).html(template);
|
$(this.el).html(template);
|
||||||
|
|
||||||
@@ -3265,7 +3245,7 @@ my.MultiView = Backbone.View.extend({
|
|||||||
_.each(this.sidebarViews, function(view) {
|
_.each(this.sidebarViews, function(view) {
|
||||||
this['$'+view.id] = view.view.el;
|
this['$'+view.id] = view.view.el;
|
||||||
$dataSidebar.append(view.view.el);
|
$dataSidebar.append(view.view.el);
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
var pager = new recline.View.Pager({
|
var pager = new recline.View.Pager({
|
||||||
model: this.model.queryState
|
model: this.model.queryState
|
||||||
@@ -3308,13 +3288,7 @@ my.MultiView = Backbone.View.extend({
|
|||||||
_onMenuClick: function(e) {
|
_onMenuClick: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var action = $(e.target).attr('data-action');
|
var action = $(e.target).attr('data-action');
|
||||||
if (action === 'filters') {
|
this['$'+action].toggle();
|
||||||
this.$filterEditor.toggle();
|
|
||||||
} else if (action === 'fields') {
|
|
||||||
this.$fieldsView.toggle();
|
|
||||||
} else if (action === 'transform') {
|
|
||||||
this.transformView.el.toggle();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_onSwitchView: function(e) {
|
_onSwitchView: function(e) {
|
||||||
@@ -3379,7 +3353,7 @@ my.MultiView = Backbone.View.extend({
|
|||||||
var self = this;
|
var self = this;
|
||||||
_.each(this.pageViews, function(pageView) {
|
_.each(this.pageViews, function(pageView) {
|
||||||
pageView.view.bind('recline:flash', function(flash) {
|
pageView.view.bind('recline:flash', function(flash) {
|
||||||
self.notify(flash);
|
self.notify(flash);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -3401,14 +3375,15 @@ my.MultiView = Backbone.View.extend({
|
|||||||
},
|
},
|
||||||
flash
|
flash
|
||||||
);
|
);
|
||||||
|
var _template;
|
||||||
if (tmplData.loader) {
|
if (tmplData.loader) {
|
||||||
var _template = ' \
|
_template = ' \
|
||||||
<div class="alert alert-info alert-loader"> \
|
<div class="alert alert-info alert-loader"> \
|
||||||
{{message}} \
|
{{message}} \
|
||||||
<span class="notification-loader"> </span> \
|
<span class="notification-loader"> </span> \
|
||||||
</div>';
|
</div>';
|
||||||
} else {
|
} else {
|
||||||
var _template = ' \
|
_template = ' \
|
||||||
<div class="alert alert-{{category}} fade in" data-alert="alert"><a class="close" data-dismiss="alert" href="#">×</a> \
|
<div class="alert alert-{{category}} fade in" data-alert="alert"><a class="close" data-dismiss="alert" href="#">×</a> \
|
||||||
{{message}} \
|
{{message}} \
|
||||||
</div>';
|
</div>';
|
||||||
|
|||||||
Reference in New Issue
Block a user