1 /* Copyright 2011 The Dominion of Awesome
2 * See COPYING for licensing information */
6 style: "background-color: black",
8 {kind: "ApplicationEvents", onWindowActivated: "windowActivated", onWindowDeactivated: "windowDeactivated"},
9 {name: "hacksCarousel", kind: "Carousel", flex: 1, onGetLeft: "getLeft", onGetRight: "getRight", onScroll: "scrolling", onScrollStart: "startScroll", onScrollStop: "stopScroll"},
10 {name: "info", kind: "HFlexBox", className: "info", style: "opacity: 0", showing: false, components: [
13 {name: "notice", className: "notice"}
17 {name: "Nimbus", kind: "Nimbus", dark: false},
18 {name: "HexaSpinner", kind: "HexaSpinnerHack", dark: false},
19 {name: "Landscape", kind: "Landscape", dark: false},
20 {name: "Munch", kind: "Munch", dark: true},
21 {name: "Orbit", kind: "Orbit", dark: false},
22 {name: "Pixelfade", kind: "Pixelfade", dark: true},
23 //{name: "Swarm", kind: "Swarm", dark: false}, // crashy
24 //{name: "Spinner.CGA", kind: "XSpinnerCGA", dark: true}, // no webfont support
25 {name: "Spinner", kind: "XSpinner", dark: true}
28 this.inherited(arguments);
30 this.index = localStorage.getItem('hack.index');
35 this.lastScrollPos = 0;
36 this.$.hacksCarousel.setCenterView(this.getHack(this.index));
40 window.addEventListener('resize', this.resizeHack.bind(this), false);
41 this.setNotice('Swipe for more...');
42 this.setTitle(this.hacksList[this.index].name);
44 setTitle: function(title) {
45 this.$.title.setContent(title);
48 setNotice: function(notice) {
49 this.$.notice.setContent(notice);
52 infoFade: function() {
53 this.$.info.setStyle('opacity: 1');
56 clearTimeout(this.noticeTimer);
57 this.noticeTimer = setTimeout(function() {
58 this.$.info.setStyle('opacity: 0');
59 setTimeout(function() {
66 windowActivated: function() {
69 windowDeactivated: function() {
72 startHack: function(direction) {
73 var view = this.$.hacksCarousel.fetchView(direction || 'center');
74 //enyo.log('starting view ' + view);
77 //localStorage.setItem('hack.index', this.index);
79 stopHack: function(direction) {
80 var view = this.$.hacksCarousel.fetchView(direction || 'center');
81 //enyo.log('stopping view ' + view);
85 resizeHack: function() {
86 var view = this.$.hacksCarousel.fetchView('center');
88 view.resize(window.innerWidth, window.innerHeight);
89 var view = this.$.hacksCarousel.fetchView('left');
91 view.resize(window.innerWidth, window.innerHeight);
92 var view = this.$.hacksCarousel.fetchView('right');
94 view.resize(window.innerWidth, window.innerHeight);
96 hackHidden: function(direction) {
97 var view = this.$.hacksCarousel.fetchView(direction);
98 //enyo.log('view ' + view + ' hidden');
102 getHack: function(index) {
103 return {kind: this.hacksList[index].kind};
105 getLeft: function(inSender, inSnap) {
106 if (inSnap && this.index > 0) {
108 this.hackHidden('right');
109 this.setTitle(this.hacksList[this.index].name);
110 this.$.info.addRemoveClass('dark', this.hacksList[this.index].dark);
115 return this.getHack(this.index - 1);
117 getRight: function(inSender, inSnap) {
118 if (inSnap && this.index < this.hacksList.length) {
120 this.hackHidden('left');
121 this.setTitle(this.hacksList[this.index].name);
122 this.$.info.addRemoveClass('dark', this.hacksList[this.index].dark);
124 if (this.index == this.hacksList.length - 1)
127 return this.getHack(this.index + 1);
129 scrolling: function(inSender) {
130 if (inSender.scrollLeft == 0 || inSender.scrollLeft == inSender.getBoundaries().right)
133 startScroll: function(inSender) {
136 stopScroll: function(inSender) {
137 this.lastScrollPos = this.$.hacksCarousel.scrollLeft;