From c89deca54260f2511f9010fcfbb7ae085f9ff002 Mon Sep 17 00:00:00 2001 From: Drew Rygh Date: Wed, 30 Sep 2015 16:21:52 -0500 Subject: [PATCH] chore(demos): fix zonejs issue, add new template --- demos/component-docs/index.ts | 17 +++++++++---- demos/component-docs/main.html | 3 +-- gulpfile.js | 9 ++++++- scripts/demos/docs.index.template.html | 33 ++++++++++++++++++++++++++ scripts/demos/index.template.html | 1 - 5 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 scripts/demos/docs.index.template.html diff --git a/demos/component-docs/index.ts b/demos/component-docs/index.ts index ec8ee55d69..577fd60582 100644 --- a/demos/component-docs/index.ts +++ b/demos/component-docs/index.ts @@ -1,4 +1,5 @@ import {App, ActionSheet} from 'ionic/ionic'; +import {NgZone} from 'angular2/angular2'; function toTitleCase(str) { return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); @@ -9,13 +10,21 @@ function toTitleCase(str) { }) class DemoApp { - constructor(actionSheet: ActionSheet) { + component: any; + actionSheet: any; + + constructor(actionSheet: ActionSheet, zone: NgZone) { this.actionSheet = actionSheet; this.component = { - title: 'Action Sheet', - } + title: 'Action Sheets', + }; window.onmessage = (e) => { - this.component.title = toTitleCase(e.data.replace('-', ' ')); + zone.run(() => { + if (e.data) { + var data = JSON.parse(e.data); + this.component.title = toTitleCase(data.hash.replace('-', ' ')); + } + }); }; } diff --git a/demos/component-docs/main.html b/demos/component-docs/main.html index f364a7fa34..89aff44058 100644 --- a/demos/component-docs/main.html +++ b/demos/component-docs/main.html @@ -3,8 +3,7 @@ - -
+
diff --git a/gulpfile.js b/gulpfile.js index b1f5aff1d6..ec17ec9a2e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -367,7 +367,8 @@ gulp.task('demos', function(){ .pipe(tsc, tscOptions, null, tscReporter) .pipe(babel, getBabelOptions('demos')) - var indexTemplate = _.template(fs.readFileSync('scripts/demos/index.template.html'))(); + var baseIndexTemplate = _.template(fs.readFileSync('scripts/demos/index.template.html'))(); + var docsIndexTemplate = _.template(fs.readFileSync('scripts/demos/docs.index.template.html'))(); return gulp.src(['demos/**/*']) .pipe(cache('demos', { optimizeMemory: true })) @@ -377,12 +378,18 @@ gulp.task('demos', function(){ function createIndexHTML() { return through2.obj(function(file, enc, next) { + var indexTemplate = baseIndexTemplate; + if (file.path.indexOf('component-docs') > -1) { + indexTemplate = docsIndexTemplate; + } this.push(new VinylFile({ base: file.base, contents: new Buffer(indexTemplate), path: path.join(path.dirname(file.path), 'index.html'), })); next(null, file); + + }); } }) diff --git a/scripts/demos/docs.index.template.html b/scripts/demos/docs.index.template.html new file mode 100644 index 0000000000..5870e1b3cf --- /dev/null +++ b/scripts/demos/docs.index.template.html @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/demos/index.template.html b/scripts/demos/index.template.html index bc1240c66d..4f67125d6f 100644 --- a/scripts/demos/index.template.html +++ b/scripts/demos/index.template.html @@ -6,7 +6,6 @@ -