You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/02/24 12:48:41 UTC
[47/50] [abbrv] allura git commit: [#7827] ticket:722 Add browser
detection snippet to allura-base.js
[#7827] ticket:722 Add browser detection snippet to allura-base.js
We need it for plugins that still rely on that.
See comment in the code for full details.
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/3ff41a4d
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/3ff41a4d
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/3ff41a4d
Branch: refs/heads/ib/7827
Commit: 3ff41a4d9bfe87ac6f73f1b2a1fa05724e899131
Parents: 208d2c2
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Feb 10 09:53:46 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Feb 24 09:37:55 2015 +0000
----------------------------------------------------------------------
Allura/allura/public/nf/js/jquery-base.js | 38 ++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/3ff41a4d/Allura/allura/public/nf/js/jquery-base.js
----------------------------------------------------------------------
diff --git a/Allura/allura/public/nf/js/jquery-base.js b/Allura/allura/public/nf/js/jquery-base.js
index 673b5a9..1493550 100644
--- a/Allura/allura/public/nf/js/jquery-base.js
+++ b/Allura/allura/public/nf/js/jquery-base.js
@@ -131,3 +131,41 @@ return e.ui.ddmanager&&(e.ui.ddmanager.current=this),e.ui.ddmanager&&!o.dropBeha
};
}));
+
+
+/**
+ * It's the piece from jquery-migrate plugin to detect browser.
+ * https://github.com/jquery/jquery-migrate/blob/master/src/core.js#L68-L102
+ * Browser detection was removed in 1.9+, but we still need it for
+ * `pb.transformie.min.js` (see jinja_master/master.html) and lightbox_me
+ * plugin which we use a lot.
+ */
+jQuery.uaMatch = function( ua ) {
+ ua = ua.toLowerCase();
+ var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
+ /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
+ /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
+ /(msie) ([\w.]+)/.exec( ua ) ||
+ ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
+ [];
+ return {
+ browser: match[ 1 ] || "",
+ version: match[ 2 ] || "0"
+ };
+};
+// Don't clobber any existing jQuery.browser in case it's different
+if ( !jQuery.browser ) {
+ matched = jQuery.uaMatch( navigator.userAgent );
+ browser = {};
+ if ( matched.browser ) {
+ browser[ matched.browser ] = true;
+ browser.version = matched.version;
+ }
+ // Chrome is Webkit, but Webkit is also Safari.
+ if ( browser.chrome ) {
+ browser.webkit = true;
+ } else if ( browser.webkit ) {
+ browser.safari = true;
+ }
+ jQuery.browser = browser;
+}