﻿
__trGroup('Month/Year picker');Ext.namespace("Credit360");Credit360.MonthYearPicker=function(config){Credit360.MonthYearPicker.superclass.constructor.call(this,config);};Ext.extend(Credit360.MonthYearPicker,Ext.Component,{initComponent:function(){this.addEvents("change");this.value=new Date(this.value);},onRender:function(container,position){var months=[];var abMonths=__trCulture.dateTimeFormat.abbreviatedMonthNames;for(var i=0;i<12;++i){months.push([i,abMonths[i]]);}
var years=[];for(var i=1992;i<=2010;++i){years.push([i]);}
var t=new Ext.XTemplate('<tpl for=".">','<div id="{$id}"'+(this.label?' style="display:inline"':'')+'>','<tpl if="values.label">','<label for="{html-name}_field">','{values.label}','</label>','</tpl>','<table border="0" cellpadding="0" cellspacing="0">','<tr>','<td>','<div id="{id}_month"></div>','</td>','<td>','<div id="{id}_year"></div>','</td>','</tr>','</table>','</div>','</tpl>');this.el=t.insertFirst(container,{id:this.id});this.yearCombo=new Ext.form.ComboBox({value:this.year||(this.value?this.value.getFullYear():2006),renderTo:this.id+'_year',store:new Ext.data.SimpleStore({fields:['year'],data:years}),width:60,mode:'local',forceSelection:true,triggerAction:'all',displayField:'year',editable:false});this.yearCombo.on("select",this.onChange,this);this.monthCombo=new Ext.form.ComboBox({value:this.month||(this.value?this.value.getMonth():0),renderTo:this.id+'_month',store:new Ext.data.SimpleStore({fields:['month','name'],data:months}),width:60,mode:'local',forceSelection:true,triggerAction:'all',displayField:'name',valueField:'month',editable:false});this.monthCombo.on("select",this.onChange,this);},onChange:function(){var v=this.getValue();this.fireEvent("change",this,v,this.value);this.value=v;},destroy:function(){Ext.destroy(this.yearCombo,this.monthCombo);this.purgeListeners();},getValue:function(){return new Date(this.yearCombo.getValue(),this.monthCombo.getValue(),1);},setValue:function(value){this.year=value.getFullYear();this.month=value.getMonth();this.value=new Date(this.year,this.month,1);this.yearCombo.setValue(this.year);this.monthCombo.setValue(this.month);}});Ext.reg('monthYearPicker',Credit360.MonthYearPicker);