From da43c0cf7b962434bf7a0ca122071f9aa062c8d9 Mon Sep 17 00:00:00 2001 From: Chip Black Date: Wed, 14 Sep 2011 03:14:24 -0500 Subject: [PATCH] Add prefs for Pixelfade --- hacks/Pixelfade/Pixelfade.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/hacks/Pixelfade/Pixelfade.js b/hacks/Pixelfade/Pixelfade.js index b91d5d2..ac01af1 100644 --- 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); -- 2.25.1