Merge pull request #2848 from storytouch/develop

Update the bowser.js to the new version
This commit is contained in:
John McLear 2015-12-01 17:47:00 +00:00
commit 16bb28a0ff
4 changed files with 92 additions and 26 deletions

View File

@ -21,7 +21,7 @@
*/ */
var _, $, jQuery, plugins, Ace2Common; var _, $, jQuery, plugins, Ace2Common;
var browser = require('./browser').browser; var browser = require('./browser');
if(browser.msie){ if(browser.msie){
// Honestly fuck IE royally. // Honestly fuck IE royally.
// Basically every hack we have since V11 causes a problem // Basically every hack we have since V11 causes a problem

View File

@ -1,11 +1,11 @@
/*! /*!
* Bowser - a browser detector * Bowser - a browser detector
* https://github.com/ded/bowser * https://github.com/ded/bowser
* MIT License | (c) Dustin Diaz 2014 * MIT License | (c) Dustin Diaz 2015
*/ */
!function (name, definition) { !function (name, definition) {
if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition() if (typeof module != 'undefined' && module.exports) module.exports = definition()
else if (typeof define == 'function' && define.amd) define(definition) else if (typeof define == 'function' && define.amd) define(definition)
else this[name] = definition() else this[name] = definition()
}('bowser', function () { }('bowser', function () {
@ -22,9 +22,24 @@
return (match && match.length > 1 && match[1]) || ''; return (match && match.length > 1 && match[1]) || '';
} }
function getSecondMatch(regex) {
var match = ua.match(regex);
return (match && match.length > 1 && match[2]) || '';
}
var iosdevice = getFirstMatch(/(ipod|iphone|ipad)/i).toLowerCase() var iosdevice = getFirstMatch(/(ipod|iphone|ipad)/i).toLowerCase()
, likeAndroid = /like android/i.test(ua) , likeAndroid = /like android/i.test(ua)
, android = !likeAndroid && /android/i.test(ua) , android = !likeAndroid && /android/i.test(ua)
, chromeos = /CrOS/.test(ua)
, silk = /silk/i.test(ua)
, sailfish = /sailfish/i.test(ua)
, tizen = /tizen/i.test(ua)
, webos = /(web|hpw)os/i.test(ua)
, windowsphone = /windows phone/i.test(ua)
, windows = !windowsphone && /windows/i.test(ua)
, mac = !iosdevice && !silk && /macintosh/i.test(ua)
, linux = !android && !sailfish && !tizen && !webos && /linux/i.test(ua)
, edgeVersion = getFirstMatch(/edge\/(\d+(\.\d+)?)/i)
, versionIdentifier = getFirstMatch(/version\/(\d+(\.\d+)?)/i) , versionIdentifier = getFirstMatch(/version\/(\d+(\.\d+)?)/i)
, tablet = /tablet/i.test(ua) , tablet = /tablet/i.test(ua)
, mobile = !tablet && /[^-]mobi/i.test(ua) , mobile = !tablet && /[^-]mobi/i.test(ua)
@ -37,12 +52,25 @@
, version: versionIdentifier || getFirstMatch(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i) , version: versionIdentifier || getFirstMatch(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i)
} }
} }
else if (/windows phone/i.test(ua)) { else if (/yabrowser/i.test(ua)) {
result = {
name: 'Yandex Browser'
, yandexbrowser: t
, version: versionIdentifier || getFirstMatch(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)
}
}
else if (windowsphone) {
result = { result = {
name: 'Windows Phone' name: 'Windows Phone'
, windowsphone: t , windowsphone: t
, msie: t }
, version: getFirstMatch(/iemobile\/(\d+(\.\d+)?)/i) if (edgeVersion) {
result.msedge = t
result.version = edgeVersion
}
else {
result.msie = t
result.version = getFirstMatch(/iemobile\/(\d+(\.\d+)?)/i)
} }
} }
else if (/msie|trident/i.test(ua)) { else if (/msie|trident/i.test(ua)) {
@ -51,6 +79,20 @@
, msie: t , msie: t
, version: getFirstMatch(/(?:msie |rv:)(\d+(\.\d+)?)/i) , version: getFirstMatch(/(?:msie |rv:)(\d+(\.\d+)?)/i)
} }
} else if (chromeos) {
result = {
name: 'Chrome'
, chromeos: t
, chromeBook: t
, chrome: t
, version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)
}
} else if (/chrome.+? edge/i.test(ua)) {
result = {
name: 'Microsoft Edge'
, msedge: t
, version: edgeVersion
}
} }
else if (/chrome|crios|crmo/i.test(ua)) { else if (/chrome|crios|crmo/i.test(ua)) {
result = { result = {
@ -68,7 +110,7 @@
result.version = versionIdentifier result.version = versionIdentifier
} }
} }
else if (/sailfish/i.test(ua)) { else if (sailfish) {
result = { result = {
name: 'Sailfish' name: 'Sailfish'
, sailfish: t , sailfish: t
@ -92,7 +134,7 @@
result.firefoxos = t result.firefoxos = t
} }
} }
else if (/silk/i.test(ua)) { else if (silk) {
result = { result = {
name: 'Amazon Silk' name: 'Amazon Silk'
, silk: t , silk: t
@ -119,7 +161,7 @@
, version: versionIdentifier || getFirstMatch(/blackberry[\d]+\/(\d+(\.\d+)?)/i) , version: versionIdentifier || getFirstMatch(/blackberry[\d]+\/(\d+(\.\d+)?)/i)
} }
} }
else if (/(web|hpw)os/i.test(ua)) { else if (webos) {
result = { result = {
name: 'WebOS' name: 'WebOS'
, webos: t , webos: t
@ -134,7 +176,7 @@
, version: getFirstMatch(/dolfin\/(\d+(\.\d+)?)/i) , version: getFirstMatch(/dolfin\/(\d+(\.\d+)?)/i)
}; };
} }
else if (/tizen/i.test(ua)) { else if (tizen) {
result = { result = {
name: 'Tizen' name: 'Tizen'
, tizen: t , tizen: t
@ -148,10 +190,15 @@
, version: versionIdentifier , version: versionIdentifier
} }
} }
else result = {} else {
result = {
name: getFirstMatch(/^(.*)\/(.*) /),
version: getSecondMatch(/^(.*)\/(.*) /)
};
}
// set webkit or gecko flag for browsers based on these engines // set webkit or gecko flag for browsers based on these engines
if (/(apple)?webkit/i.test(ua)) { if (!result.msedge && /(apple)?webkit/i.test(ua)) {
result.name = result.name || "Webkit" result.name = result.name || "Webkit"
result.webkit = t result.webkit = t
if (!result.version && versionIdentifier) { if (!result.version && versionIdentifier) {
@ -164,22 +211,28 @@
} }
// set OS flags for platforms that have multiple browsers // set OS flags for platforms that have multiple browsers
if (android || result.silk) { if (!result.msedge && (android || result.silk)) {
result.android = t result.android = t
} else if (iosdevice) { } else if (iosdevice) {
result[iosdevice] = t result[iosdevice] = t
result.ios = t result.ios = t
} else if (windows) {
result.windows = t
} else if (mac) {
result.mac = t
} else if (linux) {
result.linux = t
} }
// OS version extraction // OS version extraction
var osVersion = ''; var osVersion = '';
if (iosdevice) { if (result.windowsphone) {
osVersion = getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i);
} else if (iosdevice) {
osVersion = getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i); osVersion = getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i);
osVersion = osVersion.replace(/[_\s]/g, '.'); osVersion = osVersion.replace(/[_\s]/g, '.');
} else if (android) { } else if (android) {
osVersion = getFirstMatch(/android[ \/-](\d+(\.\d+)*)/i); osVersion = getFirstMatch(/android[ \/-](\d+(\.\d+)*)/i);
} else if (result.windowsphone) {
osVersion = getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i);
} else if (result.webos) { } else if (result.webos) {
osVersion = getFirstMatch(/(?:web|hpw)os\/(\d+(\.\d+)*)/i); osVersion = getFirstMatch(/(?:web|hpw)os\/(\d+(\.\d+)*)/i);
} else if (result.blackberry) { } else if (result.blackberry) {
@ -203,7 +256,9 @@
// Graded Browser Support // Graded Browser Support
// http://developer.yahoo.com/yui/articles/gbs // http://developer.yahoo.com/yui/articles/gbs
if ((result.msie && result.version >= 10) || if (result.msedge ||
(result.msie && result.version >= 10) ||
(result.yandexbrowser && result.version >= 15) ||
(result.chrome && result.version >= 20) || (result.chrome && result.version >= 20) ||
(result.firefox && result.version >= 20.0) || (result.firefox && result.version >= 20.0) ||
(result.safari && result.version >= 6) || (result.safari && result.version >= 6) ||
@ -228,6 +283,17 @@
var bowser = detect(typeof navigator !== 'undefined' ? navigator.userAgent : '') var bowser = detect(typeof navigator !== 'undefined' ? navigator.userAgent : '')
bowser.test = function (browserList) {
for (var i = 0; i < browserList.length; ++i) {
var browserItem = browserList[i];
if (typeof browserItem=== 'string') {
if (browserItem in bowser) {
return true;
}
}
}
return false;
}
/* /*
* Set our detect method to the main bowser object so we can * Set our detect method to the main bowser object so we can
@ -237,4 +303,4 @@
bowser._detect = detect; bowser._detect = detect;
return bowser return bowser
}); });

View File

@ -390,7 +390,7 @@
require.setGlobalKeyPath("require"); require.setGlobalKeyPath("require");
$ = jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery; // Expose jQuery #HACK $ = jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery; // Expose jQuery #HACK
browser = require('ep_etherpad-lite/static/js/browser').browser; browser = require('ep_etherpad-lite/static/js/browser');
if ((!browser.msie) && (!(browser.mozilla && browser.version.indexOf("1.8.") == 0))) { if ((!browser.msie) && (!(browser.mozilla && browser.version.indexOf("1.8.") == 0))) {
document.domain = document.domain; // for comet document.domain = document.domain; // for comet
} }

View File

@ -68,7 +68,7 @@
<button class="stepper" id="rightstep"></button> <button class="stepper" id="rightstep"></button>
</div> </div>
</div> </div>
<div id="overlay"> <div id="overlay">
<div id="overlay-inner"> <div id="overlay-inner">
<!-- --> <!-- -->
@ -231,20 +231,20 @@
<!-- Bootstrap --> <!-- Bootstrap -->
<script type="text/javascript" > <script type="text/javascript" >
var clientVars = {}; var clientVars = {};
var BroadcastSlider; var BroadcastSlider;
(function () { (function () {
var pathComponents = location.pathname.split('/'); var pathComponents = location.pathname.split('/');
// Strip 'p', the padname and 'timeslider' from the pathname and set as baseURL // Strip 'p', the padname and 'timeslider' from the pathname and set as baseURL
var baseURL = pathComponents.slice(0,pathComponents.length-3).join('/') + '/'; var baseURL = pathComponents.slice(0,pathComponents.length-3).join('/') + '/';
require.setRootURI(baseURL + "javascripts/src"); require.setRootURI(baseURL + "javascripts/src");
require.setLibraryURI(baseURL + "javascripts/lib"); require.setLibraryURI(baseURL + "javascripts/lib");
require.setGlobalKeyPath("require"); require.setGlobalKeyPath("require");
$ = jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery; // Expose jQuery #HACK $ = jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery; // Expose jQuery #HACK
browser = require('ep_etherpad-lite/static/js/browser').browser; browser = require('ep_etherpad-lite/static/js/browser');
if ((!browser.msie) && (!(browser.mozilla && browser.version.indexOf("1.8.") == 0))) { if ((!browser.msie) && (!(browser.mozilla && browser.version.indexOf("1.8.") == 0))) {
document.domain = document.domain; // for comet document.domain = document.domain; // for comet
@ -254,7 +254,7 @@
var socket = require('ep_etherpad-lite/static/js/timeslider').socket; var socket = require('ep_etherpad-lite/static/js/timeslider').socket;
BroadcastSlider = require('ep_etherpad-lite/static/js/timeslider').BroadcastSlider; BroadcastSlider = require('ep_etherpad-lite/static/js/timeslider').BroadcastSlider;
plugins.baseURL = baseURL; plugins.baseURL = baseURL;
plugins.update(function () { plugins.update(function () {
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
hooks.plugins = plugins; hooks.plugins = plugins;