Roo.form.DayPicker= function(config){
Roo.form.DayPicker.superclass.constructor.call(this, config);
};
Roo.extend(Roo.form.DayPicker, Roo.form.Field, {
focusClass : undefined,
fieldClass: "x-form-field",
defaultAutoCreate : { tag: "input", type: 'hidden', autocomplete: "new-password"},
actionMode : 'viewEl',
inputType : 'hidden',
inputElement: false, basedOn: false, isFormField: true, onResize : function(){
Roo.form.Checkbox.superclass.onResize.apply(this, arguments);
if(!this.boxLabel){
this.el.alignTo(this.wrap, 'c-c');
}
},
initEvents : function(){
Roo.form.Checkbox.superclass.initEvents.call(this);
this.el.on("click", this.onClick, this);
this.el.on("change", this.onClick, this);
},
getResizeEl : function(){
return this.wrap;
},
getPositionEl : function(){
return this.wrap;
},
onRender : function(ct, position){
Roo.form.Checkbox.superclass.onRender.call(this, ct, position);
this.wrap = this.el.wrap({cls: 'x-form-daypick-item '});
var r1 = '<table><tr>';
var r2 = '<tr class="x-form-daypick-icons">';
for (var i=0; i < 7; i++) {
r1+= '<td><div>' + Date.dayNames[i].substring(0,3) + '</div></td>';
r2+= '<td><img class="x-menu-item-icon" src="' + Roo.BLANK_IMAGE_URL +'"></td>';
}
var viewEl = this.wrap.createChild( r1 + '</tr>' + r2 + '</tr></table>');
viewEl.select('img').on('click', this.onClick, this);
this.viewEl = viewEl;
this.el.on('DOMAttrModified', this.setFromHidden, this); this.el.on('propertychange', this.setFromHidden, this); },
initValue : Roo.emptyFn,
getValue : function(){
return this.el.dom.value;
},
onClick : function(e){
Roo.get(e.target).toggleClass('x-menu-item-checked');
this.refreshValue();
},
refreshValue : function()
{
var val = '';
this.viewEl.select('img',true).each(function(e,i,n) {
val += e.is(".x-menu-item-checked") ? String(n) : '';
});
this.setValue(val, true);
},
setValue : function(v,suppressEvent){
if (!this.el.dom) {
return;
}
var old = this.el.dom.value ;
this.el.dom.value = v;
if (suppressEvent) {
return ;
}
this.viewEl.select('img',true).each(function(e,i,n) {
var on = e.is(".x-menu-item-checked");
var newv = v.indexOf(String(n)) > -1;
if (on != newv) {
e.toggleClass('x-menu-item-checked');
}
});
this.fireEvent('change', this, v, old);
},
setFromHidden: function()
{
if(!this.el){
return;
}
this.setValue(this.el.dom.value);
},
onDestroy : function()
{
if(this.viewEl){
Roo.get(this.viewEl).remove();
}
Roo.form.DayPicker.superclass.onDestroy.call(this);
}
});