1 //<script type="text/javascript">
3 * @class Ext.form.Checkbox
4 * @extends Ext.form.Field
5 * Single checkbox field. Can be used as a direct replacement for traditional checkbox fields.
7 * Creates a new Checkbox
8 * @param {Object} config Configuration options
10 Ext.form.DisplayImage = function(config){
11 Ext.form.DisplayImage.superclass.constructor.call(this, config);
15 Ext.extend(Ext.form.DisplayImage, Ext.form.Field, {
17 * @cfg {Number} width - mostly ignored
21 * @cfg {Number} height - used to restrict height of image..
25 * @cfg {String} focusClass The CSS class to use when the checkbox receives focus (defaults to undefined)
29 * @cfg {String} focusClass The CSS class to use when the checkbox receives focus (defaults to undefined)
31 focusClass : undefined,
33 * @cfg {String} fieldClass The default CSS class for the checkbox (defaults to "x-form-field")
35 fieldClass: 'x-form-field',
37 * @cfg {Boolean} checked True if the the checkbox should render already checked (defaults to false)
41 * @cfg {String/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to
42 * {tag: "input", type: "checkbox", autocomplete: "off"})
44 // defaultAutoCreate : { tag: 'div' },
45 defaultAutoCreate : { tag: 'input', type: 'hidden', autocomplete: 'off'},
47 * @cfg {String} addTitle Text to include for adding a title.
51 * @cfg {Function} renderer Method to return raw HTML to render for the image..
55 onResize : function(){
56 Ext.form.Field.superclass.onResize.apply(this, arguments);
60 initEvents : function(){
61 // Ext.form.Checkbox.superclass.initEvents.call(this);
67 getResizeEl : function(){
71 getPositionEl : function(){
76 onRender : function(ct, position){
78 this.style = this.style || '';
79 var style = this.style;
82 Ext.form.DisplayImage.superclass.onRender.call(this, ct, position);
83 this.wrap = this.el.wrap({cls: 'x-menu-check-item '});
84 this.viewEl = this.wrap.createChild({ tag: 'table', html : '<tr><td align="center"></td></tr>' });
86 this.viewEl.applyStyles(style);
89 this.viewEl.setWidth(this.width);
92 this.viewEl.setHeight(this.height);
94 //if(this.inputValue !== undefined){
95 //this.setValue(this.value);
102 initValue : Ext.emptyFn,
105 * Returns the checked state of the checkbox.
106 * @return {Boolean} True if checked, else false
110 * Sets the value of the item.
111 * @param {Boolean/String} checked True, 'true', '1', or 'on' to check the checkbox, any other value will uncheck it.
113 setValue : function(v){
119 var html = this.renderer ?
121 : String.format('<img src="{0}" height="{1}">', Roo.BLANK_IMAGE_URL, this.height);
126 html += '<p id="' + id + '" class="x-action-box-action x-action-ico-edit x-action-box" ' +
127 ' style="display: block;' + ( this.icon ? 'background-image: url(' + this.icon + ');' : '') + '"' +
128 '>' + this.addTitle + '</p>';
130 // unlink old handler???
131 // width is flexible...
132 this.viewEl.child('td').dom.innerHTML = html;
133 if (id && this.handler) {
134 Roo.get(id).on('click', this.handler, this);
137 Roo.form.DisplayImage.superclass.setValue.call(this, v);