From d27ac153f37a6a91d57b70972f6293254d5a8a22 Mon Sep 17 00:00:00 2001 From: Ben Combee Date: Mon, 22 Oct 2012 15:12:51 -0700 Subject: [PATCH] Add PlatformSampler sample that shows the detected platform user agent string and enyo.platform object Add platform detection for Firefox (desktop) and Firefox on Android Enyo-DCO-1.0-Signed-Off-By: Ben Combee (ben.combee@palm.com) --- samples/PlatformSample.css | 11 +++++++++++ samples/PlatformSample.html | 21 +++++++++++++++++++++ samples/PlatformSample.js | 22 ++++++++++++++++++++++ samples/package.js | 2 ++ source/dom/platform.js | 8 ++++++-- 5 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 samples/PlatformSample.css create mode 100644 samples/PlatformSample.html create mode 100644 samples/PlatformSample.js diff --git a/samples/PlatformSample.css b/samples/PlatformSample.css new file mode 100644 index 000000000..326002ee0 --- /dev/null +++ b/samples/PlatformSample.css @@ -0,0 +1,11 @@ +.platform-sample { + padding: 15px; +} +.platform-sample-divider { + color: #F49200; + text-transform: uppercase; + font-family: Segoe UI, Prelude Medium, Helvetica, Verdana, sans-serif; + font-size: 14px; + font-weight: bold; + margin-bottom: 8px; +} \ No newline at end of file diff --git a/samples/PlatformSample.html b/samples/PlatformSample.html new file mode 100644 index 000000000..081aa78fd --- /dev/null +++ b/samples/PlatformSample.html @@ -0,0 +1,21 @@ + + + + Platform Sample + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/PlatformSample.js b/samples/PlatformSample.js new file mode 100644 index 000000000..d291d08d1 --- /dev/null +++ b/samples/PlatformSample.js @@ -0,0 +1,22 @@ +enyo.kind({ + name: "enyo.sample.PlatformSample", + kind: "FittableRows", + classes: "enyo-fit platform-sample", + components: [ + {classes: "platform-sample-divider", content: "Enyo Platform Detection"}, + {kind: "onyx.Groupbox", components: [ + {kind: "onyx.GroupboxHeader", content: "User-Agent String"}, + {name: "uaString", content: "", style: "padding: 8px;"} + ]}, + {tag: "br"}, + {kind: "onyx.Groupbox", components: [ + {kind: "onyx.GroupboxHeader", content: "enyo.platform"}, + {name: "enyoPlatformJSON", content: "", style: "padding: 8px;"} + ]} + ], + create: function() { + this.inherited(arguments); + this.$.uaString.setContent(navigator.userAgent); + this.$.enyoPlatformJSON.setContent(JSON.stringify(enyo.platform)); + } +}); \ No newline at end of file diff --git a/samples/package.js b/samples/package.js index 251bc1f63..e6972c3e2 100644 --- a/samples/package.js +++ b/samples/package.js @@ -1,5 +1,7 @@ enyo.depends( "$lib/extra/exampler", + "PlatformSample.css", + "PlatformSample.js", "Playground.css", "Playground.js", "AjaxSample.css", diff --git a/source/dom/platform.js b/source/dom/platform.js index dc6b78200..c9414e935 100644 --- a/source/dom/platform.js +++ b/source/dom/platform.js @@ -49,10 +49,14 @@ enyo.platform = { {platform: "ios", regex: /iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/}, // webOS 1 - 3 {platform: "webos", regex: /(?:web|hpw)OS\/(\d+)/}, - // desktop safari + // desktop Safari {platform: "safari", regex: /Version\/(\d+)[.\d]+\s+Safari/}, // desktop Chrome - {platform: "chrome", regex: /Chrome\/(\d+)[.\d]+/} + {platform: "chrome", regex: /Chrome\/(\d+)[.\d]+/}, + // Firefox on Android + {platform: "androidFirefox", regex: /Android;.*Firefox\/(\d+)/}, + // desktop Firefox + {platform: "firefox", regex: /Firefox\/(\d+)/} ]; for (var i = 0, p, m, v; p = platforms[i]; i++) { m = p.regex.exec(ua);