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: "HexaSpinner", kind: "HexaSpinnerHack", dark: false},
20 {name: "Landscape", kind: "Landscape", dark: false},
21 {name: "Munch", kind: "Munch", dark: true},
22 {name: "Orbit", kind: "Orbit", dark: false},
23 {name: "Pixelfade", kind: "Pixelfade", dark: true},
24 //{name: "Swarm", kind: "Swarm", dark: false}, // crashy
25 //{name: "Spinner.CGA", kind: "XSpinnerCGA", dark: true}, // no webfont support
26 {name: "Spinner", kind: "XSpinner", dark: true}
29 this.inherited(arguments);
31 this.index = localStorage.getItem('hack.index');
36 this.lastScrollPos = 0;
37 this.$.hacksCarousel.setCenterView(this.getHack(this.index));
38 //this.$.hacksSelector.setHacksList(this.hacksList);
42 window.addEventListener('resize', this.resizeHack.bind(this), false);
43 this.setNotice('Swipe for more...');
44 this.setTitle(this.hacksList[this.index].name);
46 setTitle: function(title) {
47 this.$.title.setContent(title);
50 setNotice: function(notice) {
51 this.$.notice.setContent(notice);
54 infoFade: function() {
55 this.$.info.setStyle('opacity: 1');
58 clearTimeout(this.noticeTimer);
59 this.noticeTimer = setTimeout(function() {
60 this.$.info.setStyle('opacity: 0');
61 setTimeout(function() {
68 windowActivated: function() {
71 windowDeactivated: function() {
74 startHack: function(direction) {
75 var view = this.$.hacksCarousel.fetchView(direction || 'center');
76 //enyo.log('starting view ' + view);
79 //localStorage.setItem('hack.index', this.index);
81 stopHack: function(direction) {
82 var view = this.$.hacksCarousel.fetchView(direction || 'center');
83 //enyo.log('stopping view ' + view);
87 resizeHack: function() {
88 var view = this.$.hacksCarousel.fetchView('center');
90 view.resize(window.innerWidth, window.innerHeight);
91 var view = this.$.hacksCarousel.fetchView('left');
93 view.resize(window.innerWidth, window.innerHeight);
94 var view = this.$.hacksCarousel.fetchView('right');
96 view.resize(window.innerWidth, window.innerHeight);
98 hackHidden: function(direction) {
99 var view = this.$.hacksCarousel.fetchView(direction);
100 //enyo.log('view ' + view + ' hidden');
104 getHack: function(index) {
105 return {kind: this.hacksList[index].kind};
107 getLeft: function(inSender, inSnap) {
108 if (inSnap && this.index > 0) {
110 this.hackHidden('right');
111 this.setTitle(this.hacksList[this.index].name);
112 this.$.info.addRemoveClass('dark', this.hacksList[this.index].dark);
117 return this.getHack(this.index - 1);
119 getRight: function(inSender, inSnap) {
120 if (inSnap && this.index < this.hacksList.length) {
122 this.hackHidden('left');
123 this.setTitle(this.hacksList[this.index].name);
124 this.$.info.addRemoveClass('dark', this.hacksList[this.index].dark);
126 if (this.index == this.hacksList.length - 1)
129 return this.getHack(this.index + 1);
131 scrolling: function(inSender) {
132 if (inSender.scrollLeft == 0 || inSender.scrollLeft == inSender.getBoundaries().right)
134 //this.$.hacksSelector.index = this.index + ((inSender.scrollLeft - this.lastScrollPos) / window.innerWidth);
135 //this.$.hacksSelector.draw();
137 startScroll: function(inSender) {
140 stopScroll: function(inSender) {
141 this.lastScrollPos = this.$.hacksCarousel.scrollLeft;