IE11 compatibility fixes

Removing social share buttons from base if IE, except Facebook.
Unrolling restricted property setting loop (weird).
Updating isIE check to support IE11.
This commit is contained in:
Matt Lott 2014-09-24 12:17:08 -07:00
parent f4cee11ebe
commit 73e49f9972
3 changed files with 21 additions and 13 deletions
app
assets/javascripts/workers
templates
views/kinds

View file

@ -65,14 +65,19 @@ self.console = console;
self.importScripts('/javascripts/lodash.js', '/javascripts/world.js', '/javascripts/aether.js');
var restricted = ["XMLHttpRequest", "importScripts", "Worker"];
for(var i = 0; i < restricted.length; ++i) {
// We could do way more from this: http://stackoverflow.com/questions/10653809/making-webworkers-a-safe-environment
Object.defineProperty(self, restricted[i], {
get: function() { throw new Error("Access to that global property is forbidden."); },
configurable: false
});
}
// TODO: setting these in a loop in IE11 throws an error
Object.defineProperty(self, XMLHttpRequest, {
get: function() { throw new Error("Access to XMLHttpRequest is forbidden."); },
configurable: false
});
Object.defineProperty(self, importScripts, {
get: function() { throw new Error("Access to importScripts is forbidden."); },
configurable: false
});
Object.defineProperty(self, Worker, {
get: function() { throw new Error("Access to Worker is forbidden."); },
configurable: false
});
self.transferableSupported = function transferableSupported() {
if (typeof self._transferableSupported !== 'undefined') return self._transferableSupported;

View file

@ -81,10 +81,13 @@ body
a(href='/admin', data-i18n="nav.admin") Admin
.share-buttons
.g-plusone(data-href="http://codecombat.com", data-size="medium")
if !isIE
.g-plusone(data-href="http://codecombat.com", data-size="medium")
.fb-like(data-href="https://www.facebook.com/codecombat", data-send="false", data-layout="button_count", data-width="350", data-show-faces="true", data-ref="coco_footer_#{fbRef}")
a.twitter-follow-button(href="https://twitter.com/CodeCombat", data-show-count="true", data-show-screen-name="false", data-dnt="true", data-align="right", data-i18n="nav.twitter_follow") Follow
iframe.github-star-button(src="http://ghbtns.com/github-btn.html?user=codecombat&repo=codecombat&type=watch&count=true", allowtransparency="true", frameborder="0", scrolling="0", width="110", height="20")
if !isIE
a.twitter-follow-button(href="https://twitter.com/CodeCombat", data-show-count="true", data-show-screen-name="false", data-dnt="true", data-align="right", data-i18n="nav.twitter_follow") Follow
iframe.github-star-button(src="http://ghbtns.com/github-btn.html?user=codecombat&repo=codecombat&type=watch&count=true", allowtransparency="true", frameborder="0", scrolling="0", width="110", height="20")
.partner-badges
a.mixpanel-badge(href="https://mixpanel.com/f/partner")
img(src="//cdn.mxpnl.com/site_media/images/partner/badge_light.png", alt="Mobile Analytics")

View file

@ -313,8 +313,8 @@ module.exports = class CocoView extends Backbone.View
return mobileRELong.test(ua) or mobileREShort.test(ua.substr(0, 4))
isIE: ->
ua = navigator.userAgent or navigator.vendor or window.opera
return ua.search('MSIE') != -1
# http://stackoverflow.com/questions/19999388/jquery-check-if-user-is-using-ie
navigator.userAgent.indexOf('MSIE') > 0 or !!navigator.userAgent.match(/Trident.*rv\:11\./)
isMac: ->
navigator.platform.toUpperCase().indexOf('MAC') isnt -1