Skip to content

Commit

Permalink
Update dist file.
Browse files Browse the repository at this point in the history
(cherry picked from commit ade6a09)
  • Loading branch information
cssmagic committed May 25, 2016
1 parent a7cdb54 commit 3c72a03
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
49 changes: 25 additions & 24 deletions dist/gearbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void function (window, gearbox) {
}

// sub-string
str.include = function (str, needle, position) {
str.includes = function (str, needle, position) {
if (needle === '') return true
position = position == null ? 0 : Math.min(toPositive(position), str.length)
return makeString(str).slice(position).indexOf(needle) !== -1
Expand All @@ -128,8 +128,9 @@ void function (window, gearbox) {
}

// aliases
str.contains = str.include
str.includes = str.include
str.contains = str.includes
// @DEPRECATED
str.include = str.includes

//////////////////// END: alternative to underscore.string ////////////////////

Expand Down Expand Up @@ -195,7 +196,6 @@ void function (window, gearbox) {
}
return result
},
isPlainObject: $.isPlainObject
}

gearbox.__defineModule('root', root)
Expand All @@ -221,10 +221,11 @@ void function (window, gearbox) {

function _detect(ua) {
var s = ua.str.toLowerCase()
var _includes = gearbox.str.includes

ua.isSafari = /\bapple\b/i.test(navigator.vendor) && /\bsafari\b/i.test(s)
ua.isChrome = gearbox.str.include(s, 'chrome') ||
gearbox.str.include(s, 'crios') // both desktop and mobile version
ua.isChrome = _includes(s, 'chrome') ||
_includes(s, 'crios') // both desktop and mobile version

// platform version and device
ua.osVersion = ''
Expand All @@ -236,7 +237,7 @@ void function (window, gearbox) {
ua.osVersion = (/[\/; i]os[\/: _](\d+(?:[\._]\d+)?)[\._; ]/.exec(s) || [0, ''])[1]
.replace('_', '.')
} else {
var _includeAndroid = gearbox.str.include(s, 'android')
var _includeAndroid = _includes(s, 'android')
var _includeAdr = /\badr\b/.test(s) && /\blinux;\s*u;/.test(s)
var _isJUC = /juc\s*\(linux;\s*u;\s*\d+\.\d+/.test(s)
ua.isAndroid = _includeAndroid || _includeAdr || _isJUC
Expand All @@ -250,38 +251,38 @@ void function (window, gearbox) {
}
}
// fix - Windows Phone might pretend to be iOS or Android
if (gearbox.str.include(s, 'windows phone')) {
if (_includes(s, 'windows phone')) {
ua.isIOS = ua.isAndroid = false
ua.osVersion = ''
}
if (ua.osVersion && !gearbox.str.include(ua.osVersion, '.')) ua.osVersion += '.0'
if (ua.osVersion && !_includes(ua.osVersion, '.')) ua.osVersion += '.0'

// summery
ua.isMobileDevice = !!(ua.isIOS || ua.isAndroid)

// get browser info
var browser = ''
if (gearbox.str.include(s, 'micromessenger')) {
if (_includes(s, 'micromessenger')) {
browser = 'wechat'
} else if (gearbox.str.include(s, 'ucbrowser') || gearbox.str.include(s, 'ucweb') || gearbox.str.include(s, ' uc applewebkit')) {
} else if (_includes(s, 'ucbrowser') || _includes(s, 'ucweb') || _includes(s, ' uc applewebkit')) {
browser = 'uc'
} else if (gearbox.str.include(s, 'baiduhd') || gearbox.str.include(s, 'baiduboxapp')) {
} else if (_includes(s, 'baiduhd') || _includes(s, 'baiduboxapp')) {
browser = 'baidu-app'
} else if (gearbox.str.include(s, 'baidubrowser')) {
} else if (_includes(s, 'baidubrowser')) {
browser = 'baidu-browser'
} else if (gearbox.str.include(s, 'mqqbrowser')) {
} else if (_includes(s, 'mqqbrowser')) {
browser = 'm-qq-browser'
} else if (gearbox.str.include(s, 'miuibrowser')) {
} else if (_includes(s, 'miuibrowser')) {
browser = 'miui'
} else if (gearbox.str.include(s, '_weibo_') || gearbox.str.include(s, ' weibo ')) {
} else if (_includes(s, '_weibo_') || _includes(s, ' weibo ')) {
browser = 'weibo'
} else if (gearbox.str.include(s, 'firefox')) {
} else if (_includes(s, 'firefox')) {
browser = 'firefox'
} else if (gearbox.str.include(s, 'opera')) {
} else if (_includes(s, 'opera')) {
browser = 'opera'
} else if (gearbox.str.include(s, ' edge/')) {
} else if (_includes(s, ' edge/')) {
browser = 'edge'
} else if (gearbox.str.include(s, 'iemobile')) {
} else if (_includes(s, 'iemobile')) {
browser = 'ie-mobile'
}
// these two must be the last
Expand Down Expand Up @@ -311,15 +312,15 @@ void function (window, gearbox) {
}
}
if (!engine) {
if (gearbox.str.include(s, 'webkit')) {
if (_includes(s, 'webkit')) {
engine = 'webkit'
} else if (ua.isIOS) {
engine = 'webkit'
} else if (ua.isAndroid && browser === 'm-qq-browser') {
engine = 'webkit'
}
if (browser === 'firefox' && !ua.isIOS) engine = 'gecko'
if (browser === 'opera' && !ua.isIOS && gearbox.str.include(s, 'presto')) engine = 'presto'
if (browser === 'opera' && !ua.isIOS && _includes(s, 'presto')) engine = 'presto'
}
// fix Windows Phone, IE Mobile and Edge
if (browser === 'edge') {
Expand Down Expand Up @@ -416,7 +417,7 @@ void function (window, gearbox) {
var s = ''
url = _.isString(url) ? url : ''
url = gearbox.url.removeHashFromUrl(url)
if (gearbox.isPlainObject(param)) {
if ($.isPlainObject(param)) {
param = $.param(param)
} else if (_.isString(param)) {
// fix param string
Expand All @@ -427,7 +428,7 @@ void function (window, gearbox) {
param = null
}
// append
s = param ? url + (gearbox.str.include(url, '?') ? '&' : '?') + param : s
s = param ? url + (gearbox.str.includes(url, '?') ? '&' : '?') + param : s
return s || false
}

Expand Down
2 changes: 1 addition & 1 deletion dist/gearbox.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cmui-gearbox",
"version": "0.6.0-rc.1",
"version": "0.6.0-rc.2",
"homepage": "https://github.com/CMUI/gearbox",
"author": "cssmagic <cssmagic.cn@gmail.com>",
"description": "Lightweight JavaScript utilities for web development.",
Expand Down

0 comments on commit 3c72a03

Please sign in to comment.