From dccfa48491d49cce22d3887a8781f5a1bfafdef7 Mon Sep 17 00:00:00 2001 From: Godwin Date: Sat, 31 Dec 2016 07:09:15 -0800 Subject: [PATCH] Fixed JS errors on map --- app/assets/javascripts/main.js | 47 ------------------- app/assets/javascripts/map.js | 4 +- app/assets/stylesheets/_application.scss | 1 + .../stylesheets/bumbleberry-settings.json | 2 +- app/views/layouts/application.html.haml | 2 - 5 files changed, 4 insertions(+), 52 deletions(-) diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index da2e8ce..d467b08 100644 --- a/app/assets/javascripts/main.js +++ b/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 = '' + svg.innerHTML; - svg.innerHTML = '' + 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'); - } - }); -} diff --git a/app/assets/javascripts/map.js b/app/assets/javascripts/map.js index 588f543..b0dd9bb 100644 --- a/app/assets/javascripts/map.js +++ b/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'); function mouseover(e) { - c = document.getElementById('conference-' + event.target.getAttribute('data-c')); + c = document.getElementById('conference-' + d3.event.target.getAttribute('data-c')); tooltip.innerHTML = '

' + c.querySelector('.title').innerHTML + '

' + '
' + c.querySelector('.conference-details').innerHTML + '
'; tooltip.className = 'open'; @@ -81,7 +81,7 @@ } 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'); } diff --git a/app/assets/stylesheets/_application.scss b/app/assets/stylesheets/_application.scss index 6724dd2..304f704 100644 --- a/app/assets/stylesheets/_application.scss +++ b/app/assets/stylesheets/_application.scss @@ -3059,6 +3059,7 @@ $header-tilt: 8deg; svg { vertical-align: middle; background-color: transparent; + width: 100%; @include _(transition, background-color 1s ease-in-out); &.loaded { diff --git a/app/assets/stylesheets/bumbleberry-settings.json b/app/assets/stylesheets/bumbleberry-settings.json index c29efc9..c0bafee 100644 --- a/app/assets/stylesheets/bumbleberry-settings.json +++ b/app/assets/stylesheets/bumbleberry-settings.json @@ -8,7 +8,7 @@ "and_chr": ["55"], "chrome": ["55"], "edge": ["13"], - "firefox": ["48"], + "firefox": ["50"], "ie": ["11"], "ios_saf": ["8", "9"] } diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index a06b9c0..f1d5a0f 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -20,8 +20,6 @@ %meta{property: 'og:image', content: og_image} %meta{name: "theme-color", content: @theme_colour} = 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 } #primary-content