commit:da43c0cf7b962434bf7a0ca122071f9aa062c8d9
author:Chip Black
committer:Chip Black
date:Wed Sep 14 03:14:24 2011 -0500
parents:28acb24dfb794cace931b151354a94d524af3b22
Add prefs for Pixelfade
diff --git a/hacks/Pixelfade/Pixelfade.js b/hacks/Pixelfade/Pixelfade.js
line changes: +16/-5
index b91d5d2..ac01af1
--- a/hacks/Pixelfade/Pixelfade.js
+++ b/hacks/Pixelfade/Pixelfade.js
@@ -4,6 +4,10 @@ enyo.kind({
 	name: "Pixelfade",
 	kind: "Hack",
 	style: "background-color: yellow; background-position: center center",
+	preferences: [
+		{name: "background", label: "Background", kind: "ListSelector", items: ['desktop wallpaper'].concat(colorList)}
+	],
+	background: 'desktop wallpaper',
 	components: [
 		{name: "canvas", nodeTag: "canvas", onclick: "canvasClick"},
 		{name: "wallpaperService", kind: "PalmService",
@@ -13,10 +17,7 @@ enyo.kind({
 	],
 	create: function() {
 		this.inherited(arguments);
-		this.$.wallpaperService.call({
-			keys: ['wallpaper'],
-			subscribe: false
-		});
+		this.preferencesChanged();
 	},
 	rendered: function() {
 		this.canvas = this.$.canvas.hasNode();
@@ -63,6 +64,16 @@ enyo.kind({
 	hidden: function() {
 		this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
 	},
+	preferencesChanged: function() {
+		if (this.background == 'desktop wallpaper') {
+			this.$.wallpaperService.call({
+				keys: ['wallpaper'],
+				subscribe: false
+			});
+		} else {
+			this.setStyle('background-image: none; background-color: ' + this.background);
+		}
+	},
 	canvasClick: function(inSender, inEvent) {
 		clearTimeout(this.fadeInTimer);
 		clearInterval(this.spotTimer);
@@ -71,7 +82,7 @@ enyo.kind({
 	},
 	gotWallpaper: function(inSender, inResponse) {
 		enyo.log("got background: " + JSON.stringify(inResponse));
-		this.setStyle('background-image: url(' + inResponse.wallpaper.wallpaperFile + '); background-alignment: center center');
+		this.setStyle('background-image: url(' + inResponse.wallpaper.wallpaperFile + '); background-position: center center');
 	},
 	do_fade_spot: function() {
 		var x = Math.floor(Math.random() * this.canvas.width);