Commit 05b9f1f4e8c4de1041933cbb0f2fa292930e9465
- Diff rendering mode:
- inline
- side by side
dss-setup-interface/dSS/scene/SceneWindowLight.js
(90 / 13)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | 2 | //= require <dSS/config/Config> | |
| 3 | //= require <dSS/util/Util> | ||
| 3 | 4 | ||
| 4 | Ext.namespace("dSS", "dSS.scene", "dSS.config"); | ||
| 5 | Ext.namespace("dSS", "dSS.scene", "dSS.config", "dSS.util"); | ||
| 5 | 6 | ||
| 6 | 7 | // parameters: | |
| 7 | 8 | // maskElement | |
| 8 | 9 | // dsid | |
| 9 | 10 | dSS.scene.SceneWindowLight = Ext.extend(Ext.Window, { | |
| 10 | 11 | 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 | ); | ||
| 11 | 25 | ||
| 26 | this.dsid = config.dsid; | ||
| 27 | |||
| 12 | 28 | Ext.apply(this, { | |
| 13 | 29 | layout: 'fit', | |
| 14 | 30 | width: 370, | |
| 15 | height: 180, | ||
| 31 | height: 220, | ||
| 16 | 32 | resizable : false, | |
| 17 | 33 | iconCls: 'functionLightIcon', | |
| 18 | 34 | title: _("Control light"), | |
| … | … | ||
| 66 | 66 | } | |
| 67 | 67 | ] | |
| 68 | 68 | }, | |
| 69 | |||
| 70 | 69 | { | |
| 71 | 70 | xtype: 'panel', | |
| 72 | 71 | html: '', | |
| 73 | 72 | width: 25, | |
| 74 | rowspan: 3, | ||
| 73 | rowspan: 5, | ||
| 75 | 74 | bodyBorder: false, | |
| 76 | 75 | border: false, | |
| 77 | 76 | frame: false | |
| 78 | 77 | }, | |
| 79 | 78 | { | |
| 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 | { | ||
| 80 | 138 | xtype: 'button', | |
| 81 | 139 | layout: 'fit', | |
| 82 | 140 | width: 70, | |
| … | … | ||
| 176 | 176 | }, | |
| 177 | 177 | { | |
| 178 | 178 | xtype: 'panel', | |
| 179 | html: '', | ||
| 180 | width: 25, | ||
| 181 | rowspan: 3, | ||
| 182 | bodyBorder: false, | ||
| 183 | border: false, | ||
| 184 | frame:false | ||
| 185 | }, | ||
| 186 | { | ||
| 187 | xtype: 'panel', | ||
| 188 | 179 | bodyCfg: { cls: 'x-window-body' }, | |
| 189 | 180 | html: '', | |
| 190 | 181 | height: 15, | |
| … | … | ||
| 237 | 237 | this | |
| 238 | 238 | ); | |
| 239 | 239 | ||
| 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)); | ||
| 240 | 252 | } | |
| 241 | 253 | }); |

