Add prefs for Pixelfade
[Hacks.git] / hacks / Pixelfade / Pixelfade.js
index b91d5d2..ac01af1 100644 (file)
@@ -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);