mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
wip
This commit is contained in:
2
demos/config/app.html
Normal file
2
demos/config/app.html
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<ion-nav id="nav" [root]="rootPage" #content></ion-nav>
|
||||||
|
<ion-overlay></ion-overlay>
|
66
demos/config/config-demo.js
Normal file
66
demos/config/config-demo.js
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
if (!window.localStorage) {
|
||||||
|
Object.defineProperty(window, "localStorage", new (function () {
|
||||||
|
var aKeys = [], oStorage = {};
|
||||||
|
Object.defineProperty(oStorage, "getItem", {
|
||||||
|
value: function (sKey) { return sKey ? this[sKey] : null; },
|
||||||
|
writable: false,
|
||||||
|
configurable: false,
|
||||||
|
enumerable: false
|
||||||
|
});
|
||||||
|
Object.defineProperty(oStorage, "key", {
|
||||||
|
value: function (nKeyId) { return aKeys[nKeyId]; },
|
||||||
|
writable: false,
|
||||||
|
configurable: false,
|
||||||
|
enumerable: false
|
||||||
|
});
|
||||||
|
Object.defineProperty(oStorage, "setItem", {
|
||||||
|
value: function (sKey, sValue) {
|
||||||
|
if(!sKey) { return; }
|
||||||
|
document.cookie = escape(sKey) + "=" + escape(sValue) + "; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/";
|
||||||
|
},
|
||||||
|
writable: false,
|
||||||
|
configurable: false,
|
||||||
|
enumerable: false
|
||||||
|
});
|
||||||
|
Object.defineProperty(oStorage, "length", {
|
||||||
|
get: function () { return aKeys.length; },
|
||||||
|
configurable: false,
|
||||||
|
enumerable: false
|
||||||
|
});
|
||||||
|
Object.defineProperty(oStorage, "removeItem", {
|
||||||
|
value: function (sKey) {
|
||||||
|
if(!sKey) { return; }
|
||||||
|
document.cookie = escape(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
|
||||||
|
},
|
||||||
|
writable: false,
|
||||||
|
configurable: false,
|
||||||
|
enumerable: false
|
||||||
|
});
|
||||||
|
this.get = function () {
|
||||||
|
var iThisIndx;
|
||||||
|
for (var sKey in oStorage) {
|
||||||
|
iThisIndx = aKeys.indexOf(sKey);
|
||||||
|
if (iThisIndx === -1) { oStorage.setItem(sKey, oStorage[sKey]); }
|
||||||
|
else { aKeys.splice(iThisIndx, 1); }
|
||||||
|
delete oStorage[sKey];
|
||||||
|
}
|
||||||
|
for (aKeys; aKeys.length > 0; aKeys.splice(0, 1)) { oStorage.removeItem(aKeys[0]); }
|
||||||
|
for (var aCouple, iKey, nIdx = 0, aCouples = document.cookie.split(/\s*;\s*/); nIdx < aCouples.length; nIdx++) {
|
||||||
|
aCouple = aCouples[nIdx].split(/\s*=\s*/);
|
||||||
|
if (aCouple.length > 1) {
|
||||||
|
oStorage[iKey = unescape(aCouple[0])] = unescape(aCouple[1]);
|
||||||
|
aKeys.push(iKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return oStorage;
|
||||||
|
};
|
||||||
|
this.configurable = false;
|
||||||
|
this.enumerable = true;
|
||||||
|
})());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.localStorage.getItem('configDemo')) {
|
||||||
|
CONFIG_DEMO = JSON.parse(window.localStorage.getItem('configDemo'));
|
||||||
|
} else {
|
||||||
|
CONFIG_DEMO = null;
|
||||||
|
}
|
54
demos/config/index.ts
Normal file
54
demos/config/index.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import {App, Page, IonicApp, Platform} from 'ionic/ionic';
|
||||||
|
|
||||||
|
@App({
|
||||||
|
templateUrl: 'app.html',
|
||||||
|
config: CONFIG_DEMO || {}
|
||||||
|
})
|
||||||
|
class ApiDemoApp {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.rootPage = TabPage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Page({
|
||||||
|
templateUrl: 'tabs.html'
|
||||||
|
})
|
||||||
|
export class TabPage {
|
||||||
|
constructor() {
|
||||||
|
this.tabOne = InitialPage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Page({
|
||||||
|
templateUrl: 'main.html'
|
||||||
|
})
|
||||||
|
export class InitialPage {
|
||||||
|
constructor(platform: Platform) {
|
||||||
|
this.platform = platform;
|
||||||
|
if (window.localStorage.getItem('configDemo') !== "{}") {
|
||||||
|
debugger;
|
||||||
|
this.config = JSON.parse(window.localStorage.getItem('configDemo'));
|
||||||
|
}
|
||||||
|
else if (platform.is('ios')) {
|
||||||
|
this.config = {
|
||||||
|
'backButtonIcon': 'ion-ios-arrow-back',
|
||||||
|
'iconMode': 'ios',
|
||||||
|
'tabbarPlacement': 'bottom'
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
this.config = {
|
||||||
|
'backButtonIcon': 'ion-md-arrow-back',
|
||||||
|
'iconMode': 'md',
|
||||||
|
'tabbarPlacement': 'top'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
load() {
|
||||||
|
window.localStorage.setItem('configDemo', JSON.stringify(this.config));
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
61
demos/config/main.html
Normal file
61
demos/config/main.html
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<ion-navbar *navbar>
|
||||||
|
<ion-title>Config</ion-title>
|
||||||
|
</ion-navbar>
|
||||||
|
|
||||||
|
<ion-content padding>
|
||||||
|
|
||||||
|
<ion-row>
|
||||||
|
@App({
|
||||||
|
</ion-row>
|
||||||
|
|
||||||
|
<ion-row>
|
||||||
|
|
||||||
|
<ion-col>
|
||||||
|
config: {
|
||||||
|
|
||||||
|
<ion-row>
|
||||||
|
<ion-col>
|
||||||
|
backButtonIcon:
|
||||||
|
<select [(ng-model)]="config.backButtonIcon">
|
||||||
|
<option value="ion-ios-arrow-back">ion-ios-arrow-back</option>
|
||||||
|
<option value="ion-md-arrow-back">ion-md-arrow-back</option>
|
||||||
|
</select>
|
||||||
|
</ion-col>
|
||||||
|
</ion-row>
|
||||||
|
|
||||||
|
<ion-row>
|
||||||
|
<ion-col>
|
||||||
|
iconMode:
|
||||||
|
<select [(ng-model)]="config.iconMode">
|
||||||
|
<option value="ios">ios</option>
|
||||||
|
<option value="md">md</option>
|
||||||
|
</select>
|
||||||
|
</ion-col>
|
||||||
|
</ion-row>
|
||||||
|
|
||||||
|
<ion-row>
|
||||||
|
<ion-col>
|
||||||
|
tabbarPlacement:
|
||||||
|
<select [(ng-model)]="config.tabbarPlacement">
|
||||||
|
<option value="bottom">bottom</option>
|
||||||
|
<option value="top">top</option>
|
||||||
|
</select>
|
||||||
|
</ion-col>
|
||||||
|
</ion-row>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
</ion-col>
|
||||||
|
|
||||||
|
</ion-row>
|
||||||
|
|
||||||
|
<ion-row>
|
||||||
|
})
|
||||||
|
</ion-row>
|
||||||
|
|
||||||
|
<ion-row>
|
||||||
|
<button full (click)="load()">Reload Config</button>
|
||||||
|
</ion-row>
|
||||||
|
|
||||||
|
<ion-content>
|
5
demos/config/tabs.html
Normal file
5
demos/config/tabs.html
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<ion-tabs>
|
||||||
|
<ion-tab tab-title="Music" [root]="tabOne"></ion-tab>
|
||||||
|
<ion-tab tab-title="Movies" [root]="tabOne"></ion-tab>
|
||||||
|
<ion-tab tab-title="Games" [root]="tabOne"></ion-tab>
|
||||||
|
</ion-tabs>
|
@ -99,7 +99,7 @@ import {isObject, isDefined, isFunction, isArray, extend} from '../util/util';
|
|||||||
* tabbarPlacement: 'top',
|
* tabbarPlacement: 'top',
|
||||||
* tabSubPages: true,
|
* tabSubPages: true,
|
||||||
* ```
|
* ```
|
||||||
*
|
* @demo /docs/v2/demos/config/
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
export class Config {
|
export class Config {
|
||||||
|
Reference in New Issue
Block a user