diff --git a/ionic/components/modal/test/basic/index.js b/ionic/components/modal/test/basic/index.js index 55d862f560..1b0434b51a 100644 --- a/ionic/components/modal/test/basic/index.js +++ b/ionic/components/modal/test/basic/index.js @@ -159,8 +159,9 @@ export function main(ionicBootstrap) { ionicBootstrap(MyApp, myConfig).then(root => { console.log('platforms', root.platform.platforms()); - console.log(myConfig.setting('mode')); + console.log('mode', myConfig.setting('mode')); + console.log('core', root.platform.is('core')) console.log('cordova', root.platform.is('cordova')) console.log('mobile', root.platform.is('mobile')) console.log('ipad', root.platform.is('ipad')) diff --git a/ionic/platform/platform.js b/ionic/platform/platform.js index 357cf37089..0d32ebcaa9 100644 --- a/ionic/platform/platform.js +++ b/ionic/platform/platform.js @@ -6,8 +6,8 @@ export class PlatformCtrl { constructor() { this._settings = {}; this._platforms = []; - this._registry = {}; + this._default = null; } register(platformConfig) { @@ -18,21 +18,19 @@ export class PlatformCtrl { return this._registry; } + setDefault(platformName) { + this._default = platformName; + } + load(app) { let rootPlatformNode = null; let engineNode = null; - // reset values - this._settings = {}; - this._platforms = []; - - function matchPlatform(platformConfig) { + function matchPlatform(platformName) { // build a PlatformNode and assign config data to it // use it's getRoot method to build up its hierarchy // depending on which platforms match - let platformNode = new PlatformNode(); - platformNode.config(platformConfig); - platformNode.isEngine = platformConfig.isEngine; + let platformNode = new PlatformNode(platformName); let tmpPlatform = platformNode.getRoot(app, 0); if (tmpPlatform) { @@ -51,8 +49,7 @@ export class PlatformCtrl { if (supersetPlaformName) { // add a platform in between two exist platforms // so we can build the correct hierarchy of active platforms - let supersetPlatform = new PlatformNode(); - supersetPlatform.load(supersetPlaformName); + let supersetPlatform = new PlatformNode(supersetPlaformName); supersetPlatform.parent(platformNode.parent()); supersetPlatform.child(platformNode); supersetPlatform.parent().child(supersetPlatform); @@ -64,7 +61,7 @@ export class PlatformCtrl { let tmpPlatform = null; for (let platformName in this._registry) { - tmpPlatform = matchPlatform( this._registry[platformName] ); + tmpPlatform = matchPlatform(platformName); if (tmpPlatform) { // we found a platform match! // check if its more specific than the one we already have @@ -83,6 +80,10 @@ export class PlatformCtrl { } } + if (!rootPlatformNode) { + rootPlatformNode = new PlatformNode(this._default); + } + // build a Platform instance filled with the // hierarchy of active platforms and settings @@ -156,24 +157,21 @@ export class PlatformCtrl { class PlatformNode { - load(platformName) { - this._c = Platform.get(platformName); - } - - config(val) { - this._c = val; - } - - settings() { - return this._c.settings || {}; + constructor(platformName) { + this.c = Platform.get(platformName); + this.isEngine = this.c.isEngine; } name() { - return this._c.name; + return this.c.name; + } + + settings() { + return this.c.settings || {}; } superset() { - return this._c.superset; + return this.c.superset; } runAll() { @@ -200,15 +198,14 @@ class PlatformNode { } isMatch(app) { - if (typeof this._c._isMatched !== 'boolean') { - // only do the actual check once - if (!this._c.isMatch) { - this._c._isMatched = true; + if (typeof this.c.isMatched !== 'boolean') { + if (!this.c.isMatch) { + this.c.isMatched = false; } else { - this._c._isMatched = this._c.isMatch(app); + this.c.isMatched = this.c.isMatch(app); } } - return this._c._isMatched; + return this.c.isMatched; } getRoot(app) { @@ -224,8 +221,7 @@ class PlatformNode { let rootPlatform = null; for (let i = 0; i < parents.length; i++) { - platform = new PlatformNode(); - platform.load(parents[i]); + platform = new PlatformNode(parents[i]); platform.child(this); rootPlatform = platform.getRoot(app); diff --git a/ionic/platform/registry.js b/ionic/platform/registry.js index c1149890de..792498189a 100644 --- a/ionic/platform/registry.js +++ b/ionic/platform/registry.js @@ -1,18 +1,13 @@ import {Platform} from './platform'; -import {Tap} from '../util/tap'; Platform.register({ name: 'core', - subsets: [ - 'android', - 'ios', - 'windowsphone' - ], settings: { mode: 'core' } }); +Platform.setDefault('core'); Platform.register({ @@ -55,7 +50,9 @@ Platform.register({ mode: 'md' }, isMatch(app) { - return app.isPlatform('android'); + // "silk" is kindle fire + let re = 'android| silk'; + return app.isPlatform('android', re); } }); @@ -80,9 +77,6 @@ Platform.register({ versionParser(app) { let val = app.matchUserAgent('OS (\d+)_(\d+)?'); console.log(val); - }, - run() { - //Tap.run(); } });