improve tapPolyfill config

This commit is contained in:
Adam Bradley
2015-07-30 09:19:44 -05:00
parent 2bce715366
commit 1bcf110d0f
4 changed files with 28 additions and 16 deletions

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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',