diff --git a/demos/config/app.html b/demos/config/app.html new file mode 100644 index 0000000000..5f6bb33d68 --- /dev/null +++ b/demos/config/app.html @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/demos/config/config-demo.js b/demos/config/config-demo.js new file mode 100644 index 0000000000..e18ab9659b --- /dev/null +++ b/demos/config/config-demo.js @@ -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; +} \ No newline at end of file diff --git a/demos/config/index.ts b/demos/config/index.ts new file mode 100644 index 0000000000..ce67af60a6 --- /dev/null +++ b/demos/config/index.ts @@ -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(); + } +} + diff --git a/demos/config/main.html b/demos/config/main.html new file mode 100644 index 0000000000..3aee3681ec --- /dev/null +++ b/demos/config/main.html @@ -0,0 +1,61 @@ + + Config + + + + + + @App({ + + + + + + config: { + + + + backButtonIcon: + + + + + + + iconMode: + + + + + + + tabbarPlacement: + + + + + + + } + + + + + + }) + + + + + + + diff --git a/demos/config/tabs.html b/demos/config/tabs.html new file mode 100644 index 0000000000..736e5f6f85 --- /dev/null +++ b/demos/config/tabs.html @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ionic/config/config.ts b/ionic/config/config.ts index 2d77e36014..d1c7c2f17d 100644 --- a/ionic/config/config.ts +++ b/ionic/config/config.ts @@ -99,7 +99,7 @@ import {isObject, isDefined, isFunction, isArray, extend} from '../util/util'; * tabbarPlacement: 'top', * tabSubPages: true, * ``` - * + * @demo /docs/v2/demos/config/ * **/ export class Config {