Skip to content

Commit

Permalink
Merge pull request #158 from SBA-ONE/staging
Browse files Browse the repository at this point in the history
Merging in all work through Sprint 16
  • Loading branch information
solipet authored May 11, 2017
2 parents 3f9d582 + 8e0ece4 commit 584b9a9
Show file tree
Hide file tree
Showing 87 changed files with 1,705 additions and 797 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ GEM
minitest (5.10.1)
multi_json (1.12.1)
nio4r (1.2.1)
nokogiri (1.7.0.1)
nokogiri (1.7.1)
mini_portile2 (~> 2.1.0)
parser (2.3.3.1)
ast (~> 2.2)
Expand Down Expand Up @@ -205,7 +205,7 @@ GEM
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
rubyzip (1.2.0)
rubyzip (1.2.1)
sass (3.4.23)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
Expand Down Expand Up @@ -303,4 +303,4 @@ DEPENDENCIES
web-console

BUNDLED WITH
1.13.6
1.14.6
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/help/base-map-toggle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/help/brac-details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/help/clear-search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/help/error-message.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/help/geolocation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/help/legend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/help/pegman.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/help/printable-version.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/help/search-bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/help/search-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/help/search-query.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/help/search-results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/help/zoom-control.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions app/assets/javascripts/hzmap/hz-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,31 @@ HZApp.HZQuery = {
},
handleBadResponses: function(responseStatus){
if (responseStatus === 'ZERO_RESULTS' || responseStatus === 'INVALID_REQUEST'){
$('.sidebar-card.map-report').hide();
$('.sidebar-card.map-actions').hide();
$('#sidebar-content').addClass('zero-results');
$('#legend').addClass('zero-results');
} else {
$('.sidebar-card.map-report').show();
$('.sidebar-card.map-actions').show();
$('#sidebar-content').removeClass('zero-results');
$('#legend').removeClass('zero-results');
}
},
parseResponseGeometry: function(response){
if (HZApp.HZQuery.response.geometry){
if (response.geometry){
HZApp.MapUtils.jumpToLocation({
viewport: response.geometry.viewport,
location: response.geometry.location
});

this.response.geocodeLocation = response.geometry.location;

if (response.place_id){
this.query.q = response.formatted_address;
this.query.latlng = null;
} else {
this.query.q = null;
this.query.latlng = [response.geocodeLocation.lat, response.geocodeLocation.lng ].join(',');
this.query.latlng = [response.geometry.location.lat, response.geometry.location.lng ].join(',');
}

this.response.geocodeLocation = response.geometry.location;
}
},
updateMap: function(){
Expand Down
6 changes: 6 additions & 0 deletions app/assets/javascripts/hzmap/layer-defs.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ HZApp.Layers.LayerDefs = (function(){
layerGroup: 'qct',
isVisible: true,
overlay:[],
},
qda_lg: {
layerIndex: 5,
layerGroup: 'qda',
isVisible: true,
overlay:[],
}
}
};
Expand Down
102 changes: 5 additions & 97 deletions app/assets/javascripts/hzmap/legend-defs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,131 +4,39 @@
// order in this object defines draw order on the map:
// first object is drawn first, then next on top of that, etc.
HZApp.Legend.LegendDefs = (function(){
var legendDefaults = {
circleFillColor: '#FFFFFF',
circleFillOpacity: 0.5,
circleStrokeColor: '#CCCCCC',
circleStrokeOpacity: 1,
circleStrokeWidth: 1,
displacementX: 0,
displacementY: 0,
fillColor: '#CCCCCC',
fillOpacity: 0.5,
graphicSpacing: 10,
lineStrokeColor: '#fff',
lineStrokeOpacity: 1,
lineStrokeWidth: 1,
lineRotation: 0,
strokeColor: '#CCCCCC',
strokeOpacity: 1,
strokeWidth: 1.25,
tileSize: 10,

// // USWDS Alt 1
// qctColor: '#2E8540',
// qnmcColor: '#0071BB',
// indianLandsColor: '#4C2C92'

// Tyler 1
qctColor: '#0D465C',
qnmcColor: '#BA233F',
indianLandsColor: '#009DCD'
};

var legendKeys = {
qct: {
title: "Census Tract",
svg: [],
canToggle: true,
layerGroup: 'qct',
styleOptions: [
{
type: 'polygon',
fillColor: legendDefaults.qctColor,
fillOpacity: legendDefaults.fillOpacity,
strokeColor: legendDefaults.qctColor,
strokeOpacity: legendDefaults.strokeOpacity,
strokeWidth: legendDefaults.strokeWidth
}
]
layerGroup: 'qct'
},
qnmc: {
title: "County",
svg: [],
canToggle: true,
layerGroup: 'qnmc',
styleOptions: [
{
type: 'polygon',
fillColor: legendDefaults.qnmcColor,
fillOpacity: legendDefaults.fillOpacity,
strokeColor: legendDefaults.qnmcColors,
strokeOpacity: legendDefaults.strokeOpacity,
strokeWidth: legendDefaults.strokeWidth
}
]
layerGroup: 'qnmc'
},
indian_lands: {
title: "Indian Land",
svg: [],
canToggle: true,
layerGroup: 'indian_lands',
styleOptions: [
{
type: 'polygon',
fillColor: legendDefaults.indianLandsColor,
fillOpacity: legendDefaults.fillOpacity,
strokeColor: legendDefaults.indianLandsColor,
strokeOpacity: legendDefaults.strokeOpacity,
strokeWidth: legendDefaults.strokeWidth
}
]
layerGroup: 'indian_lands'
},
redesignated: {
title: "Redesignated",
svg: [],
canToggle: true,
layerGroup: 'redesignated',
styleOptions: [
{
type: 'horline',
lineStrokeColor: legendDefaults.lineStrokeColor,
lineStrokeWidth: 5,
lineStrokeOpacity: legendDefaults.fillOpacity,
strokeWidth: legendDefaults.strokeWidth,
strokeColor: legendDefaults.lineStrokeColor,
strokeOpacity: legendDefaults.strokeOpacity,
tileSize: 30,
lineRotation: 0
}
]
layerGroup: 'redesignated'
},
brac: {
title: "Base Closure Area",
svg: [],
canToggle: true,
layerGroup: 'brac',
styleOptions: [
{
type: 'circle',
circleFillColor: '#fff',
circleFillOpacity: legendDefaults.fillOpacity,
circleStrokeColor: '#fff',
circleStrokeOpacity: legendDefaults.strokeOpacity,
circleStrokeWidth: legendDefaults.strokeWidth,
strokeColor: '#000000',
strokeOpacity: legendDefaults.strokeOpacity,
strokeWidth: legendDefaults.strokeWidth,
tileSize: 15,
graphicSpacing: legendDefaults.graphicSpacing
}
]
layerGroup: 'brac'
},
};

return {
legendDefaults: legendDefaults,
legend: legendKeys
};

})();
141 changes: 16 additions & 125 deletions app/assets/javascripts/hzmap/legend.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,147 +2,38 @@
HZApp.Legend = (function(){
return {
legend: HZApp.Legend.LegendDefs.legend,
buildLegend: function(layers){
Object.keys(layers).map(function(layer){
var legendConfig = HZApp.Legend.getConfigFromLayerStyle(layers[layer]);
HZApp.Legend.legend[legendConfig.layerGroup].svg.push(HZApp.Legend.svgFromStyle(legendConfig));
});

Object.keys(this.legend).map(HZApp.Legend.insertLegendItem);

buildLegend: function(){
this.addLegendButtonListeners();

this.setLegendState(window.innerWidth);

this.setMobileState(window.innerWidth);
this.addLayerToggleListeners();

},
addLegendButtonListeners: function(){
$('#legend-header').click(function(event) {
$('.legend-header').click(function(event) {
HZApp.Legend.toggleLegendVisibility(event.currentTarget.className);
});
},
toggleLegendVisibility: function(legendState) {
if(legendState === 'open') {
if(legendState.includes('open')) {
HZApp.Legend.hideLegend();
$('#legend-header').removeClass('open');
} else {
HZApp.Legend.showLegend();
$('#legend-header').addClass('open');
}
},
getConfigFromLayerStyle: function(layer){
return {
layerGroup: layer.layerGroup,
styleType: layer.styleOptions[0].type,
styleColor: layer.styleOptions[0][HZApp.Legend.legendTypeToColorType[layer.styleOptions[0].type]]
};
},
svgFromStyle: function(style){
var width = 34, height = 29;
var svg = this.svgHeader(width, height);
svg += '<title>hubzone legend</title>';
var svg_fn_name = "svg_" + style.styleType;
svg += HZApp.Legend[svg_fn_name](style,width, height);
svg += '</svg>';
return svg;
},
svgHeader: function(width, height){
return ('<svg width="' + width + 'px" height="' + height + 'px" viewBox="0 0 ' + (width + 5) + ' ' + height + '" ' +
'version="1.1" xmlns="http://www.w3.org/2000/svg" ' +
'xmlns:xlink="http://www.w3.org/1999/xlink">'
);
},
svg_polygon: function(style, width, height){
return ( '<g fill="' + style.styleColor + '">' +
'<rect width="' + width + '" height="' + height + '"></rect>' +
'</g>'
);
},
svg_horline: function(style, width, height){
return (
// '<defs><rect id="path-1" x="0" y="0" width="' + width + '" height="' + height +'"></rect></defs>' +
'<g fill="' + '#000' + '">' +
'<rect width="' + width + '" height="' + height + '"></rect>' +
'</g>' +
'<g stroke="'+ style.styleColor + '" stroke-width="1" fill="none" fill-rule="evenodd">' +
// '<use fill="#212121" xlink:href="#path-1"></use>' +
'<path d="M22.5,-5.5 L-5.5,31.5" id="Line" stroke="' + style.styleColor + '" stroke-width="6" stroke-linecap="square"></path>' +
'<path d="M45,-7 L9.5,39.5" id="Line-Copy" stroke="' + style.styleColor + '" stroke-width="6" stroke-linecap="square"></path>' +
'<path d="M63,0 L27.5,46.5" id="Line-Copy-2" stroke="' + style.styleColor + '" stroke-width="6" stroke-linecap="square"></path>' +
'<path d="M79,9 L43.5,55.5" id="Line-Copy-3" stroke="' + style.styleColor + '" stroke-width="6" stroke-linecap="square"></path>' +
'</g>'
);
},
svg_circle: function(style, width, height){
return (
// '<defs><rect id="path-2" x="0" y="0" width="' + width + '" height="' + height +'"></rect></defs>' +
'<g fill="' + '#000' + '">' +
'<rect width="' + width + '" height="' + height + '"></rect>' +
'</g>' +
'<g stroke="'+ style.styleColor + '" stroke-width="1" fill="none" fill-rule="evenodd">' +
// '<use fill="#212121" xlink:href="#path-2"></use>' +
'<ellipse fill="' + style.styleColor +'" cx="12" cy="0" rx="5" ry="5"></ellipse>' +
'<ellipse fill="' + style.styleColor +'" cx="12" cy="28" rx="5" ry="5"></ellipse>' +
'<circle fill="' + style.styleColor +'" cx="33" cy="0" r="5"></circle>' +
'<circle fill="' + style.styleColor +'" cx="33" cy="28" r="5"></circle>' +
'<circle fill="' + style.styleColor +'" cx="54" cy="0" r="5"></circle>' +
'<circle fill="' + style.styleColor +'" cx="54" cy="28" r="5"></circle>' +
'<ellipse fill="' + style.styleColor +'" cx="22" cy="15" rx="5" ry="5"></ellipse>' +
'<ellipse fill="' + style.styleColor +'" cx="22" cy="43" rx="5" ry="5"></ellipse>' +
'<ellipse fill="' + style.styleColor +'" cx="1" cy="15" rx="5" ry="5"></ellipse>' +
'<ellipse fill="' + style.styleColor +'" cx="1" cy="43" rx="5" ry="5"></ellipse>' +
'<ellipse fill="' + style.styleColor +'" cx="44" cy="15" rx="5" ry="5"></ellipse>' +
'<ellipse fill="' + style.styleColor +'" cx="44" cy="43" rx="5" ry="5"></ellipse>' +
'<circle fill="' + style.styleColor +'" cx="65" cy="15" r="5"></circle>' +
'<circle fill="' + style.styleColor +'" cx="65" cy="43" r="5"></circle>' +
'</g>'
);
},
insertLegendItem: function(legendItem) {
HZApp.Legend.legend[legendItem].canToggle ? HZApp.Legend.insertLegendItemToggle(legendItem) : HZApp.Legend.insertLegendItemNoToggle(legendItem);
},
insertLegendItemToggle: function(legendItem){
var li = '<li id="legend-' + legendItem + '"' + 'class="legend-item">';
li += '<input id="' + legendItem + '" type="checkbox" name="' + legendItem + '" value="' + legendItem + '" checked>';
li += '<label for=' + legendItem + '>';
HZApp.Legend.legend[legendItem].svg.map(function(svg){ li += svg; });
li += '<span>' + I18n.t('legend.' + legendItem) + '</span>';
li += '</label>';
li += '</li>';
$('#legend > ul').append(li);
},
// insertLegendItemNoToggle: function(legendItem){
// var li = '<li id="legend-' + legendItem + '"' + 'class="legend-item no-toggle">';
// HZApp.Legend.legend[legendItem].svg.map(function(svg){ li += svg; });
// li += '<span>' + I18n.t('legend.' + legendItem) + '</span>';
// li += '</li>';
// $('#legend > ul').append(li);
// },
legendTypeToColorType: { //mapping style type to css/svg color parameter
'polygon': 'fillColor',
'circle': 'circleFillColor',
'horline': 'lineStrokeColor'
},
hideLegend: function(){
$('#legend li.legend-item').hide();
$('#hide-legend-button').hide();
$('#legend-header-title-expanded').hide();
$('#legend-header-title-hidden').show();
$('#show-legend-button').show();
$('.legend-item').hide();
$('.legend-button').addClass("fa-chevron-up").removeClass("fa-chevron-down");
$('.legend-content').hide();
$('.legend-header').removeClass('open');
},
showLegend: function(){
$('#legend li.legend-item').show();
$('#hide-legend-button').show();
$('#legend-header-title-expanded').show();
$('#legend-header-title-hidden').hide();
$('#show-legend-button').hide();
},
setLegendState: function(windowWidth) {
if (windowWidth > 950) {
HZApp.Legend.toggleLegendVisibility('');
} else {
HZApp.Legend.toggleLegendVisibility('open');
$('.legend-item').show();
$('.legend-button').addClass("fa-chevron-down").removeClass("fa-chevron-up");
$('.legend-content').show();
$('.legend-header').addClass('open');
},
setMobileState: function(windowWidth) {
if (windowWidth < 950) {
HZApp.Legend.hideLegend();
}
},
addLayerToggleListeners: function() {
Expand Down
Loading

0 comments on commit 584b9a9

Please sign in to comment.