3 * Copyright(c) 2006-2011 Sencha Inc.
5 * http://www.sencha.com/license
9 * @class Ext.ux.desktop.Wallpaper
10 * @extends Ext.Component
11 * <p>This component renders an image that stretches to fill the component.</p>
13 Ext.define('Ext.ux.desktop.Wallpaper', {
14 extend: 'Ext.Component',
16 alias: 'widget.wallpaper',
19 html: '<img src="'+Ext.BLANK_IMAGE_URL+'">',
24 afterRender: function () {
27 me.setWallpaper(me.wallpaper, me.stretch);
30 applyState: function () {
31 var me = this, old = me.wallpaper;
32 me.callParent(arguments);
33 if (old != me.wallpaper) {
34 me.setWallpaper(me.wallpaper);
38 getState: function () {
39 return this.wallpaper && { wallpaper: this.wallpaper };
42 setWallpaper: function (wallpaper, stretch) {
43 var me = this, imgEl, bkgnd;
45 me.stretch = (stretch !== false);
46 me.wallpaper = wallpaper;
49 imgEl = me.el.dom.firstChild;
51 if (!wallpaper || wallpaper == Ext.BLANK_IMAGE_URL) {
52 Ext.fly(imgEl).hide();
53 } else if (me.stretch) {
54 imgEl.src = wallpaper;
56 me.el.removeCls('ux-wallpaper-tiled');
57 Ext.fly(imgEl).setStyle({
62 Ext.fly(imgEl).hide();
64 bkgnd = 'url('+wallpaper+')';
65 me.el.addCls('ux-wallpaper-tiled');
69 backgroundImage: bkgnd || ''