From 779e18e7363ac15078995518d3ddb365a3197c19 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Fri, 26 Jun 2015 11:21:41 -0500 Subject: [PATCH] init engine methods/events --- ionic/platform/platform.js | 59 ++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/ionic/platform/platform.js b/ionic/platform/platform.js index daa08d6276..13b378e25f 100644 --- a/ionic/platform/platform.js +++ b/ionic/platform/platform.js @@ -9,29 +9,68 @@ export class PlatformCtrl { this._platforms = []; this._registry = {}; this._default = null; + this._vMajor = 0; + this._vMinor = 0; } // Methods // ********************************************** + is(platformName) { + return (this._platforms.indexOf(platformName) > -1); + } + + platforms() { + // get the array of active platforms, which also knows the hierarchy, + // with the last one the most important + return this._platforms; + } + + version(asObject) { + let version = parseFloat(this._vMajor + '.' + this._vMinor); + if (asObject) { + return { + version: version, + major: this._vMajor, + minor: this._vMinor + } + } + return version; + } + ready() { - // no ready method was provided by an engine - // fallback to use dom ready instead - // if a ready method was provide then it would - // override the default method + // if a ready method was provided then it would + // override this default method + // fallback to use dom ready by default return dom.ready(); } domReady() { + // helper method so its easy to access on Platform return dom.ready(); } windowLoad() { + // helper method so its easy to access on Platform return dom.windowLoad(); } - // Properties + + // Methods meant to be overridden by the engine + // ********************************************** + // Provided NOOP methods so they do not error when + // called by engines (the browser) doesn't provide them + on() {} + onHardwareBackButton() {} + registerBackButtonAction() {} + exitApp() {} + fullScreen() {} + showStatusBar() {} + + + + // Getter/Setter Methods // ********************************************** url(val) { @@ -193,10 +232,6 @@ export class PlatformCtrl { return this; } - is(platformName) { - return (this._platforms.indexOf(platformName) > -1); - } - settings(val) { if (arguments.length) { this._settings = val; @@ -204,12 +239,6 @@ export class PlatformCtrl { return this._settings; } - platforms() { - // get the array of active platforms, which also knows the hierarchy, - // with the last one the most important - return this._platforms; - } - get(platformName) { return this._registry[platformName] || {}; }