diff --git a/ionic/components/app/app.js b/ionic/components/app/app.js index e9116e9f5d..016ee872fc 100644 --- a/ionic/components/app/app.js +++ b/ionic/components/app/app.js @@ -120,20 +120,12 @@ export class IonicApp { return this._rtl; } - lang(val) { - if (arguments.length) { - this._lang = val; - } - return this._lang; - } - } -function initApp(window, document) { +function initApp(window, document, config) { // create the base IonicApp let app = new IonicApp(); app.isRTL(document.documentElement.getAttribute('dir') == 'rtl'); - app.lang(document.documentElement.getAttribute('lang')); // load all platform data // Platform is a global singleton @@ -141,7 +133,7 @@ function initApp(window, document) { Platform.userAgent(window.navigator.userAgent); Platform.width(window.innerWidth); Platform.height(window.innerHeight); - Platform.load(); + Platform.load(config); return app; } @@ -149,12 +141,12 @@ function initApp(window, document) { export function ionicBootstrap(ComponentType, config) { return new Promise((resolve, reject) => { try { - // create the base IonicApp - let app = initApp(window, document) - // get the user config, or create one if wasn't passed in config = config || new IonicConfig(); + // create the base IonicApp + let app = initApp(window, document, config); + // copy default platform settings into the user config platform settings // user config platform settings should override default platform settings config.setPlatform(Platform); diff --git a/ionic/config/config.js b/ionic/config/config.js index e2358cb887..d36898b3a3 100644 --- a/ionic/config/config.js +++ b/ionic/config/config.js @@ -4,7 +4,16 @@ import {isString, isObject, isDefined, isFunction, extend} from '../util/util'; export class IonicConfig { constructor(settings) { - this.setting(settings || {}); + + // defaults + this._settings = { + platform: 'ios' + }; + + // override defaults w/ user config + if (settings) { + extend(this._settings, setting); + } } setting() { diff --git a/ionic/platform/platform.js b/ionic/platform/platform.js index 82bba2d9fc..cc1133a56d 100644 --- a/ionic/platform/platform.js +++ b/ionic/platform/platform.js @@ -172,11 +172,13 @@ export class PlatformCtrl { this.testUserAgent(userAgentExpression); } - load() { + load(config) { let rootPlatformNode = null; let engineNode = null; let self = this; + this.platformOverride = config.setting('platform'); + // figure out the most specific platform and active engine let tmpPlatform = null; for (let platformName in this._registry) { @@ -281,7 +283,7 @@ function matchPlatform(platformName, platform) { if (tmpPlatform) { tmpPlatform.depth = 0; let childPlatform = tmpPlatform.child(); - while(childPlatform) { + while (childPlatform) { tmpPlatform.depth++ childPlatform = childPlatform.child(); } @@ -344,7 +346,9 @@ class PlatformNode { isMatch(p) { if (typeof this.c.isMatched !== 'boolean') { - if (!this.c.isMatch) { + if (p.platformOverride) { + this.c.isMatched = (p.platformOverride === this.c.name); + } else if (!this.c.isMatch) { this.c.isMatched = false; } else { this.c.isMatched = this.c.isMatch(p); diff --git a/ionic/platform/registry.js b/ionic/platform/registry.js index d874eb9a3a..8a06ba3d86 100644 --- a/ionic/platform/registry.js +++ b/ionic/platform/registry.js @@ -73,9 +73,6 @@ Platform.register({ tapPolyfill: true }, isMatch(p) { - // SLEDGEHAMMER OVERRIDE FOR NOW - return true; - return p.isPlatform('ios', 'iphone|ipad|ipod'); }, versionParser(p) {