From 6a8a428b6c33b5e81d5224ec1b110ef175b07a99 Mon Sep 17 00:00:00 2001 From: Triangle717 Date: Tue, 18 Nov 2014 10:59:27 -0500 Subject: [PATCH] For #46. --- Gruntfile.js | 2 +- README.md | 7 ++----- dist/jquery.browser.js | 14 ++++++++------ test/test.js | 27 ++++++++++++++------------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 0291f8a..bf401eb 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,7 +2,7 @@ module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), jshint: { - files: ['gruntfile.js', 'jquery.browser.js', 'test/test.js'], + files: ['Gruntfile.js', 'dist/jquery.browser.js', 'test/test.js'], options: { globals: { diff --git a/README.md b/README.md index 6b29fc3..2a48746 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Include script *after* the jQuery library: ## Usage -Returns true if the current useragent is some version of Microsoft's Internet Explorer. Supports all IE versions including IE11 +Returns true if the current useragent is some version of Microsoft's Internet Explorer. Supports all IE versions including IE 12. $.browser.msie; @@ -66,7 +66,7 @@ Reading the browser verion $.browser.versionNumber // Returns 32 as a number ``` -- Support for new useragent on IE11 +- Support for new useragent on IE 11 and IE 12 - Support for WebKit based Opera browsers - Added testing using PhantomJS and different browser user agents @@ -94,6 +94,3 @@ Once Casperjs and the grunt-cli npm package is installed you can execute all the - [Examples and original implementation](http://api.jquery.com/jQuery.browser/) - [Original Gist used for the plugin](https://gist.github.com/adeelejaz/4714079) - -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/gabceb/jquery-browser-plugin/trend.png)](https://bitdeli.com/free "Bitdeli Badge") - diff --git a/dist/jquery.browser.js b/dist/jquery.browser.js index c312d74..a56e816 100644 --- a/dist/jquery.browser.js +++ b/dist/jquery.browser.js @@ -17,7 +17,7 @@ if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['jquery'], function ($) { - factory($, root); + factory($, root); }); } else { // Browser globals @@ -34,7 +34,8 @@ var match = /(edge)\/([\w.]+)/.exec( ua ) || /(opr)[\/]([\w.]+)/.exec( ua ) || /(chrome)[ \/]([\w.]+)/.exec( ua ) || - /(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) || + /(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) || + /(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) || /(webkit)[ \/]([\w.]+)/.exec( ua ) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || /(msie) ([\w.]+)/.exec( ua ) || @@ -49,12 +50,13 @@ /(win)/.exec( ua ) || /(mac)/.exec( ua ) || /(linux)/.exec( ua ) || - /(cros)/i.exec( ua ) || + /(cros)/.exec( ua ) || []; return { - browser: match[ 3 ] || match[ 1 ] || "", - version: match[ 2 ] || "0", + browser: match[ 5 ] || match[ 3 ] || match[ 1 ] || "", + version: match[ 2 ] || match[ 4 ] || "0", + versionNumber: match[ 4 ] || match[ 2 ] || "0", platform: platform_match[ 0 ] || "" }; }; @@ -65,7 +67,7 @@ if ( matched.browser ) { browser[ matched.browser ] = true; browser.version = matched.version; - browser.versionNumber = parseInt(matched.version); + browser.versionNumber = parseInt(matched.versionNumber, 10); } if ( matched.platform ) { diff --git a/test/test.js b/test/test.js index e12beb8..82e3937 100644 --- a/test/test.js +++ b/test/test.js @@ -398,8 +398,9 @@ casper.test.begin("when using IE10", 7, function(test) { }); }); -casper.test.begin("when using IE11", 7, function(test) { - casper.userAgent(ua.ie.windows.v_11); + +casper.test.begin("when using IE10 on a Windows Phone", 7, function(test) { + casper.userAgent(ua.ie.win_phone.v_10); casper.start(test_url).then(function(){ @@ -410,21 +411,21 @@ casper.test.begin("when using IE11", 7, function(test) { test.assert(browser.msie, "Browser should be IE"); test.assertEquals(browser.name, ua.ie.name,"Browser name should be " + ua.ie.name); - test.assertEquals(browser.version, "11.0", "Version should be 11.0"); - test.assertEquals(browser.versionNumber, 11, "Version should be 11"); + test.assertEquals(browser.version, "10.0", "Version should be 10.0"); + test.assertEquals(browser.versionNumber, 10, "Version should be 10"); - test.assert(browser.desktop, "Browser platform should be desktop"); - test.assert(browser.win, "Platform should be Windows"); + test.assert(browser.mobile, "Browser platform should be mobile"); + test.assert(browser["windows phone"], "Platform should be Windows Phone"); test.assertFalsy(browser.webkit, "Browser should NOT be WebKit based"); }).run(function(){ - test.done(); + test.done(); }); }); -casper.test.begin("when using IE10 on a Windows Phone", 7, function(test) { - casper.userAgent(ua.ie.win_phone.v_10); +casper.test.begin("when using IE11", 7, function(test) { + casper.userAgent(ua.ie.windows.v_11); casper.start(test_url).then(function(){ @@ -435,11 +436,11 @@ casper.test.begin("when using IE10 on a Windows Phone", 7, function(test) { test.assert(browser.msie, "Browser should be IE"); test.assertEquals(browser.name, ua.ie.name,"Browser name should be " + ua.ie.name); - test.assertEquals(browser.version, "10.0", "Version should be 10.0"); - test.assertEquals(browser.versionNumber, 10, "Version should be 10"); + test.assertEquals(browser.version, "11.0", "Version should be 11.0"); + test.assertEquals(browser.versionNumber, 11, "Version should be 11"); - test.assert(browser.mobile, "Browser platform should be mobile"); - test.assert(browser["windows phone"], "Platform should be Windows Phone"); + test.assert(browser.desktop, "Browser platform should be desktop"); + test.assert(browser.win, "Platform should be Windows"); test.assertFalsy(browser.webkit, "Browser should NOT be WebKit based");