comparison app/view/widget/base/CheckBox.js @ 610:f240fe19ff5d

Added a Checkbox Widget
author Dustin Demuth <dustin@intevation.de>
date Fri, 13 Mar 2015 13:20:49 +0100
parents
children fead63bb5fb4
comparison
equal deleted inserted replaced
607:80077aeaa9ed 610:f240fe19ff5d
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU GPL (v>=3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
6 * the documentation coming with IMIS-Labordaten-Application for details.
7 */
8
9 Ext.define('Lada.view.widget.base.CheckBox', {
10 extend: 'Ext.form.Panel',
11 alias: 'widget.chkbox',
12
13 layout: 'hbox',
14
15 border: 0,
16
17 margin: '0, 0, 5, 0',
18
19 initComponent: function() {
20 this.items = [{
21 xtype: 'checkbox',
22 flex: 1,
23 name: this.name,
24 fieldLabel: this.fieldLabel,
25 labelWidth: this.labelWidth,
26 listeners: this.listeners,
27 triggerAction: this.triggerAction,
28 msgTarget: 'none',
29 tpl: this.tpl
30 }, {
31 xtype: 'image',
32 name: 'warnImg',
33 src: 'resources/img/icon-warning.gif',
34 width: 12,
35 height: 12,
36 hidden: true
37 }, {
38 xtype: 'image',
39 name: 'errorImg',
40 src: 'resources/img/icon-error.gif',
41 width: 12,
42 height: 12,
43 hidden: true
44 }];
45 this.callParent(arguments);
46 },
47
48 showWarnings: function(warnings) {
49 var img = this.down('image[name=warnImg]');
50 Ext.create('Ext.tip.ToolTip', {
51 target: img.getEl(),
52 html: warnings
53 });
54 this.down('checkbox').invalidCls = 'x-lada-warning';
55 this.down('checkbox').markInvalid('');
56 img.show();
57 var fieldset = this.up('fieldset[collapsible=true]');
58 if (fieldset) {
59 fieldset.showWarnings(warnings);
60 }
61 },
62
63 showErrors: function(errors) {
64 var img = this.down('image[name=errorImg]');
65 var warnImg = this.down('image[name=warnImg]');
66 warnImg.hide();
67 Ext.create('Ext.tip.ToolTip', {
68 target: img.getEl(),
69 html: errors
70 });
71 this.down('checkbox').invalidCls = 'x-lada-error';
72 this.down('checkbox').markInvalid('');
73 img.show();
74 var fieldset = this.up('fieldset[collapsible=true]');
75 if (fieldset) {
76 fieldset.showErrors();
77 }
78 },
79
80 clearWarningOrError: function() {
81 this.down('image[name=errorImg]').hide();
82 this.down('image[name=warnImg]').hide();
83 },
84
85 getValue: function() {
86 return this.down('checkbox').getValue();
87 },
88
89 getName: function() {
90 return this.name;
91 },
92
93 setReadOnly: function(value) {
94 this.down('checkbox').setReadOnly(value);
95 }
96 });

http://lada.wald.intevation.org