diff options
author | James Nylen <jnylen@gmail.com> | 2014-09-16 07:40:24 -0500 |
---|---|---|
committer | James Nylen <jnylen@gmail.com> | 2014-09-16 07:40:24 -0500 |
commit | 9cc4ab7abfb0a3a9c921d51570903fc2640044df (patch) | |
tree | 7f4578e9b1ee8ce5e112240ab299e79b16115916 | |
parent | 11da1623d8ae40dc435c3a3098342beb1ffb2a59 (diff) | |
download | d3-process-map-origin/fix-ie-markers.zip d3-process-map-origin/fix-ie-markers.tar.gz d3-process-map-origin/fix-ie-markers.tar.bz2 |
Work around IE bug regarding paths with markersorigin/fix-ie-markers
Fixes #6.
-rw-r--r-- | graph.php | 1 | ||||
-rw-r--r-- | jquery/jquery.browser.js | 112 | ||||
-rw-r--r-- | jquery/jquery.browser.min.js | 14 | ||||
-rw-r--r-- | script.js | 11 |
4 files changed, 137 insertions, 1 deletions
@@ -36,6 +36,7 @@ read_config(); </div> </div> <script src="jquery/jquery-1.10.2.min.js"></script> + <script src="jquery/jquery.browser.min.js"></script> <script src="d3/d3.v3.min.js"></script> <script src="colorbrewer.js"></script> <script src="lib/geometry.js"></script> diff --git a/jquery/jquery.browser.js b/jquery/jquery.browser.js new file mode 100644 index 0000000..3bb26d7 --- /dev/null +++ b/jquery/jquery.browser.js @@ -0,0 +1,112 @@ +/*! + * jQuery Browser Plugin v0.0.6 + * https://github.com/gabceb/jquery-browser-plugin + * + * Original jquery-browser code Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors + * http://jquery.org/license + * + * Modifications Copyright 2013 Gabriel Cebrian + * https://github.com/gabceb + * + * Released under the MIT license + * + * Date: 2013-07-29T17:23:27-07:00 + */ + +(function( jQuery, window, undefined ) { + "use strict"; + + var matched, browser; + + jQuery.uaMatch = function( ua ) { + ua = ua.toLowerCase(); + + var match = /(opr)[\/]([\w.]+)/.exec( ua ) || + /(chrome)[ \/]([\w.]+)/.exec( ua ) || + /(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) || + /(webkit)[ \/]([\w.]+)/.exec( ua ) || + /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || + /(msie) ([\w.]+)/.exec( ua ) || + ua.indexOf("trident") >= 0 && /(rv)(?::| )([\w.]+)/.exec( ua ) || + ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || + []; + + var platform_match = /(ipad)/.exec( ua ) || + /(iphone)/.exec( ua ) || + /(android)/.exec( ua ) || + /(windows phone)/.exec( ua ) || + /(win)/.exec( ua ) || + /(mac)/.exec( ua ) || + /(linux)/.exec( ua ) || + /(cros)/i.exec( ua ) || + []; + + return { + browser: match[ 3 ] || match[ 1 ] || "", + version: match[ 2 ] || "0", + platform: platform_match[ 0 ] || "" + }; + }; + + matched = jQuery.uaMatch( window.navigator.userAgent ); + browser = {}; + + if ( matched.browser ) { + browser[ matched.browser ] = true; + browser.version = matched.version; + browser.versionNumber = parseInt(matched.version); + } + + if ( matched.platform ) { + browser[ matched.platform ] = true; + } + + // These are all considered mobile platforms, meaning they run a mobile browser + if ( browser.android || browser.ipad || browser.iphone || browser[ "windows phone" ] ) { + browser.mobile = true; + } + + // These are all considered desktop platforms, meaning they run a desktop browser + if ( browser.cros || browser.mac || browser.linux || browser.win ) { + browser.desktop = true; + } + + // Chrome, Opera 15+ and Safari are webkit based browsers + if ( browser.chrome || browser.opr || browser.safari ) { + browser.webkit = true; + } + + // IE11 has a new token so we will assign it msie to avoid breaking changes + if ( browser.rv ) + { + var ie = "msie"; + + matched.browser = ie; + browser[ie] = true; + } + + // Opera 15+ are identified as opr + if ( browser.opr ) + { + var opera = "opera"; + + matched.browser = opera; + browser[opera] = true; + } + + // Stock Android browsers are marked as Safari on Android. + if ( browser.safari && browser.android ) + { + var android = "android"; + + matched.browser = android; + browser[android] = true; + } + + // Assign the name and platform variable + browser.name = matched.browser; + browser.platform = matched.platform; + + + jQuery.browser = browser; +})( jQuery, window );
\ No newline at end of file diff --git a/jquery/jquery.browser.min.js b/jquery/jquery.browser.min.js new file mode 100644 index 0000000..eadf06e --- /dev/null +++ b/jquery/jquery.browser.min.js @@ -0,0 +1,14 @@ +/*! + * jQuery Browser Plugin 0.0.6 + * https://github.com/gabceb/jquery-browser-plugin + * + * Original jquery-browser code Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors + * http://jquery.org/license + * + * Modifications Copyright 2014 Gabriel Cebrian + * https://github.com/gabceb + * + * Released under the MIT license + * + * Date: 30-03-2014 + */!function(a,b){"use strict";var c,d;if(a.uaMatch=function(a){a=a.toLowerCase();var b=/(opr)[\/]([\w.]+)/.exec(a)||/(chrome)[ \/]([\w.]+)/.exec(a)||/(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(a)||/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||a.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(a)||a.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(a)||[],c=/(ipad)/.exec(a)||/(iphone)/.exec(a)||/(android)/.exec(a)||/(windows phone)/.exec(a)||/(win)/.exec(a)||/(mac)/.exec(a)||/(linux)/.exec(a)||/(cros)/i.exec(a)||[];return{browser:b[3]||b[1]||"",version:b[2]||"0",platform:c[0]||""}},c=a.uaMatch(b.navigator.userAgent),d={},c.browser&&(d[c.browser]=!0,d.version=c.version,d.versionNumber=parseInt(c.version)),c.platform&&(d[c.platform]=!0),(d.android||d.ipad||d.iphone||d["windows phone"])&&(d.mobile=!0),(d.cros||d.mac||d.linux||d.win)&&(d.desktop=!0),(d.chrome||d.opr||d.safari)&&(d.webkit=!0),d.rv){var e="msie";c.browser=e,d[e]=!0}if(d.opr){var f="opera";c.browser=f,d[f]=!0}if(d.safari&&d.android){var g="android";c.browser=g,d[g]=!0}d.name=c.browser,d.platform=c.platform,a.browser=d}(jQuery,window);
\ No newline at end of file @@ -1,10 +1,13 @@ var graph = {}, selected = {}, - highlighted = null; + highlighted = null, + isIE = false; $(function() { resize(); + isIE = $.browser.msie; + d3.json(config.jsonUrl, function(data) { if (data.errors.length) { alert('Data error(s):\n\n' + data.errors.join('\n')); @@ -497,6 +500,12 @@ function tick(e) { return d.source.y; }) .each(function(d) { + if (isIE) { + // Work around IE bug regarding paths with markers + // Credit: #6 and http://stackoverflow.com/a/18475039/106302 + this.parentNode.insertBefore(this, this); + } + var x = d.target.x, y = d.target.y, line = new geo.LineSegment(d.source.x, d.source.y, x, y); |