Files
Brandy Carney 1f83cde78b chore(demos): update demos to work
* chore(demos): WIP refactor gulp demos task to use SystemJS

move build files into dist/demos and comment out the AoT demos task for
right now. This makes both `gulp demos` and `gulp demos.watch`work
again.

references #8411

* docs(demos): fix infinite scroll demo

* chore(demos): move old demos task to demos.prod

update the demos file with shared tasks, include the shared css

* docs(demos): fix API demos to use correct styles

* chore(demos): remove the main.ts files from each demo

* chore(demos): add prod template and constant

* chore(demos): remove tsconfig and package from demos

* chore(demos): update app.module path to ionic

* chore(demos): update app.module path to ionic

* chore(demos): update prod task for demos to work with AoT

also puts the demo build files into dist/ instead of the src directory

* docs(demos): update deploy and docs tasks for new build

* docs(scripts): update demos README

* chore(demos): fix path for prod build
2016-12-13 12:56:22 -06:00

165 lines
4.0 KiB
TypeScript

import { Component, NgModule } from '@angular/core';
import { IonicApp, IonicModule, Platform, NavController } from '../';
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 = encodeURI(sKey) + '=' + encodeURI(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 = encodeURI(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 as any).setItem(sKey, oStorage[sKey]);
} else {
aKeys.splice(iThisIndx, 1);
}
delete oStorage[sKey];
}
for (aKeys; aKeys.length > 0; aKeys.splice(0, 1)) { (oStorage as any).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 = decodeURI(aCouple[0])] = decodeURI(aCouple[1]);
aKeys.push(iKey);
}
}
return oStorage;
};
this.configurable = false;
this.enumerable = true;
})());
}
var CONFIG_DEMO = null;
if (window.localStorage.getItem('configDemo')) {
CONFIG_DEMO = JSON.parse(window.localStorage.getItem('configDemo'));
}
@Component({
templateUrl: 'tabs.html'
})
export class TabPage {
tabOne = ApiDemoPage;
}
@Component({
templateUrl: 'page.html'
})
export class ApiDemoPage {
config: any;
initialConfig: any;
constructor(public platform: Platform, public navCtrl: NavController) {
if (window.localStorage.getItem('configDemo') !== null) {
this.config = JSON.parse(window.localStorage.getItem('configDemo'));
} else if (platform.is('ios')) {
this.config = {
'backButtonIcon': 'ios-arrow-back',
'iconMode': 'ios',
'tabsPlacement': 'bottom'
};
} else if (platform.is('windows')) {
this.config = {
'backButtonIcon': 'ios-arrow-back',
'iconMode': 'ios',
'tabsPlacement': 'top'
};
} else {
this.config = {
'backButtonIcon': 'md-arrow-back',
'iconMode': 'md',
'tabsPlacement': 'bottom'
};
}
this.initialConfig = JSON.parse(JSON.stringify(this.config));
}
load() {
window.localStorage.setItem('configDemo', JSON.stringify(this.config));
window.location.reload();
}
push() {
this.navCtrl.push(PushPage);
}
}
@Component({
templateUrl: 'push-page.html'
})
export class PushPage {
constructor(public navCtrl: NavController) {}
pop() {
this.navCtrl.pop();
}
}
@Component({
template: '<ion-nav [root]="root" #content></ion-nav>'
})
export class ApiDemoApp {
root = TabPage;
}
@NgModule({
declarations: [
ApiDemoApp,
ApiDemoPage,
PushPage,
TabPage
],
imports: [
IonicModule.forRoot(ApiDemoApp, CONFIG_DEMO)
],
bootstrap: [IonicApp],
entryComponents: [
ApiDemoPage,
PushPage,
TabPage
]
})
export class AppModule {}