2013-04-01 15:17:10 -04:00
|
|
|
//browser-update.org notification script, <browser-update.org>
|
|
|
|
//Copyright (c) 2007-2009, MIT Style License <browser-update.org/LICENSE.txt>
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
|
2013-04-02 02:44:08 -04:00
|
|
|
var $buo = function() {
|
|
|
|
|
2013-12-02 14:18:33 -05:00
|
|
|
var badAndroid = false, ua = null;
|
|
|
|
|
|
|
|
// Sometimes we have to resort to parsing the user agent string. :(
|
|
|
|
if (navigator && navigator.userAgent) {
|
|
|
|
ua = navigator.userAgent;
|
|
|
|
}
|
|
|
|
if (ua && (ua.indexOf('Android 2.2') >= 0 || ua.indexOf('Android 2.3') >= 0)) {
|
|
|
|
// Android 2.2 and 2.3 browsers report that they have pushState, but they don't really.
|
|
|
|
// See http://caniuse.com/#search=pushstate
|
|
|
|
badAndroid = true;
|
|
|
|
}
|
|
|
|
|
2013-04-02 02:44:08 -04:00
|
|
|
// sam: my main concern here is mobile, but its an outlier, for now we support ie9, set conditionally and stuff with pushState
|
2013-12-02 14:18:33 -05:00
|
|
|
if (window.ie === "new" || (window.history && window.history.pushState && !badAndroid)) {
|
2013-04-02 02:44:08 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-02 03:42:59 -04:00
|
|
|
// retrieve localized browser upgrade text
|
2013-11-27 12:26:27 -05:00
|
|
|
var t = <%= "'" + I18n.t('js.browser_update') + "'" %>;
|
2013-04-02 02:44:08 -04:00
|
|
|
|
2013-04-02 03:42:59 -04:00
|
|
|
// create the notification div HTML
|
2013-04-02 02:44:08 -04:00
|
|
|
var div = document.createElement("div");
|
2013-04-02 03:42:59 -04:00
|
|
|
div.className = "buorg";
|
|
|
|
div.innerHTML = "<div>" + t + "</div>";
|
2013-04-02 02:44:08 -04:00
|
|
|
|
2013-04-02 03:42:59 -04:00
|
|
|
// create the notification div stylesheet
|
2013-04-02 02:44:08 -04:00
|
|
|
var sheet = document.createElement("style");
|
2013-04-02 03:42:59 -04:00
|
|
|
var style = ".buorg {position:absolute; z-index:111111; width:100%; top:0px; left:0px; background:#FDF2AB; text-align:left; font-family: sans-serif; color:#000; font-size: 14px;} .buorg div {padding: 8px;} .buorg a, .buorg a:visited {color:#E25600; text-decoration: underline;}";
|
2013-04-02 02:44:08 -04:00
|
|
|
|
2013-04-02 03:42:59 -04:00
|
|
|
// insert the div and stylesheet into the DOM
|
|
|
|
document.body.insertBefore(div, document.body.firstChild);
|
2013-04-02 02:44:08 -04:00
|
|
|
document.getElementsByTagName("head")[0].appendChild(sheet);
|
|
|
|
try {
|
2013-04-02 03:42:59 -04:00
|
|
|
sheet.innerText = style;
|
|
|
|
sheet.innerHTML = style;
|
2013-04-02 02:44:08 -04:00
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
try {
|
|
|
|
sheet.styleSheet.cssText = style;
|
2013-04-01 15:17:10 -04:00
|
|
|
}
|
2013-04-02 02:44:08 -04:00
|
|
|
catch(ex) {
|
|
|
|
return;
|
2013-04-01 15:17:10 -04:00
|
|
|
}
|
2013-04-02 02:44:08 -04:00
|
|
|
}
|
2013-04-01 15:17:10 -04:00
|
|
|
|
2013-04-02 03:42:59 -04:00
|
|
|
// shift the body down to make room for our notification div
|
|
|
|
document.body.style.marginTop = (div.clientHeight) + "px";
|
2013-04-01 15:17:10 -04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2013-11-27 12:26:27 -05:00
|
|
|
$bu=$buo();
|
2013-04-01 15:17:10 -04:00
|
|
|
|
2013-04-02 03:42:59 -04:00
|
|
|
})(this);
|