Roo/bootstrap/MonthField.js
[roojs1] / Roo / bootstrap / MonthField.js
1 /*
2  * - LGPL
3  *
4  * MonthField
5  * 
6  */
7
8 /**
9  * @class Roo.bootstrap.MonthField
10  * @extends Roo.bootstrap.Input
11  * Bootstrap MonthField class
12  * 
13  * @cfg {String} language default en
14  * 
15  * @constructor
16  * Create a new MonthField
17  * @param {Object} config The config object
18  */
19
20 Roo.bootstrap.MonthField = function(config){
21     Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
22     
23     this.addEvents({
24         /**
25          * @event show
26          * Fires when this field show.
27          * @param {Roo.bootstrap.MonthField} this
28          * @param {Mixed} date The date value
29          */
30         show : true,
31         /**
32          * @event show
33          * Fires when this field hide.
34          * @param {Roo.bootstrap.MonthField} this
35          * @param {Mixed} date The date value
36          */
37         hide : true,
38         /**
39          * @event select
40          * Fires when select a date.
41          * @param {Roo.bootstrap.MonthField} this
42          * @param {Mixed} date The date value
43          */
44         select : true
45     });
46 };
47
48 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input,  {
49     
50     format : "F",
51     
52     onRender: function(ct, position)
53     {
54         
55         Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
56         
57         this.language = this.language || 'en';
58         this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
59         this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
60         
61         this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
62         this.format = this.format || 'F';
63         this.isInline = false;
64         this.isInput = true;
65         this.component = this.el.select('.add-on', true).first() || false;
66         this.component = (this.component && this.component.length === 0) ? false : this.component;
67         this.hasInput = this.component && this.inputEL().length;
68         
69         this.minViewMode = 1;
70         this.viewMode = 1;
71                 
72         this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
73         
74         this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
75         
76         this.picker().on('mousedown', this.onMousedown, this);
77         this.picker().on('click', this.onClick, this);
78         
79         this.picker().addClass('datepicker-dropdown');
80         
81         this.startViewMode = this.viewMode;
82         
83         Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
84             v.setVisibilityMode(Roo.Element.DISPLAY)
85             v.hide();
86         })
87
88         Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
89             v.setStyle('width', '189px');
90         });
91         
92         Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
93             if(!this.calendarWeeks){
94                 v.remove();
95                 return;
96             };
97             
98             v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today
99             v.attr('colspan', function(i, val){
100                 return parseInt(val) + 1;
101             });
102         })
103                         
104         
105         this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
106         
107         this.setStartDate(this.startDate);
108         this.setEndDate(this.endDate);
109         
110         this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
111         
112         this.fillDow();
113         this.fillMonths();
114         this.update();
115         this.showMode();
116         
117         if(this.isInline) {
118             this.show();
119         }
120     },
121     
122     setValue: function(v)
123     {
124         
125         var d = new Date(this.parseDate(v) ).clearTime();
126         
127         if(isNaN(d.getTime())){
128             this.date = this.viewDate = '';
129             Roo.bootstrap.DateField.superclass.setValue.call(this, '');
130             return;
131         }
132         
133         v = this.formatDate(d);
134         
135         Roo.bootstrap.DateField.superclass.setValue.call(this, v);
136         
137         this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
138      
139         this.update();
140
141         this.fireEvent('select', this, this.date);
142         
143     },
144     
145     onClick: function(e) 
146     {
147         e.stopPropagation();
148         e.preventDefault();
149         
150         var target = e.getTarget();
151         
152         if(target.nodeName.toLowerCase() === 'i'){
153             target = Roo.get(target).dom.parentNode;
154         }
155         
156         var nodeName = target.nodeName;
157         var className = target.className;
158         var html = target.innerHTML;
159         
160         if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
161             return;
162         }
163         this.viewDate.setUTCDate(1);
164         this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
165         
166         this.setValue(this.formatDate(this.viewDate));
167         this.hide();
168                         
169     },
170     
171     picker : function()
172     {
173         return this.pickerEl;
174 //        return this.el.select('.datepicker', true).first();
175     },
176     
177     fillDow: function()
178     {
179         var dowCnt = this.weekStart;
180         
181         var dow = {
182             tag: 'tr',
183             cn: [
184                 
185             ]
186         };
187         
188         if(this.calendarWeeks){
189             dow.cn.push({
190                 tag: 'th',
191                 cls: 'cw',
192                 html: ' '
193             })
194         }
195         
196         while (dowCnt < this.weekStart + 7) {
197             dow.cn.push({
198                 tag: 'th',
199                 cls: 'dow',
200                 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
201             });
202         }
203         
204         this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
205     },
206     
207     fillMonths: function()
208     {    
209         var i = 0
210         var months = this.picker().select('>.datepicker-months td', true).first();
211         
212         months.dom.innerHTML = '';
213         
214         while (i < 12) {
215             var month = {
216                 tag: 'span',
217                 cls: 'month',
218                 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
219             }
220             
221             months.createChild(month);
222         }
223         
224     },
225     
226     update: function()
227     {
228         this.date = (typeof(this.date) === 'undefined' || ((typeof(this.date) === 'string') && !this.date.length)) ? this.UTCToday() : (typeof(this.date) === 'string') ? this.parseDate(this.date) : this.date;
229         
230         if (this.date < this.startDate) {
231             this.viewDate = new Date(this.startDate);
232         } else if (this.date > this.endDate) {
233             this.viewDate = new Date(this.endDate);
234         } else {
235             this.viewDate = new Date(this.date);
236         }
237         
238         this.fill();
239     },
240     
241     fill: function() 
242     {
243         var d = new Date(this.viewDate),
244                 year = d.getUTCFullYear(),
245                 month = d.getUTCMonth(),
246                 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
247                 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
248                 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
249                 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
250                 currentDate = this.date && this.date.valueOf(),
251                 today = this.UTCToday();
252         
253         this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
254         
255 //        this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
256         
257 //        this.picker.select('>tfoot th.today').
258 //                                              .text(dates[this.language].today)
259 //                                              .toggle(this.todayBtn !== false);
260     
261         this.updateNavArrows();
262         this.fillMonths();
263                                                 
264         var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
265         
266         day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
267          
268         prevMonth.setUTCDate(day);
269         
270         prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
271         
272         var nextMonth = new Date(prevMonth);
273         
274         nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
275         
276         nextMonth = nextMonth.valueOf();
277         
278         var fillMonths = false;
279         
280         this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
281         
282         while(prevMonth.valueOf() < nextMonth) {
283             var clsName = '';
284             
285             if (prevMonth.getUTCDay() === this.weekStart) {
286                 if(fillMonths){
287                     this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
288                 }
289                     
290                 fillMonths = {
291                     tag: 'tr',
292                     cn: []
293                 };
294                 
295                 if(this.calendarWeeks){
296                     // ISO 8601: First week contains first thursday.
297                     // ISO also states week starts on Monday, but we can be more abstract here.
298                     var
299                     // Start of current week: based on weekstart/current date
300                     ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
301                     // Thursday of this week
302                     th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
303                     // First Thursday of year, year from thursday
304                     yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
305                     // Calendar week: ms between thursdays, div ms per day, div 7 days
306                     calWeek =  (th - yth) / 864e5 / 7 + 1;
307                     
308                     fillMonths.cn.push({
309                         tag: 'td',
310                         cls: 'cw',
311                         html: calWeek
312                     });
313                 }
314             }
315             
316             if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
317                 clsName += ' old';
318             } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
319                 clsName += ' new';
320             }
321             if (this.todayHighlight &&
322                 prevMonth.getUTCFullYear() == today.getFullYear() &&
323                 prevMonth.getUTCMonth() == today.getMonth() &&
324                 prevMonth.getUTCDate() == today.getDate()) {
325                 clsName += ' today';
326             }
327             
328             if (currentDate && prevMonth.valueOf() === currentDate) {
329                 clsName += ' active';
330             }
331             
332             if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
333                     this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
334                     clsName += ' disabled';
335             }
336             
337             fillMonths.cn.push({
338                 tag: 'td',
339                 cls: 'day ' + clsName,
340                 html: prevMonth.getDate()
341             })
342             
343             prevMonth.setDate(prevMonth.getDate()+1);
344         }
345           
346         var currentYear = this.date && this.date.getUTCFullYear();
347         var currentMonth = this.date && this.date.getUTCMonth();
348         
349         this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
350         
351         Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
352             v.removeClass('active');
353             
354             if(currentYear === year && k === currentMonth){
355                 v.addClass('active');
356             }
357             
358             if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
359                 v.addClass('disabled');
360             }
361             
362         });
363         
364         
365         year = parseInt(year/10, 10) * 10;
366         
367         this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
368         
369         this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
370         
371         year -= 1;
372         for (var i = -1; i < 11; i++) {
373             this.picker().select('>.datepicker-years tbody td',true).first().createChild({
374                 tag: 'span',
375                 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
376                 html: year
377             })
378             
379             year += 1;
380         }
381     },
382     
383     showMode: function(dir) 
384     {
385         if (dir) {
386             this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
387         }
388         
389         Roo.each(this.picker().select('>div',true).elements, function(v){
390             v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
391             v.hide();
392         });
393         this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
394     },
395     
396     place: function()
397     {
398         if(this.isInline) return;
399         
400         this.picker().removeClass(['bottom', 'top']);
401         
402         if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
403             /*
404              * place to the top of element!
405              *
406              */
407             
408             this.picker().addClass('top');
409             this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
410             
411             return;
412         }
413         
414         this.picker().addClass('bottom');
415         
416         this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
417     },
418     
419     parseDate : function(value)
420     {
421         if(!value || value instanceof Date){
422             return value;
423         }
424         var v = Date.parseDate(value, this.format);
425         if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
426             v = Date.parseDate(value, 'Y-m-d');
427         }
428         if(!v && this.altFormats){
429             if(!this.altFormatsArray){
430                 this.altFormatsArray = this.altFormats.split("|");
431             }
432             for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
433                 v = Date.parseDate(value, this.altFormatsArray[i]);
434             }
435         }
436         return v;
437     },
438     
439     formatDate : function(date, fmt)
440     {   
441         return (!date || !(date instanceof Date)) ?
442         date : date.dateFormat(fmt || this.format);
443     },
444     
445     onFocus : function()
446     {
447         Roo.bootstrap.DateField.superclass.onFocus.call(this);
448         this.show();
449     },
450     
451     onBlur : function()
452     {
453         Roo.bootstrap.DateField.superclass.onBlur.call(this);
454         
455         var d = this.inputEl().getValue();
456         
457         this.setValue(d);
458                 
459         this.hide();
460     },
461     
462     show : function()
463     {
464         this.picker().show();
465         this.update();
466         this.place();
467         
468         this.fireEvent('show', this, this.date);
469     },
470     
471     hide : function()
472     {
473         if(this.isInline) return;
474         this.picker().hide();
475         this.viewMode = this.startViewMode;
476         this.showMode();
477         
478         this.fireEvent('hide', this, this.date);
479         
480     },
481     
482     onMousedown: function(e)
483     {
484         e.stopPropagation();
485         e.preventDefault();
486     },
487     
488     keyup: function(e)
489     {
490         Roo.bootstrap.DateField.superclass.keyup.call(this);
491         this.update();
492     },
493
494     getValue: function()
495     {
496         return this.formatDate(this.date);
497     },
498     
499     fireKey: function(e)
500     {
501         if (!this.picker().isVisible()){
502             if (e.keyCode == 27) // allow escape to hide and re-show picker
503                 this.show();
504             return;
505         }
506         
507         var dateChanged = false,
508         dir, day, month,
509         newDate, newViewDate;
510         
511         switch(e.keyCode){
512             case 27: // escape
513                 this.hide();
514                 e.preventDefault();
515                 break;
516             case 37: // left
517             case 39: // right
518                 if (!this.keyboardNavigation) break;
519                 dir = e.keyCode == 37 ? -1 : 1;
520                 
521                 if (e.ctrlKey){
522                     newDate = this.moveYear(this.date, dir);
523                     newViewDate = this.moveYear(this.viewDate, dir);
524                 } else if (e.shiftKey){
525                     newDate = this.moveMonth(this.date, dir);
526                     newViewDate = this.moveMonth(this.viewDate, dir);
527                 } else {
528                     newDate = new Date(this.date);
529                     newDate.setUTCDate(this.date.getUTCDate() + dir);
530                     newViewDate = new Date(this.viewDate);
531                     newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
532                 }
533                 if (this.dateWithinRange(newDate)){
534                     this.date = newDate;
535                     this.viewDate = newViewDate;
536                     this.setValue(this.formatDate(this.date));
537 //                    this.update();
538                     e.preventDefault();
539                     dateChanged = true;
540                 }
541                 break;
542             case 38: // up
543             case 40: // down
544                 if (!this.keyboardNavigation) break;
545                 dir = e.keyCode == 38 ? -1 : 1;
546                 if (e.ctrlKey){
547                     newDate = this.moveYear(this.date, dir);
548                     newViewDate = this.moveYear(this.viewDate, dir);
549                 } else if (e.shiftKey){
550                     newDate = this.moveMonth(this.date, dir);
551                     newViewDate = this.moveMonth(this.viewDate, dir);
552                 } else {
553                     newDate = new Date(this.date);
554                     newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
555                     newViewDate = new Date(this.viewDate);
556                     newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
557                 }
558                 if (this.dateWithinRange(newDate)){
559                     this.date = newDate;
560                     this.viewDate = newViewDate;
561                     this.setValue(this.formatDate(this.date));
562 //                    this.update();
563                     e.preventDefault();
564                     dateChanged = true;
565                 }
566                 break;
567             case 13: // enter
568                 this.setValue(this.formatDate(this.date));
569                 this.hide();
570                 e.preventDefault();
571                 break;
572             case 9: // tab
573                 this.setValue(this.formatDate(this.date));
574                 this.hide();
575                 break;
576             case 16: // shift
577             case 17: // ctrl
578             case 18: // alt
579                 break;
580             default :
581                 this.hide();
582                 
583         }
584     },
585     
586     setStartDate: function(startDate)
587     {
588         this.startDate = startDate || -Infinity;
589         if (this.startDate !== -Infinity) {
590             this.startDate = this.parseDate(this.startDate);
591         }
592         this.update();
593         this.updateNavArrows();
594     },
595
596     setEndDate: function(endDate)
597     {
598         this.endDate = endDate || Infinity;
599         if (this.endDate !== Infinity) {
600             this.endDate = this.parseDate(this.endDate);
601         }
602         this.update();
603         this.updateNavArrows();
604     },
605     
606     setDaysOfWeekDisabled: function(daysOfWeekDisabled)
607     {
608         this.daysOfWeekDisabled = daysOfWeekDisabled || [];
609         if (typeof(this.daysOfWeekDisabled) !== 'object') {
610             this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
611         }
612         this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
613             return parseInt(d, 10);
614         });
615         this.update();
616         this.updateNavArrows();
617     },
618     
619     updateNavArrows: function() 
620     {
621         if(this.singleMode){
622             return;
623         }
624         
625         var d = new Date(this.viewDate),
626         year = d.getUTCFullYear(),
627         month = d.getUTCMonth();
628         
629         Roo.each(this.picker().select('.prev', true).elements, function(v){
630             v.show();
631             switch (this.viewMode) {
632                 case 0:
633
634                     if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
635                         v.hide();
636                     }
637                     break;
638                 case 1:
639                 case 2:
640                     if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
641                         v.hide();
642                     }
643                     break;
644             }
645         });
646         
647         Roo.each(this.picker().select('.next', true).elements, function(v){
648             v.show();
649             switch (this.viewMode) {
650                 case 0:
651
652                     if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
653                         v.hide();
654                     }
655                     break;
656                 case 1:
657                 case 2:
658                     if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
659                         v.hide();
660                     }
661                     break;
662             }
663         })
664     },
665     
666     moveMonth: function(date, dir)
667     {
668         if (!dir) return date;
669         var new_date = new Date(date.valueOf()),
670         day = new_date.getUTCDate(),
671         month = new_date.getUTCMonth(),
672         mag = Math.abs(dir),
673         new_month, test;
674         dir = dir > 0 ? 1 : -1;
675         if (mag == 1){
676             test = dir == -1
677             // If going back one month, make sure month is not current month
678             // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
679             ? function(){
680                 return new_date.getUTCMonth() == month;
681             }
682             // If going forward one month, make sure month is as expected
683             // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
684             : function(){
685                 return new_date.getUTCMonth() != new_month;
686             };
687             new_month = month + dir;
688             new_date.setUTCMonth(new_month);
689             // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
690             if (new_month < 0 || new_month > 11)
691                 new_month = (new_month + 12) % 12;
692         } else {
693             // For magnitudes >1, move one month at a time...
694             for (var i=0; i<mag; i++)
695                 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
696                 new_date = this.moveMonth(new_date, dir);
697             // ...then reset the day, keeping it in the new month
698             new_month = new_date.getUTCMonth();
699             new_date.setUTCDate(day);
700             test = function(){
701                 return new_month != new_date.getUTCMonth();
702             };
703         }
704         // Common date-resetting loop -- if date is beyond end of month, make it
705         // end of month
706         while (test()){
707             new_date.setUTCDate(--day);
708             new_date.setUTCMonth(new_month);
709         }
710         return new_date;
711     },
712
713     moveYear: function(date, dir)
714     {
715         return this.moveMonth(date, dir*12);
716     },
717
718     dateWithinRange: function(date)
719     {
720         return date >= this.startDate && date <= this.endDate;
721     },
722
723     
724     remove: function() 
725     {
726         this.picker().remove();
727     }
728    
729 });
730
731 Roo.apply(Roo.bootstrap.DateField,  {
732     
733     head : {
734         tag: 'thead',
735         cn: [
736         {
737             tag: 'tr',
738             cn: [
739             {
740                 tag: 'th',
741                 cls: 'prev',
742                 html: '<i class="fa fa-arrow-left"/>'
743             },
744             {
745                 tag: 'th',
746                 cls: 'switch',
747                 colspan: '5'
748             },
749             {
750                 tag: 'th',
751                 cls: 'next',
752                 html: '<i class="fa fa-arrow-right"/>'
753             }
754
755             ]
756         }
757         ]
758     },
759     
760     content : {
761         tag: 'tbody',
762         cn: [
763         {
764             tag: 'tr',
765             cn: [
766             {
767                 tag: 'td',
768                 colspan: '7'
769             }
770             ]
771         }
772         ]
773     },
774     
775     footer : {
776         tag: 'tfoot',
777         cn: [
778         {
779             tag: 'tr',
780             cn: [
781             {
782                 tag: 'th',
783                 colspan: '7',
784                 cls: 'today'
785             }
786                     
787             ]
788         }
789         ]
790     },
791     
792     dates:{
793         en: {
794             days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
795             daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
796             daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
797             months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
798             monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
799             today: "Today"
800         }
801     },
802     
803     modes: [
804     {
805         clsName: 'days',
806         navFnc: 'Month',
807         navStep: 1
808     },
809     {
810         clsName: 'months',
811         navFnc: 'FullYear',
812         navStep: 1
813     },
814     {
815         clsName: 'years',
816         navFnc: 'FullYear',
817         navStep: 10
818     }]
819 });
820
821 Roo.apply(Roo.bootstrap.DateField,  {
822   
823     template : {
824         tag: 'div',
825         cls: 'datepicker dropdown-menu roo-dynamic',
826         cn: [
827         {
828             tag: 'div',
829             cls: 'datepicker-days',
830             cn: [
831             {
832                 tag: 'table',
833                 cls: 'table-condensed',
834                 cn:[
835                 Roo.bootstrap.DateField.head,
836                 {
837                     tag: 'tbody'
838                 },
839                 Roo.bootstrap.DateField.footer
840                 ]
841             }
842             ]
843         },
844         {
845             tag: 'div',
846             cls: 'datepicker-months',
847             cn: [
848             {
849                 tag: 'table',
850                 cls: 'table-condensed',
851                 cn:[
852                 Roo.bootstrap.DateField.head,
853                 Roo.bootstrap.DateField.content,
854                 Roo.bootstrap.DateField.footer
855                 ]
856             }
857             ]
858         },
859         {
860             tag: 'div',
861             cls: 'datepicker-years',
862             cn: [
863             {
864                 tag: 'table',
865                 cls: 'table-condensed',
866                 cn:[
867                 Roo.bootstrap.DateField.head,
868                 Roo.bootstrap.DateField.content,
869                 Roo.bootstrap.DateField.footer
870                 ]
871             }
872             ]
873         }
874         ]
875     }
876 });
877
878  
879
880  
881