Commit ed762815 authored by Okhin's avatar Okhin
Browse files

Merge branch 'master' of git.laquadrature.net:la-quadrature-du-net/respect-my-net into nav

parents f4f44026 51b2a3ea
...@@ -66,3 +66,6 @@ class SearchViolation(SearchForm): ...@@ -66,3 +66,6 @@ class SearchViolation(SearchForm):
sqs = sqs.filter(country=self.cleaned_data['country']) sqs = sqs.filter(country=self.cleaned_data['country'])
return sqs return sqs
class QuickSearchViolation(forms.Form):
query = forms.CharField(required='True', max_length=256, label=_("Search"), help_text=_('Search for an existing violation'))
...@@ -145,7 +145,7 @@ class JSONMixin(object): ...@@ -145,7 +145,7 @@ class JSONMixin(object):
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
qs = self.get_queryset() qs = self.get_queryset()
if qs.count(): if qs.count():
return HttpResponse(json.dumps(sorted([(x.object.id, x.object.resource_name) for x in qs]))) return HttpResponse(json.dumps(sorted([(x.id, x.resource_name) for x in qs])))
else: else:
return HttpResponse('') return HttpResponse('')
......
nnmon/static/img/org.png

221 KB | W: | H:

nnmon/static/img/org.png

4.25 KB | W: | H:

nnmon/static/img/org.png
nnmon/static/img/org.png
nnmon/static/img/org.png
nnmon/static/img/org.png
  • 2-up
  • Swipe
  • Onion skin
nnmon/static/img/xnet.png

43.4 KB | W: | H:

nnmon/static/img/xnet.png

26.6 KB | W: | H:

nnmon/static/img/xnet.png
nnmon/static/img/xnet.png
nnmon/static/img/xnet.png
nnmon/static/img/xnet.png
  • 2-up
  • Swipe
  • Onion skin
This source diff could not be displayed because it is too large. You can view the blob instead.
(function() { (function() {
var svg; var svg;
/save off default references //save off default references
var d3 = window.d3, topojson = window.topojson; var d3 = window.d3, topojson = window.topojson;
var defaultOptions = { var defaultOptions = {
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
hideAntarctica: true, hideAntarctica: true,
hideHawaiiAndAlaska : false, hideHawaiiAndAlaska : false,
borderWidth: 1, borderWidth: 1,
borderOpacity: 1,
borderColor: '#FDFDFD', borderColor: '#FDFDFD',
popupTemplate: function(geography, data) { popupTemplate: function(geography, data) {
return '<div class="hoverinfo"><strong>' + geography.properties.name + '</strong></div>'; return '<div class="hoverinfo"><strong>' + geography.properties.name + '</strong></div>';
...@@ -30,13 +31,15 @@ ...@@ -30,13 +31,15 @@
highlightOnHover: true, highlightOnHover: true,
highlightFillColor: '#FC8D59', highlightFillColor: '#FC8D59',
highlightBorderColor: 'rgba(250, 15, 160, 0.2)', highlightBorderColor: 'rgba(250, 15, 160, 0.2)',
highlightBorderWidth: 2 highlightBorderWidth: 2,
highlightBorderOpacity: 1
}, },
projectionConfig: { projectionConfig: {
rotation: [97, 0] rotation: [97, 0]
}, },
bubblesConfig: { bubblesConfig: {
borderWidth: 2, borderWidth: 2,
borderOpacity: 1,
borderColor: '#FFFFFF', borderColor: '#FFFFFF',
popupOnHover: true, popupOnHover: true,
radius: null, radius: null,
...@@ -49,6 +52,7 @@ ...@@ -49,6 +52,7 @@
highlightFillColor: '#FC8D59', highlightFillColor: '#FC8D59',
highlightBorderColor: 'rgba(250, 15, 160, 0.2)', highlightBorderColor: 'rgba(250, 15, 160, 0.2)',
highlightBorderWidth: 2, highlightBorderWidth: 2,
highlightBorderOpacity: 1,
highlightFillOpacity: 0.85, highlightFillOpacity: 0.85,
exitDelay: 100, exitDelay: 100,
key: JSON.stringify key: JSON.stringify
...@@ -93,7 +97,7 @@ ...@@ -93,7 +97,7 @@
.attr('data-width', width || element.offsetWidth) .attr('data-width', width || element.offsetWidth)
.attr('class', 'datamap') .attr('class', 'datamap')
.attr('height', height || element.offsetHeight) .attr('height', height || element.offsetHeight)
.style('overflow', 'hidden'); / IE10+ doesn't respect height/width when map is zoomed in .style('overflow', 'hidden'); // IE10+ doesn't respect height/width when map is zoomed in
if (this.options.responsive) { if (this.options.responsive) {
d3.select(this.options.element).style({'position': 'relative', 'padding-bottom': (this.options.aspectRatio*100) + '%'}); d3.select(this.options.element).style({'position': 'relative', 'padding-bottom': (this.options.aspectRatio*100) + '%'});
...@@ -105,7 +109,7 @@ ...@@ -105,7 +109,7 @@
return this.svg; return this.svg;
} }
/ setProjection takes the svg element and options // setProjection takes the svg element and options
function setProjection( element, options ) { function setProjection( element, options ) {
var width = options.width || element.offsetWidth; var width = options.width || element.offsetWidth;
var height = options.height || element.offsetHeight; var height = options.height || element.offsetHeight;
...@@ -193,9 +197,9 @@ ...@@ -193,9 +197,9 @@
return JSON.stringify( colorCodeData[d.id]); return JSON.stringify( colorCodeData[d.id]);
}) })
.style('fill', function(d) { .style('fill', function(d) {
/if fillKey - use that //if fillKey - use that
/otherwise check 'fill' //otherwise check 'fill'
/otherwise check 'defaultFill' //otherwise check 'defaultFill'
var fillColor; var fillColor;
var datum = colorCodeData[d.id]; var datum = colorCodeData[d.id];
...@@ -210,6 +214,7 @@ ...@@ -210,6 +214,7 @@
return fillColor; return fillColor;
}) })
.style('stroke-width', geoConfig.borderWidth) .style('stroke-width', geoConfig.borderWidth)
.style('stroke-opacity', geoConfig.borderOpacity)
.style('stroke', geoConfig.borderColor); .style('stroke', geoConfig.borderColor);
} }
...@@ -236,11 +241,12 @@ ...@@ -236,11 +241,12 @@
.style('fill', val(datum.highlightFillColor, options.highlightFillColor, datum)) .style('fill', val(datum.highlightFillColor, options.highlightFillColor, datum))
.style('stroke', val(datum.highlightBorderColor, options.highlightBorderColor, datum)) .style('stroke', val(datum.highlightBorderColor, options.highlightBorderColor, datum))
.style('stroke-width', val(datum.highlightBorderWidth, options.highlightBorderWidth, datum)) .style('stroke-width', val(datum.highlightBorderWidth, options.highlightBorderWidth, datum))
.style('stroke-opacity', val(datum.highlightBorderOpacity, options.highlightBorderOpacity, datum))
.style('fill-opacity', val(datum.highlightFillOpacity, options.highlightFillOpacity, datum)) .style('fill-opacity', val(datum.highlightFillOpacity, options.highlightFillOpacity, datum))
.attr('data-previousAttributes', JSON.stringify(previousAttributes)); .attr('data-previousAttributes', JSON.stringify(previousAttributes));
/as per discussion on https:/github.com/markmarkoh/datamaps/issues/19 //as per discussion on https://github.com/markmarkoh/datamaps/issues/19
if ( ! /((MSIE)|(Trident))/.test ) { if ( ! /((MSIE)|(Trident))/.test(navigator.userAgent) ) {
moveToFront.call(this); moveToFront.call(this);
} }
} }
...@@ -253,7 +259,7 @@ ...@@ -253,7 +259,7 @@
var $this = d3.select(this); var $this = d3.select(this);
if (options.highlightOnHover) { if (options.highlightOnHover) {
/reapply previous attributes //reapply previous attributes
var previousAttributes = JSON.parse( $this.attr('data-previousAttributes') ); var previousAttributes = JSON.parse( $this.attr('data-previousAttributes') );
for ( var attr in previousAttributes ) { for ( var attr in previousAttributes ) {
$this.style(attr, previousAttributes[attr]); $this.style(attr, previousAttributes[attr]);
...@@ -269,7 +275,7 @@ ...@@ -269,7 +275,7 @@
} }
} }
/plugin to add a simple map legend //plugin to add a simple map legend
function addLegend(layer, data, options) { function addLegend(layer, data, options) {
data = data || {}; data = data || {};
if ( !this.options.fills ) { if ( !this.options.fills ) {
...@@ -321,9 +327,9 @@ ...@@ -321,9 +327,9 @@
throw "Datamaps Error - arcs must be an array"; throw "Datamaps Error - arcs must be an array";
} }
/ For some reason arc options were put in an `options` object instead of the parent arc // For some reason arc options were put in an `options` object instead of the parent arc
/ I don't like this, so to match bubbles and other plugins I'm moving it // I don't like this, so to match bubbles and other plugins I'm moving it
/ This is to keep backwards compatability // This is to keep backwards compatability
for ( var i = 0; i < data.length; i++ ) { for ( var i = 0; i < data.length; i++ ) {
data[i] = defaults(data[i], data[i].options); data[i] = defaults(data[i], data[i].options);
delete data[i].options; delete data[i].options;
...@@ -355,7 +361,7 @@ ...@@ -355,7 +361,7 @@
var destXY = self.latLngToXY(val(datum.destination.latitude, datum), val(datum.destination.longitude, datum)); var destXY = self.latLngToXY(val(datum.destination.latitude, datum), val(datum.destination.longitude, datum));
var midXY = [ (originXY[0] + destXY[0]) / 2, (originXY[1] + destXY[1]) / 2]; var midXY = [ (originXY[0] + destXY[0]) / 2, (originXY[1] + destXY[1]) / 2];
if (options.greatArc) { if (options.greatArc) {
/ TODO: Move this to inside `if` clause when setting attr `d` // TODO: Move this to inside `if` clause when setting attr `d`
var greatArc = d3.geo.greatArc() var greatArc = d3.geo.greatArc()
.source(function(d) { return [val(d.origin.longitude, d), val(d.origin.latitude, d)]; }) .source(function(d) { return [val(d.origin.longitude, d), val(d.origin.latitude, d)]; })
.target(function(d) { return [val(d.destination.longitude, d), val(d.destination.latitude, d)]; }); .target(function(d) { return [val(d.destination.longitude, d), val(d.destination.latitude, d)]; });
...@@ -365,12 +371,15 @@ ...@@ -365,12 +371,15 @@
var sharpness = val(datum.arcSharpness, options.arcSharpness, datum); var sharpness = val(datum.arcSharpness, options.arcSharpness, datum);
return "M" + originXY[0] + ',' + originXY[1] + "S" + (midXY[0] + (50 * sharpness)) + "," + (midXY[1] - (75 * sharpness)) + "," + destXY[0] + "," + destXY[1]; return "M" + originXY[0] + ',' + originXY[1] + "S" + (midXY[0] + (50 * sharpness)) + "," + (midXY[1] - (75 * sharpness)) + "," + destXY[0] + "," + destXY[1];
}) })
.attr('data-info', function(datum) {
return JSON.stringify(datum);
})
.transition() .transition()
.delay(100) .delay(100)
.style('fill', function(datum) { .style('fill', function(datum) {
/* /*
Thank you Jake Archibald, this is awesome. Thank you Jake Archibald, this is awesome.
Source: http:/jakearchibald.com/2013/animated-line-drawing-svg/ Source: http://jakearchibald.com/2013/animated-line-drawing-svg/
*/ */
var length = this.getTotalLength(); var length = this.getTotalLength();
this.style.transition = this.style.WebkitTransition = 'none'; this.style.transition = this.style.WebkitTransition = 'none';
...@@ -421,13 +430,20 @@ ...@@ -421,13 +430,20 @@
.style("stroke-width", options.lineWidth || 1) .style("stroke-width", options.lineWidth || 1)
} }
layer.append("text") layer.append("text")
.attr("x", x) .attr("x", x)
.attr("y", y) .attr("y", y)
.style("font-size", (options.fontSize || 10) + 'px') .style("font-size", (options.fontSize || 10) + 'px')
.style("font-family", options.fontFamily || "Verdana") .style("font-family", options.fontFamily || "Verdana")
.style("fill", options.labelColor || "#000") .style("fill", options.labelColor || "#000")
.text( d.id ); .text(function() {
if (options.customLabelText && options.customLabelText[d.id]) {
return options.customLabelText[d.id]
} else {
return d.id
}
});
return "bar"; return "bar";
}); });
} }
...@@ -470,11 +486,11 @@ ...@@ -470,11 +486,11 @@
if ( latLng ) return latLng[1]; if ( latLng ) return latLng[1];
}) })
.attr('r', function(datum) { .attr('r', function(datum) {
/ if animation enabled start with radius 0, otherwise use full size. // if animation enabled start with radius 0, otherwise use full size.
return options.animate ? 0 : val(datum.radius, options.radius, datum); return options.animate ? 0 : val(datum.radius, options.radius, datum);
}) })
.attr('data-info', function(d) { .attr('data-info', function(datum) {
return JSON.stringify(d); return JSON.stringify(datum);
}) })
.attr('filter', function (datum) { .attr('filter', function (datum) {
var filterKey = filterData[ val(datum.filterKey, options.filterKey, datum) ]; var filterKey = filterData[ val(datum.filterKey, options.filterKey, datum) ];
...@@ -489,6 +505,9 @@ ...@@ -489,6 +505,9 @@
.style('stroke-width', function ( datum ) { .style('stroke-width', function ( datum ) {
return val(datum.borderWidth, options.borderWidth, datum); return val(datum.borderWidth, options.borderWidth, datum);
}) })
.style('stroke-opacity', function ( datum ) {
return val(datum.borderOpacity, options.borderOpacity, datum);
})
.style('fill-opacity', function ( datum ) { .style('fill-opacity', function ( datum ) {
return val(datum.fillOpacity, options.fillOpacity, datum); return val(datum.fillOpacity, options.fillOpacity, datum);
}) })
...@@ -500,7 +519,7 @@ ...@@ -500,7 +519,7 @@
var $this = d3.select(this); var $this = d3.select(this);
if (options.highlightOnHover) { if (options.highlightOnHover) {
/save all previous attributes for mouseout //save all previous attributes for mouseout
var previousAttributes = { var previousAttributes = {
'fill': $this.style('fill'), 'fill': $this.style('fill'),
'stroke': $this.style('stroke'), 'stroke': $this.style('stroke'),
...@@ -512,6 +531,7 @@ ...@@ -512,6 +531,7 @@
.style('fill', val(datum.highlightFillColor, options.highlightFillColor, datum)) .style('fill', val(datum.highlightFillColor, options.highlightFillColor, datum))
.style('stroke', val(datum.highlightBorderColor, options.highlightBorderColor, datum)) .style('stroke', val(datum.highlightBorderColor, options.highlightBorderColor, datum))
.style('stroke-width', val(datum.highlightBorderWidth, options.highlightBorderWidth, datum)) .style('stroke-width', val(datum.highlightBorderWidth, options.highlightBorderWidth, datum))
.style('stroke-opacity', val(datum.highlightBorderOpacity, options.highlightBorderOpacity, datum))
.style('fill-opacity', val(datum.highlightFillOpacity, options.highlightFillOpacity, datum)) .style('fill-opacity', val(datum.highlightFillOpacity, options.highlightFillOpacity, datum))
.attr('data-previousAttributes', JSON.stringify(previousAttributes)); .attr('data-previousAttributes', JSON.stringify(previousAttributes));
} }
...@@ -524,7 +544,7 @@ ...@@ -524,7 +544,7 @@
var $this = d3.select(this); var $this = d3.select(this);
if (options.highlightOnHover) { if (options.highlightOnHover) {
/reapply previous attributes //reapply previous attributes
var previousAttributes = JSON.parse( $this.attr('data-previousAttributes') ); var previousAttributes = JSON.parse( $this.attr('data-previousAttributes') );
for ( var attr in previousAttributes ) { for ( var attr in previousAttributes ) {
$this.style(attr, previousAttributes[attr]); $this.style(attr, previousAttributes[attr]);
...@@ -538,6 +558,11 @@ ...@@ -538,6 +558,11 @@
.duration(400) .duration(400)
.attr('r', function ( datum ) { .attr('r', function ( datum ) {
return val(datum.radius, options.radius, datum); return val(datum.radius, options.radius, datum);
})
.transition()
.duration(0)
.attr('data-info', function(d) {
return JSON.stringify(d);
}); });
bubbles.exit() bubbles.exit()
...@@ -551,7 +576,7 @@ ...@@ -551,7 +576,7 @@
} }
} }
/stolen from underscore.js //stolen from underscore.js
function defaults(obj) { function defaults(obj) {
Array.prototype.slice.call(arguments, 1).forEach(function(source) { Array.prototype.slice.call(arguments, 1).forEach(function(source) {
if (source) { if (source) {
...@@ -571,14 +596,14 @@ ...@@ -571,14 +596,14 @@
if ( typeof d3 === 'undefined' || typeof topojson === 'undefined' ) { if ( typeof d3 === 'undefined' || typeof topojson === 'undefined' ) {
throw new Error('Include d3.js (v3.0.3 or greater) and topojson on this page before creating a new map'); throw new Error('Include d3.js (v3.0.3 or greater) and topojson on this page before creating a new map');
} }
/set options for global use //set options for global use
this.options = defaults(options, defaultOptions); this.options = defaults(options, defaultOptions);
this.options.geographyConfig = defaults(options.geographyConfig, defaultOptions.geographyConfig); this.options.geographyConfig = defaults(options.geographyConfig, defaultOptions.geographyConfig);
this.options.projectionConfig = defaults(options.projectionConfig, defaultOptions.projectionConfig); this.options.projectionConfig = defaults(options.projectionConfig, defaultOptions.projectionConfig);
this.options.bubblesConfig = defaults(options.bubblesConfig, defaultOptions.bubblesConfig); this.options.bubblesConfig = defaults(options.bubblesConfig, defaultOptions.bubblesConfig);
this.options.arcConfig = defaults(options.arcConfig, defaultOptions.arcConfig); this.options.arcConfig = defaults(options.arcConfig, defaultOptions.arcConfig);
/add the SVG container //add the SVG container
if ( d3.select( this.options.element ).select('svg').length > 0 ) { if ( d3.select( this.options.element ).select('svg').length > 0 ) {
addContainer.call(this, this.options.element, this.options.height, this.options.width ); addContainer.call(this, this.options.element, this.options.height, this.options.width );
} }
...@@ -590,7 +615,7 @@ ...@@ -590,7 +615,7 @@
this.addPlugin('labels', handleLabels); this.addPlugin('labels', handleLabels);
this.addPlugin('graticule', addGraticule); this.addPlugin('graticule', addGraticule);
/append style block with basic hoverover styles //append style block with basic hoverover styles
if ( ! this.options.disableDefaultStyles ) { if ( ! this.options.disableDefaultStyles ) {
addStyleBlock(); addStyleBlock();
} }
...@@ -598,7 +623,7 @@ ...@@ -598,7 +623,7 @@
return this.draw(); return this.draw();
} }
/ resize map // resize map
Datamap.prototype.resize = function () { Datamap.prototype.resize = function () {
var self = this; var self = this;
...@@ -612,19 +637,19 @@ ...@@ -612,19 +637,19 @@
} }
} }
/ actually draw the features(states & countries) // actually draw the features(states & countries)
Datamap.prototype.draw = function() { Datamap.prototype.draw = function() {
/save off in a closure //save off in a closure
var self = this; var self = this;
var options = self.options; var options = self.options;
/set projections and paths based on scope //set projections and paths based on scope
var pathAndProjection = options.setProjection.apply(self, [options.element, options] ); var pathAndProjection = options.setProjection.apply(self, [options.element, options] );
this.path = pathAndProjection.path; this.path = pathAndProjection.path;
this.projection = pathAndProjection.projection; this.projection = pathAndProjection.projection;
/if custom URL for topojson data, retrieve it and render //if custom URL for topojson data, retrieve it and render
if ( options.geographyConfig.dataUrl ) { if ( options.geographyConfig.dataUrl ) {
d3.json( options.geographyConfig.dataUrl, function(error, results) { d3.json( options.geographyConfig.dataUrl, function(error, results) {
if ( error ) throw new Error(error); if ( error ) throw new Error(error);
...@@ -639,11 +664,11 @@ ...@@ -639,11 +664,11 @@
return this; return this;
function draw (data) { function draw (data) {
/ if fetching remote data, draw the map first then call `updateChoropleth` // if fetching remote data, draw the map first then call `updateChoropleth`
if ( self.options.dataUrl ) { if ( self.options.dataUrl ) {
/allow for csv or json data types //allow for csv or json data types
d3[self.options.dataType](self.options.dataUrl, function(data) { d3[self.options.dataType](self.options.dataUrl, function(data) {
/in the case of csv, transform data to object //in the case of csv, transform data to object
if ( self.options.dataType === 'csv' && (data && data.slice) ) { if ( self.options.dataType === 'csv' && (data && data.slice) ) {
var tmpData = {}; var tmpData = {};
for(var i = 0; i < data.length; i++) { for(var i = 0; i < data.length; i++) {
...@@ -664,7 +689,7 @@ ...@@ -664,7 +689,7 @@
.style('position', 'absolute'); .style('position', 'absolute');
} }
/fire off finished callback //fire off finished callback
self.options.done(self); self.options.done(self);
} }
}; };
...@@ -932,12 +957,12 @@ ...@@ -932,12 +957,12 @@
Utilities Utilities
***************************************/ ***************************************/
/convert lat/lng coords to X / Y coords //convert lat/lng coords to X / Y coords
Datamap.prototype.latLngToXY = function(lat, lng) { Datamap.prototype.latLngToXY = function(lat, lng) {
return this.projection([lng, lat]); return this.projection([lng, lat]);
}; };
/add <g> layer to root SVG //add <g> layer to root SVG
Datamap.prototype.addLayer = function( className, id, first ) { Datamap.prototype.addLayer = function( className, id, first ) {
var layer; var layer;
if ( first ) { if ( first ) {
...@@ -950,8 +975,19 @@ ...@@ -950,8 +975,19 @@
.attr('class', className || ''); .attr('class', className || '');
}; };
Datamap.prototype.updateChoropleth = function(data) { Datamap.prototype.updateChoropleth = function(data, options) {
var svg = this.svg; var svg = this.svg;
var that = this;
// when options.reset = true, reset all the fill colors to the defaultFill and kill all data-info
if ( options && options.reset === true ) {
svg.selectAll('.datamaps-subunit')
.attr('data-info', function() {
return "{}"
})
.transition().style('fill', this.options.fills.defaultFill)
}
for ( var subunit in data ) { for ( var subunit in data ) {
if ( data.hasOwnProperty(subunit) ) { if ( data.hasOwnProperty(subunit) ) {
var color; var color;
...@@ -971,7 +1007,7 @@ ...@@ -971,7 +1007,7 @@
else { else {
color = this.options.fills[ subunitData.fillKey ]; color = this.options.fills[ subunitData.fillKey ];
} }
/if it's an object, overriding the previous data //if it's an object, overriding the previous data
if ( subunitData === Object(subunitData) ) { if ( subunitData === Object(subunitData) ) {
this.options.data[subunit] = defaults(subunitData, this.options.data[subunit] || {}); this.options.data[subunit] = defaults(subunitData, this.options.data[subunit] || {});
var geo = this.svg.select('.' + subunit).attr('data-info', JSON.stringify(this.options.data[subunit])); var geo = this.svg.select('.' + subunit).attr('data-info', JSON.stringify(this.options.data[subunit]));
...@@ -1021,7 +1057,7 @@ ...@@ -1021,7 +1057,7 @@
options = defaults(options || {}, self.options[name + 'Config']); options = defaults(options || {}, self.options[name + 'Config']);
/add a single layer, reuse the old layer //add a single layer, reuse the old layer
if ( !createNewLayer && this.options[name + 'Layer'] ) { if ( !createNewLayer && this.options[name + 'Layer'] ) {
layer = this.options[name + 'Layer']; layer = this.options[name + 'Layer'];
options = options || this.options[name + 'Options'];