8 * @class Roo.form.DayPicker
9 * @extends Roo.form.Field
10 * A Day picker show [M] [T] [W] ....
12 * Creates a new Day Picker
13 * @param {Object} config Configuration options
15 Roo.form.DayPicker= function(config){
16 Roo.form.DayPicker.superclass.constructor.call(this, config);
20 Roo.extend(Roo.form.DayPicker, Roo.form.Field, {
22 * @cfg {String} focusClass The CSS class to use when the checkbox receives focus (defaults to undefined)
24 focusClass : undefined,
26 * @cfg {String} fieldClass The default CSS class for the checkbox (defaults to "x-form-field")
28 fieldClass: "x-form-field",
31 * @cfg {String/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to
32 * {tag: "input", type: "checkbox", autocomplete: "off"})
34 defaultAutoCreate : { tag: "input", type: 'hidden', autocomplete: "off"},
37 actionMode : 'viewEl',
44 inputElement: false, // real input element?
45 basedOn: false, // ????
47 isFormField: true, // not sure where this is needed!!!!
49 onResize : function(){
50 Roo.form.Checkbox.superclass.onResize.apply(this, arguments);
52 this.el.alignTo(this.wrap, 'c-c');
56 initEvents : function(){
57 Roo.form.Checkbox.superclass.initEvents.call(this);
58 this.el.on("click", this.onClick, this);
59 this.el.on("change", this.onClick, this);
63 getResizeEl : function(){
67 getPositionEl : function(){
73 onRender : function(ct, position){
74 Roo.form.Checkbox.superclass.onRender.call(this, ct, position);
76 this.wrap = this.el.wrap({cls: 'x-form-daypick-item '});
80 var r1 = '<table><tr>'
82 var r1 = '<table><tr>';
83 >>>>>>> bb63e2e529c47fb77152cfc02100d5ff9fdca211
85 var r1 = '<table><tr>';
86 >>>>>>> bb63e2e529c47fb77152cfc02100d5ff9fdca211
87 var r2 = '<tr class="x-form-daypick-icons">';
88 for (var i=0; i < 7; i++) {
89 r1+= '<td><div>' + Date.dayNames[i].substring(0,3) + '</div></td>';
90 r2+= '<td><img class="x-menu-item-icon" src="' + Roo.BLANK_IMAGE_URL +'"></td>';
93 var viewEl = this.wrap.createChild( r1 + '</tr>' + r2 + '</tr></table>');
94 viewEl.select('img').on('click', this.onClick, this);
98 // this will not work on Chrome!!!
99 this.el.on('DOMAttrModified', this.setFromHidden, this); //ff
100 this.el.on('propertychange', this.setFromHidden, this); //ie
108 initValue : Roo.emptyFn,
111 * Returns the checked state of the checkbox.
112 * @return {Boolean} True if checked, else false
114 getValue : function(){
115 return this.el.dom.value;
120 onClick : function(e){
121 //this.setChecked(!this.checked);
122 Roo.get(e.target).toggleClass('x-menu-item-checked');
124 //if(this.el.dom.checked != this.checked){
125 // this.setValue(this.el.dom.checked);
130 refreshValue : function()
133 this.viewEl.select('img',true).each(function(e,i,n) {
134 val += e.is(".x-menu-item-checked") ? String(n) : '';
136 this.setValue(val, true);
140 * Sets the checked state of the checkbox.
141 * On is always based on a string comparison between inputValue and the param.
142 * @param {Boolean/String} value - the value to set
143 * @param {Boolean/String} suppressEvent - whether to suppress the checkchange event.
145 setValue : function(v,suppressEvent){
149 var old = this.el.dom.value ;
150 this.el.dom.value = v;
157 for (var i =0; i < v.length;i++) {
158 cur[v.substring(i,i+1)] = 1 ;
162 >>>>>>> bb63e2e529c47fb77152cfc02100d5ff9fdca211
165 >>>>>>> bb63e2e529c47fb77152cfc02100d5ff9fdca211
167 this.viewEl.select('img',true).each(function(e,i,n) {
169 var on = e.is(".x-menu-item-checked");
172 var newv = typeof(cur[n]) != 'undefined';
174 var newv = v.indexOf(String(n)) > -1;
175 >>>>>>> bb63e2e529c47fb77152cfc02100d5ff9fdca211
177 var newv = v.indexOf(String(n)) > -1;
178 >>>>>>> bb63e2e529c47fb77152cfc02100d5ff9fdca211
180 e.toggleClass('x-menu-item-checked');
186 this.fireEvent('change', this, v, old);
191 // handle setting of hidden value by some other method!!?!?
192 setFromHidden: function()
197 //console.log("SET FROM HIDDEN");
198 //alert('setFrom hidden');
199 this.setValue(this.el.dom.value);
202 onDestroy : function()
205 Roo.get(this.viewEl).remove();
208 Roo.form.DayPicker.superclass.onDestroy.call(this);