Replacing SVG polyfill to fix event issues

This commit is contained in:
Bruno Alves de Faria committed 2017-09-05 20:53:20 -03:00
1 parent 233d12c481
commit b6b3a443a2
9 files changed
+24 -30

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
import { Meteor } from 'meteor/meteor';
import writeScript from './lib/writeScript';
// Fix SVG+USE issues
writeScript('svg4everybody.min.js');
Meteor.startup(() => {
// Call the SVG polyfill
window.svg4everybody();
});
+1 -14
View File
@@ -1,19 +1,6 @@
import { $ } from 'meteor/jquery';
import { absoluteUrl } from './lib/absoluteUrl';
import writeScript from './lib/writeScript';
/* jshint -W060 */
// Check if browser is IE and add the polyfill scripts
if (navigator && /MSIE \d|Trident.*rv:/.test(navigator.userAgent)) {
const writeScript = fileName => {
const src = absoluteUrl(`/packages/ohif_polyfill/public/js/${fileName}`);
document.write(`<script src="${src}"><\/script>`);
};
writeScript('svgxuse.min.js');
writeScript('typedarray.min.js');
window.addEventListener('click', event => {
if (!window.SVGElementInstance || !(event.target instanceof SVGElementInstance)) return;
$(event.target.correspondingUseElement).trigger('click');
}, true);
}
+2 -1
View File
@@ -1 +1,2 @@
import './ie';
import './all.js';
import './ie.js';
@@ -1,10 +1,10 @@
import { Meteor } from 'meteor/meteor';
export const absoluteUrl = function(path) {
export default function(path) {
if (path) {
// Remove the leading "/"
path = path.replace(/^\//, '');
}
return Meteor.absoluteUrl(path);
};
}
@@ -0,0 +1,7 @@
/* jshint -W060 */
import absoluteUrl from './absoluteUrl';
export default function(fileName) {
const src = absoluteUrl(`/packages/ohif_polyfill/public/js/${fileName}`);
document.write(`<script src="${src}"><\/script>`);
}