Commit 05b9f1f4e8c4de1041933cbb0f2fa292930e9465

  • avatar
  • Sergey 'Jin' Bostandzhyan <jin @deve…per.digitalstrom.org>
  • Wed Jul 28 19:17:34 CEST 2010
Addes slider for light brightness settings
dss-setup-interface/dSS/scene/SceneWindowLight.js
(90 / 13)
  
11//= require <dSS/GetTextHelper>
22//= require <dSS/config/Config>
3//= require <dSS/util/Util>
34
4Ext.namespace("dSS", "dSS.scene", "dSS.config");
5Ext.namespace("dSS", "dSS.scene", "dSS.config", "dSS.util");
56
67// parameters:
78// maskElement
89// dsid
910dSS.scene.SceneWindowLight = Ext.extend(Ext.Window, {
1011 constructor: function(config) {
12 this.messagePanel = new Ext.Panel(
13 {
14 xtype: 'panel',
15 ref: 'message',
16 id: 'message',
17 height: 20,
18 columnWidth: 1,
19 bodyCfg: { cls: 'x-text-align-center x-window-body' },
20 autoEl: 'span',
21 html: _("Move slider to change brightness."),
22 bodyBorder: false
23 }
24 );
1125
26 this.dsid = config.dsid;
27
1228 Ext.apply(this, {
1329 layout: 'fit',
1430 width: 370,
15 height: 180,
31 height: 220,
1632 resizable : false,
1733 iconCls: 'functionLightIcon',
1834 title: _("Control light"),
6666 }
6767 ]
6868 },
69
7069 {
7170 xtype: 'panel',
7271 html: '',
7372 width: 25,
74 rowspan: 3,
73 rowspan: 5,
7574 bodyBorder: false,
7675 border: false,
7776 frame: false
7877 },
7978 {
79 xtype: 'panel',
80 bodyCfg: { cls: 'x-window-body' },
81 colspan: 4,
82 layout: 'table',
83 layoutConfig:
84 {
85 columns : 3,
86 tableAttrs: { width: '100%' }
87 },
88 items: [
89 {
90 xtype: 'panel',
91 bodyCfg: { cls: 'x-window-body' },
92 autoEl: {
93 tag: 'img',
94 align: 'left',
95 src: '/images/lightbulb_off.png'
96 }
97 },
98 this.messagePanel,
99 {
100 xtype: 'panel',
101 bodyCfg: { cls: 'x-window-body' },
102 autoEl: {
103 tag: 'img',
104 align: 'right',
105 src: '/images/lightbulb.png'
106 }
107 },
108
109 ]
110 },
111 {
112 xtype: 'panel',
113 html: '',
114 width: 25,
115 rowspan: 5,
116 bodyBorder: false,
117 border: false,
118 frame:false
119 },
120 {
121 xtype: 'slider',
122 minValue: 0,
123 increment: 1,
124 maxValue: 100,
125 plugins: new Ext.slider.Tip({
126 getText: function(thumb){
127 return String.format('{0}%',
128 thumb.value);
129 }
130 }),
131 colspan: 4,
132 listeners: {
133 changeComplete:
134 this.handleSliderChanged.createDelegate(this)
135 }
136 },
137 {
80138 xtype: 'button',
81139 layout: 'fit',
82140 width: 70,
176176 },
177177 {
178178 xtype: 'panel',
179 html: '',
180 width: 25,
181 rowspan: 3,
182 bodyBorder: false,
183 border: false,
184 frame:false
185 },
186 {
187 xtype: 'panel',
188179 bodyCfg: { cls: 'x-window-body' },
189180 html: '',
190181 height: 15,
237237 this
238238 );
239239
240 },
241 handleSliderChanged: function(slider, newVal, thumb) {
242 this.messagePanel.update(_("Brightness set to") + ": " + newVal + "%");
243 var value = newVal / 100;
244 value = value * 255;
245 if (value < 0) {
246 value = 0;
247 } else if (value > 255) {
248 value = 255;
249 }
250
251 dSS.util.setValueOnDevice(this.dsid, Math.round(value));
240252 }
241253});