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 //enyo.log('resizing view ' + view);
91 view.resize(window.innerWidth, window.innerHeight);
93 hackHidden: function(direction) {
94 var view = this.$.hacksCarousel.fetchView(direction);
95 //enyo.log('view ' + view + ' hidden');
99 getHack: function(index) {
100 return {kind: this.hacksList[index].kind};
102 getLeft: function(inSender, inSnap) {
103 if (inSnap && this.index > 0) {
105 this.hackHidden('right');
106 this.setTitle(this.hacksList[this.index].name);
107 this.$.info.addRemoveClass('dark', this.hacksList[this.index].dark);
112 return this.getHack(this.index - 1);
114 getRight: function(inSender, inSnap) {
115 if (inSnap && this.index < this.hacksList.length) {
117 this.hackHidden('left');
118 this.setTitle(this.hacksList[this.index].name);
119 this.$.info.addRemoveClass('dark', this.hacksList[this.index].dark);
121 if (this.index == this.hacksList.length - 1)
124 return this.getHack(this.index + 1);
126 scrolling: function(inSender) {
127 if (inSender.scrollLeft == 0 || inSender.scrollLeft == inSender.getBoundaries().right)
129 //this.$.hacksSelector.index = this.index + ((inSender.scrollLeft - this.lastScrollPos) / window.innerWidth);
130 //this.$.hacksSelector.draw();
132 startScroll: function(inSender) {
135 stopScroll: function(inSender) {
136 this.lastScrollPos = this.$.hacksCarousel.scrollLeft;