Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added platform detection for the Apache Cordova (formerly phonegap)

javascript-to-mobile bridge. Also added gitignore entries for .project
and .settings, which are eclipse-specific configuration files.
  • Loading branch information...
commit 85464b3ce0df66282c5f2e4f25cbaa2346b0e5b4 1 parent 67e1a64
Michael Krotscheck krotscheck authored publickeating committed
2  .gitignore
View
@@ -13,3 +13,5 @@ Gemfile*
*.orig
.sass-cache/
.strobe/
+.project
+.settings/
21 frameworks/core_foundation/system/platform.js
View
@@ -387,7 +387,26 @@ SC.platform = SC.Object.create({
@property {Boolean}
@default NO
*/
- windowSizeDeterminesOrientation: SC.browser.os === SC.OS.ios || !('onorientationchange' in window)
+ windowSizeDeterminesOrientation: SC.browser.os === SC.OS.ios || !('onorientationchange' in window),
+
+ /**
+ Does this browser support the Apache Cordova (formerly phonegap) runtime?
+
+ This requires that you (the engineer) manually include the cordova
+ javascript library for the appropriate platform (Android, iOS, etc)
+ in your code. There are various methods of doing this; creating your own
+ platform-specific index.rhtml is probably the easiest option.
+
+ WARNING: Using the javascript_libs Buildfile option for the cordova include
+ will NOT work. The library will be included after your application code,
+ by which time this property will already have been evaluated.
+
+ @property {Boolean}
+ @see http://incubator.apache.org/cordova/
+ @default NO
+ */
+ // Check for the global cordova property.
+ cordova: (typeof window.cordova !== "undefined")
});
18 frameworks/core_foundation/tests/system/platform.js
View
@@ -0,0 +1,18 @@
+// ==========================================================================
+// Project: SproutCore - JavaScript Application Framework
+// Copyright: ©2012 Michael Krotscheck and contributors. All rights reserved.
+// License: Licensed under MIT license (see license.js)
+// ==========================================================================
+
+/**
+ * Test for correct cordova detection.
+ */
+test("SC.platform.cordova", function() {
+
+ ok(typeof SC.platform.cordova == 'boolean', "Cordova check must have been executed.");
+
+ // Is there a chance we're in a cordova runtime?
+ var isCordova = typeof window.cordova !== "undefined";
+ equals(isCordova, SC.platform.cordova, "Cordova detection must match what we've been able to determine for ourselves");
+
+});
Please sign in to comment.
Something went wrong with that request. Please try again.