Browse Source

Fixed JS errors on map

development
Godwin 8 years ago
parent
commit
dccfa48491
  1. 47
      app/assets/javascripts/main.js
  2. 4
      app/assets/javascripts/map.js
  3. 1
      app/assets/stylesheets/_application.scss
  4. 2
      app/assets/stylesheets/bumbleberry-settings.json
  5. 2
      app/views/layouts/application.html.haml

47
app/assets/javascripts/main.js

@ -241,50 +241,3 @@
} }
}); });
})(); })();
function generateScreenshot() {
var css = '';
var svgs = document.getElementsByTagName('svg');
for (var i = 0; i < document.styleSheets.length; i++) {
if (document.styleSheets[i].href && !document.styleSheets[i].href.match(/web\-fonts/)) {
var rules = document.styleSheets[i].rules || document.styleSheets[i].cssRules;
for (var j = 0; j < rules.length; j++) {
cssText = rules[j].cssText;
if (rules[j].selectorText) {
if (rules[j].selectorText.match(/(^|\s)svg[^\w]/) || cssText.match(/\s(fill|stroke(\-width)?):/)) {
css += cssText;
}
}
}
}
}
for (var i = 0; i < svgs.length; i++) {
var svg = svgs[i];
// svg.innerHTML = '<style type="text/css"><![CDATA[' + css + ']]></style>' + svg.innerHTML;
svg.innerHTML = '<style type="text/css"><![CDATA[' + css + ']]></style>' + svg.innerHTML;
svg.setAttribute('height', svg.clientHeight);
svg.setAttribute('width', svg.clientWidth);
var canvas = document.createElement('canvas');
canvg(canvas, svg.outerHTML);
console.log(svg.outerHTML);
svg.style.backgroundImage = 'url(' + encodeURI(canvas.toDataURL('image/png')) + ')';
}
html2canvas(document.body, {
logging: true,
profile: true,
useCORS: true}).then(function(canvas) {
var data = canvas.toDataURL('image/jpeg', 0.9);
var src = encodeURI(data);
window.open(src, '_blank');
// reset the svg height and width
for (var i = 0; i < svgs.length; i++) {
var svg = svgs[i];
svg.removeAttribute('height');
svg.removeAttribute('width');
svg.removeAttribute('style');
}
});
}

4
app/assets/javascripts/map.js

@ -70,7 +70,7 @@
var annualConferences = container.append('g').attr('filter', 'url(#svg-gooey-filter)').attr('class', 'cities annual-conferences'); var annualConferences = container.append('g').attr('filter', 'url(#svg-gooey-filter)').attr('class', 'cities annual-conferences');
function mouseover(e) { function mouseover(e) {
c = document.getElementById('conference-' + event.target.getAttribute('data-c')); c = document.getElementById('conference-' + d3.event.target.getAttribute('data-c'));
tooltip.innerHTML = '<h3>' + c.querySelector('.title').innerHTML + '</h3>' + tooltip.innerHTML = '<h3>' + c.querySelector('.title').innerHTML + '</h3>' +
'<div class="conference-details">' + c.querySelector('.conference-details').innerHTML + '</div>'; '<div class="conference-details">' + c.querySelector('.conference-details').innerHTML + '</div>';
tooltip.className = 'open'; tooltip.className = 'open';
@ -81,7 +81,7 @@
} }
function click(e) { function click(e) {
l = document.querySelector('#conference-' + event.target.getAttribute('data-c') + ' .conference-link'); l = document.querySelector('#conference-' + d3.event.target.getAttribute('data-c') + ' .conference-link');
window.location.href = l.getAttribute('href'); window.location.href = l.getAttribute('href');
} }

1
app/assets/stylesheets/_application.scss

@ -3059,6 +3059,7 @@ $header-tilt: 8deg;
svg { svg {
vertical-align: middle; vertical-align: middle;
background-color: transparent; background-color: transparent;
width: 100%;
@include _(transition, background-color 1s ease-in-out); @include _(transition, background-color 1s ease-in-out);
&.loaded { &.loaded {

2
app/assets/stylesheets/bumbleberry-settings.json

@ -8,7 +8,7 @@
"and_chr": ["55"], "and_chr": ["55"],
"chrome": ["55"], "chrome": ["55"],
"edge": ["13"], "edge": ["13"],
"firefox": ["48"], "firefox": ["50"],
"ie": ["11"], "ie": ["11"],
"ios_saf": ["8", "9"] "ios_saf": ["8", "9"]
} }

2
app/views/layouts/application.html.haml

@ -20,8 +20,6 @@
%meta{property: 'og:image', content: og_image} %meta{property: 'og:image', content: og_image}
%meta{name: "theme-color", content: @theme_colour} %meta{name: "theme-color", content: @theme_colour}
= yield :head = yield :head
= javascript_include_tag 'https://rawgit.com/niklasvh/html2canvas/master/dist/html2canvas.js'
= javascript_include_tag 'https://cdnjs.cloudflare.com/ajax/libs/amcharts/3.13.0/exporting/canvg.js'
%body{ class: page_style } %body{ class: page_style }
#primary-content #primary-content

Loading…
Cancel
Save