From f4905ee5b7985a27d3ef90e104c772171fe999b0 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Mon, 27 Apr 2015 10:30:35 -0500 Subject: [PATCH] Fun stuff --- ionic/components/app/test/hn/hn.js | 13 +++++++++ ionic/components/app/test/hn/main.html | 3 ++ ionic/components/app/test/hn/main.js | 28 +++++++++++++++++++ .../components/app/test/hn/pages/splash.html | 3 ++ ionic/components/app/test/hn/pages/splash.js | 13 +++++++++ .../content/test/pull-to-refresh/main.html | 2 +- .../content/test/pull-to-refresh/main.js | 4 +++ ionic/components/scroll/pull-to-refresh.js | 15 +++++++++- 8 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 ionic/components/app/test/hn/hn.js create mode 100644 ionic/components/app/test/hn/main.html create mode 100644 ionic/components/app/test/hn/main.js create mode 100644 ionic/components/app/test/hn/pages/splash.html create mode 100644 ionic/components/app/test/hn/pages/splash.js diff --git a/ionic/components/app/test/hn/hn.js b/ionic/components/app/test/hn/hn.js new file mode 100644 index 0000000000..49fc815369 --- /dev/null +++ b/ionic/components/app/test/hn/hn.js @@ -0,0 +1,13 @@ +export class HackerNews { + constructor() { + this.fb = new Firebase('https://hacker-news.firebaseio.com/v0'); + this.getPosts(); + } + + getPosts() { + console.log('GETTING POSTS'); + this.fb.child('topstories').on('value', function(snapshot) { + console.log(snapshot.val()); + }); + } +} diff --git a/ionic/components/app/test/hn/main.html b/ionic/components/app/test/hn/main.html new file mode 100644 index 0000000000..bfbbe0774e --- /dev/null +++ b/ionic/components/app/test/hn/main.html @@ -0,0 +1,3 @@ + + + diff --git a/ionic/components/app/test/hn/main.js b/ionic/components/app/test/hn/main.js new file mode 100644 index 0000000000..6ac6d4fad4 --- /dev/null +++ b/ionic/components/app/test/hn/main.js @@ -0,0 +1,28 @@ +import {Descendent, NgElement, Component, View as NgView, bootstrap} from 'angular2/angular2'; +import {View, Content, Nav, NavPane} from 'ionic/ionic'; + +import {HackerNews} from 'hn'; +import {HNSplashPage} from 'pages/splash'; + +@Component({ selector: '[ion-app]' }) +@NgView({ + templateUrl: 'main.html', + directives: [View, Content, Nav, NavPane] +}) +class IonicApp { + constructor( + @NgElement() element:NgElement + ) { + console.log('IonicApp start: HackerNews') + + this.splashPage = HNSplashPage + + // Timeout so Firebase can be resolved + setTimeout(() => { + this.hn = new HackerNews(); + }); + } +} + +bootstrap(IonicApp) + diff --git a/ionic/components/app/test/hn/pages/splash.html b/ionic/components/app/test/hn/pages/splash.html new file mode 100644 index 0000000000..03ef0c60f6 --- /dev/null +++ b/ionic/components/app/test/hn/pages/splash.html @@ -0,0 +1,3 @@ +
+

That's so HACKER NEWS

+
diff --git a/ionic/components/app/test/hn/pages/splash.js b/ionic/components/app/test/hn/pages/splash.js new file mode 100644 index 0000000000..ce40bef829 --- /dev/null +++ b/ionic/components/app/test/hn/pages/splash.js @@ -0,0 +1,13 @@ +import {Descendent, Parent, NgElement, Component, View as NgView, bootstrap} from 'angular2/angular2'; +import {View, Content, Nav, NavPane} from 'ionic/ionic'; + +@Component({ selector: 'splash-page' }) +@NgView({ + templateUrl: 'pages/splash.html', + directives: [View, Content] +}) +export class HNSplashPage { + constructor(@Parent() viewport: Nav) { + //window.navPane = navPane; + } +} diff --git a/ionic/components/content/test/pull-to-refresh/main.html b/ionic/components/content/test/pull-to-refresh/main.html index c62aeacd9a..213d8ac774 100644 --- a/ionic/components/content/test/pull-to-refresh/main.html +++ b/ionic/components/content/test/pull-to-refresh/main.html @@ -1,6 +1,6 @@ - +
diff --git a/ionic/components/content/test/pull-to-refresh/main.js b/ionic/components/content/test/pull-to-refresh/main.js index b64b97b21e..44f2b44f61 100644 --- a/ionic/components/content/test/pull-to-refresh/main.js +++ b/ionic/components/content/test/pull-to-refresh/main.js @@ -17,6 +17,10 @@ class IonicApp { ) { console.log('IonicApp Start') } + + doRefresh() { + console.log('DOREFRESH') + } } bootstrap(IonicApp) diff --git a/ionic/components/scroll/pull-to-refresh.js b/ionic/components/scroll/pull-to-refresh.js index f15003d23a..10f58d857c 100644 --- a/ionic/components/scroll/pull-to-refresh.js +++ b/ionic/components/scroll/pull-to-refresh.js @@ -1,4 +1,4 @@ -import {NgElement, Decorator, Component, View as NgView, PropertySetter} from 'angular2/angular2'; +import {NgElement, EventEmitter, Decorator, Component, View as NgView, PropertySetter} from 'angular2/angular2'; @Decorator({ selector: '[ion-refresher]' @@ -10,10 +10,23 @@ export class Refresher { this.domElement = element.domElement; this.domElement.classList.add('content'); + this.refreshEvent = new EventEmitter('refreshing'); + console.log(this.domElement); this.domElement.children[0].addEventListener('scroll', function(e) { console.log('CONTENT: scroll', e.target.scrollTop); }); + + setTimeout(() => { + this.refresh() + }, 1000); + } + + refresh() { + console.log('REFRESH'); + this.refreshEvent.next({ + data: 'blah' + }); } }