more quote identeiifers fixessss
[Pman.Core] / widgets / DisplayImage.js
1 //<script type="text/javascript">
2 /**
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.
6  * @constructor
7  * Creates a new Checkbox
8  * @param {Object} config Configuration options
9  */
10 Ext.form.DisplayImage = function(config){
11     Ext.form.DisplayImage.superclass.constructor.call(this, config);
12      
13 };
14
15 Ext.extend(Ext.form.DisplayImage, Ext.form.Field,  {
16     /**
17      * @cfg {Number} width  - mostly ignored
18      */
19     width : 100,
20     /**
21      * @cfg {Number} height - used to restrict height of image..
22      */
23     width : 50,
24      /**
25      * @cfg {String} focusClass The CSS class to use when the checkbox receives focus (defaults to undefined)
26      */
27     
28     /**
29      * @cfg {String} focusClass The CSS class to use when the checkbox receives focus (defaults to undefined)
30      */
31     focusClass : undefined,
32     /**
33      * @cfg {String} fieldClass The default CSS class for the checkbox (defaults to "x-form-field")
34      */
35     fieldClass: 'x-form-field',
36     /**
37      * @cfg {Boolean} checked True if the the checkbox should render already checked (defaults to false)
38      */
39     checked: false,
40     /**
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"})
43      */
44    // defaultAutoCreate : { tag: 'div' },
45      defaultAutoCreate : { tag: 'input', type: 'hidden', autocomplete: 'off'},
46     /**
47      * @cfg {String} addTitle Text to include for adding a title.
48      */
49      addTitle : false,
50     /**
51      * @cfg {Function} renderer Method to return raw HTML to render for the image..
52      */ 
53      
54     //
55     onResize : function(){
56         Ext.form.Field.superclass.onResize.apply(this, arguments);
57         
58     },
59
60     initEvents : function(){
61         // Ext.form.Checkbox.superclass.initEvents.call(this);
62         // has no events...
63        
64     },
65
66
67     getResizeEl : function(){
68         return this.wrap;
69     },
70
71     getPositionEl : function(){
72         return this.wrap;
73     },
74
75     // private
76     onRender : function(ct, position){
77         
78         this.style = this.style || '';
79         var style = this.style;
80         delete this.style;
81         
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>' });
85         if (style) {
86             this.viewEl.applyStyles(style);
87         }
88         if (this.width) {
89             this.viewEl.setWidth(this.width);
90         }
91         if (this.height) {
92             this.viewEl.setHeight(this.height);
93         }
94         //if(this.inputValue !== undefined){
95         //this.setValue(this.value);
96         
97         
98         
99     },
100
101     // private
102     initValue : Ext.emptyFn,
103
104     /**
105      * Returns the checked state of the checkbox.
106      * @return {Boolean} True if checked, else false
107      */
108     
109     /**
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.
112      */
113     setValue : function(v){
114         this.value = v;
115         
116         if (!this.el) {
117             return;
118         }
119         var html = this.renderer ? 
120             this.renderer(v)
121             : String.format('<img src="{0}" height="{1}">', Roo.BLANK_IMAGE_URL, this.height);
122        
123         var id = false;
124         if (this.addTitle) {
125             id = Roo.id();
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>';
129         }
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);
135         }
136         
137         Roo.form.DisplayImage.superclass.setValue.call(this, v);
138     }
139     
140      
141     
142     
143 });