From 2ef3b4e295a8908f0f4995ed4f3ee81c369d6d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Ga=C5=82uszka?= Date: Sun, 5 Jan 2014 20:20:45 +0100 Subject: [PATCH 1/2] Fixed #1709 and added information for not supported old browsers --- js/gittip/upgrade.js | 47 +++++++++++++++++++++++++++++++++++++++++++ scss/gittip.scss | 2 +- scss/lib/upgrade.scss | 6 ++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 js/gittip/upgrade.js create mode 100644 scss/lib/upgrade.scss diff --git a/js/gittip/upgrade.js b/js/gittip/upgrade.js new file mode 100644 index 0000000000..a268d227ff --- /dev/null +++ b/js/gittip/upgrade.js @@ -0,0 +1,47 @@ +Gittip.upgrade = {}; + +Gittip.upgrade.init = function () { + + var browserSupport = new Gittip.upgrade.BrowserSupport(); + browserSupport.isSupportedBrowser(); +}; + +Gittip.upgrade.BrowserSupport = function () { + this.userAgent = navigator.userAgent.toLowerCase(); +} + +Gittip.upgrade.BrowserSupport.prototype = { + /* + If method return -1 then this isn't IE browser. + Also this work only to IE10. IE 11 has different user agent. (notice for future for gittip) + */ + detectIEVersion: function () { + return (this.userAgent.indexOf('msie') != -1) ? parseInt(this.userAgent.split('msie')[1]) : -1; + }, + + detectBrowser: function () { + this.browser = this.detectIEVersion(); + }, + + isSupportedBrowser: function () { + this.detectBrowser() + // is this old IE? + if(this.browser != -1 && this.browser < 9){ + this.showMessage(); + } + }, + + showMessage: function () { + var message = '' + + '
' + + '
' + + 'This browser isn\'t supported by GitTip.com. ' + + 'We encourage You to upgrade or change browser. ' + + 'Learn more' + + '
' + + '
'; + $("body").prepend(message); + } +} + +$(document).ready(Gittip.upgrade.init); \ No newline at end of file diff --git a/scss/gittip.scss b/scss/gittip.scss index fd49e1d158..b70cd3f785 100644 --- a/scss/gittip.scss +++ b/scss/gittip.scss @@ -17,7 +17,7 @@ @import "lib/dropdown"; // You guessed it... dropdowns. @import "lib/chart"; - +@import "lib/upgrade"; // Page layout styles diff --git a/scss/lib/upgrade.scss b/scss/lib/upgrade.scss new file mode 100644 index 0000000000..e4b6cdbbb7 --- /dev/null +++ b/scss/lib/upgrade.scss @@ -0,0 +1,6 @@ +#upgrade_browser { + background: #FFFE26; + width: 100%; + height: auto; + padding: 5px; +} From 4472dc095149b11dfff3d6795797e165d9bbc3ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Ga=C5=82uszka?= Date: Wed, 8 Jan 2014 14:18:42 +0100 Subject: [PATCH 2/2] added suggestions to code --- js/gittip/upgrade.js | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/js/gittip/upgrade.js b/js/gittip/upgrade.js index a268d227ff..255b22dc48 100644 --- a/js/gittip/upgrade.js +++ b/js/gittip/upgrade.js @@ -2,36 +2,10 @@ Gittip.upgrade = {}; Gittip.upgrade.init = function () { - var browserSupport = new Gittip.upgrade.BrowserSupport(); - browserSupport.isSupportedBrowser(); -}; - -Gittip.upgrade.BrowserSupport = function () { - this.userAgent = navigator.userAgent.toLowerCase(); -} - -Gittip.upgrade.BrowserSupport.prototype = { - /* - If method return -1 then this isn't IE browser. - Also this work only to IE10. IE 11 has different user agent. (notice for future for gittip) - */ - detectIEVersion: function () { - return (this.userAgent.indexOf('msie') != -1) ? parseInt(this.userAgent.split('msie')[1]) : -1; - }, + var userAgent = navigator.userAgent.toLowerCase(); + var browser = (userAgent.indexOf('msie') != -1) ? parseInt(userAgent.split('msie')[1]) : -1; - detectBrowser: function () { - this.browser = this.detectIEVersion(); - }, - - isSupportedBrowser: function () { - this.detectBrowser() - // is this old IE? - if(this.browser != -1 && this.browser < 9){ - this.showMessage(); - } - }, - - showMessage: function () { + if(browser != -1 && browser < 9) { var message = '' + '
' + '
' + @@ -42,6 +16,6 @@ Gittip.upgrade.BrowserSupport.prototype = { '
'; $("body").prepend(message); } -} +}; $(document).ready(Gittip.upgrade.init); \ No newline at end of file