You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2015/02/24 19:50:41 UTC

[06/11] 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/d1f5521f
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/d1f5521f
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/d1f5521f

Branch: refs/heads/master
Commit: d1f5521f883497dd453cb2a2279c9e4968849328
Parents: 0ce4968
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Feb 10 09:53:46 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Feb 24 18:50:19 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/d1f5521f/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;
+}