mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
iOS default config
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user