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: "hacksSelector", kind: "HacksSelector"}
11 {name: "info", kind: "HFlexBox", className: "info", style: "opacity: 0", showing: false, components: [
14 {name: "notice", className: "notice"}
18 {name: "Nimbus", kind: "Nimbus", 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));
37 //this.$.hacksSelector.setHacksList(this.hacksList);
41 window.addEventListener('resize', this.resizeHack.bind(this), false);
42 this.setNotice('Swipe for more...');
43 this.setTitle(this.hacksList[this.index].name);
45 setTitle: function(title) {
46 this.$.title.setContent(title);
49 setNotice: function(notice) {
50 this.$.notice.setContent(notice);
53 infoFade: function() {
54 this.$.info.setStyle('opacity: 1');
57 clearTimeout(this.noticeTimer);
58 this.noticeTimer = setTimeout(function() {
59 this.$.info.setStyle('opacity: 0');
60 setTimeout(function() {
67 windowActivated: function() {
70 windowDeactivated: function() {
73 startHack: function(direction) {
74 var view = this.$.hacksCarousel.fetchView(direction || 'center');
75 //enyo.log('starting view ' + view);
78 //localStorage.setItem('hack.index', this.index);
80 stopHack: function(direction) {
81 var view = this.$.hacksCarousel.fetchView(direction || 'center');
82 //enyo.log('stopping view ' + view);
86 resizeHack: function() {
87 var view = this.$.hacksCarousel.fetchView('center');
89 view.resize(window.innerWidth, window.innerHeight);
90 var view = this.$.hacksCarousel.fetchView('left');
92 view.resize(window.innerWidth, window.innerHeight);
93 var view = this.$.hacksCarousel.fetchView('right');
95 view.resize(window.innerWidth, window.innerHeight);
97 hackHidden: function(direction) {
98 var view = this.$.hacksCarousel.fetchView(direction);
99 //enyo.log('view ' + view + ' hidden');
103 getHack: function(index) {
104 return {kind: this.hacksList[index].kind};
106 getLeft: function(inSender, inSnap) {
107 if (inSnap && this.index > 0) {
109 this.hackHidden('right');
110 this.setTitle(this.hacksList[this.index].name);
111 this.$.info.addRemoveClass('dark', this.hacksList[this.index].dark);
116 return this.getHack(this.index - 1);
118 getRight: function(inSender, inSnap) {
119 if (inSnap && this.index < this.hacksList.length) {
121 this.hackHidden('left');
122 this.setTitle(this.hacksList[this.index].name);
123 this.$.info.addRemoveClass('dark', this.hacksList[this.index].dark);
125 if (this.index == this.hacksList.length - 1)
128 return this.getHack(this.index + 1);
130 scrolling: function(inSender) {
131 if (inSender.scrollLeft == 0 || inSender.scrollLeft == inSender.getBoundaries().right)
133 //this.$.hacksSelector.index = this.index + ((inSender.scrollLeft - this.lastScrollPos) / window.innerWidth);
134 //this.$.hacksSelector.draw();
136 startScroll: function(inSender) {
139 stopScroll: function(inSender) {
140 this.lastScrollPos = this.$.hacksCarousel.scrollLeft;