From 1bcf110d0f0ec475b1415685615f8cd5909008e7 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Thu, 30 Jul 2015 09:19:44 -0500 Subject: [PATCH] improve tapPolyfill config --- ionic/components/app/app.ts | 1 + ionic/config/config.ts | 30 +++++++++++++++--------------- ionic/platform/platform.ts | 7 +++++++ ionic/platform/registry.ts | 6 +++++- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/ionic/components/app/app.ts b/ionic/components/app/app.ts index 985c09254f..4878e616a0 100644 --- a/ionic/components/app/app.ts +++ b/ionic/components/app/app.ts @@ -165,6 +165,7 @@ function initApp(window, document, config) { // Platform is a global singleton Platform.url(window.location.href); Platform.userAgent(window.navigator.userAgent); + Platform.navigatorPlatform(window.navigator.platform); Platform.load(config); // on resize be sure to clear out existing window dimensions diff --git a/ionic/config/config.ts b/ionic/config/config.ts index 7cb6b0d62b..4da5c553e7 100644 --- a/ionic/config/config.ts +++ b/ionic/config/config.ts @@ -25,13 +25,13 @@ export class IonicConfig { const arg0 = args[0]; const arg1 = args[1]; - let s = this._settings; + let settings = this._settings; switch (args.length) { case 0: // setting() = get settings object - return s; + return settings; case 1: @@ -49,17 +49,17 @@ export class IonicConfig { // setting('key') = get value // arg0 = key - if (!isDefined(s[arg0])) { + if (!isDefined(settings[arg0])) { // if the value was already set this will all be skipped // if there was no user config then it'll check each of // the user config's platforms, which already contains // settings from default platform configs - s[arg0] = null; + settings[arg0] = null; // check the platform settings object for this value // loop though each of the active platforms let activePlatformKeys = this._platforms; - let platformSettings = s.platforms; + let platformSettings = settings.platforms; let platformObj = null; if (platformSettings) { let platformValue = undefined; @@ -70,7 +70,7 @@ export class IonicConfig { } } if (isDefined(platformValue)) { - s[arg0] = platformValue; + settings[arg0] = platformValue; } } } @@ -80,10 +80,10 @@ export class IonicConfig { // or it was from the users platform configs // or it was from the default platform configs // in that order - if (isFunction(s[arg0])) { - return s[arg0](); + if (isFunction(settings[arg0])) { + settings[arg0] = settings[arg0](); } - return s[arg0]; + return settings[arg0]; case 2: @@ -93,14 +93,14 @@ export class IonicConfig { // setting('ios', {...}) = set platform config object // arg0 = platform // arg1 = platform config object - s.platforms = s.platforms || {}; - s.platforms[arg0] = arg1; + settings.platforms = settings.platforms || {}; + settings.platforms[arg0] = arg1; } else { // setting('key', 'value') = set key/value pair // arg0 = key // arg1 = value - s[arg0] = arg1; + settings[arg0] = arg1; } return this; @@ -110,9 +110,9 @@ export class IonicConfig { // arg0 = platform // arg1 = key // arg2 = value - s.platforms = s.platforms || {}; - s.platforms[arg0] = s.platforms[arg0] || {}; - s.platforms[arg0][arg1] = args[2]; + settings.platforms = settings.platforms || {}; + settings.platforms[arg0] = settings.platforms[arg0] || {}; + settings.platforms[arg0][arg1] = args[2]; return this; } diff --git a/ionic/platform/platform.ts b/ionic/platform/platform.ts index 21d7981ad9..324d4c4c97 100644 --- a/ionic/platform/platform.ts +++ b/ionic/platform/platform.ts @@ -106,6 +106,13 @@ export class PlatformCtrl { return this._ua; } + navigatorPlatform(val) { + if (arguments.length) { + this._bPlt = val; + } + return this._bPlt || ''; + } + width() { if (!this._w) { this._w = window.innerWidth; diff --git a/ionic/platform/registry.ts b/ionic/platform/registry.ts index 51970f0e0b..0b43d39b6a 100644 --- a/ionic/platform/registry.ts +++ b/ionic/platform/registry.ts @@ -89,7 +89,11 @@ Platform.register({ forwardIcon: 'ion-ios-arrow-forward', mode: 'ios', iconMode: 'ios', - tapPolyfill: true, + tapPolyfill: function() { + // this ensures it's actually a physical iOS device + // and not just an a spoofed user-agent string + return /iphone|ipad|ipod/i.test(Platform.navigatorPlatform()); + }, keyboardScrollAssist: true, viewTransition: 'ios', navTitleAlign: 'center',