-<html>\r
-<head>\r
- <title>The source code</title>\r
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body onload="prettyPrint();">\r
- <pre class="prettyprint lang-js"><div id="cls-Ext.DatePicker"></div>/**\r
+<html>
+<head>
+ <title>The source code</title>
+ <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+</head>
+<body onload="prettyPrint();">
+ <pre class="prettyprint lang-js">/*!
+ * Ext JS Library 3.0.3
+ * Copyright(c) 2006-2009 Ext JS, LLC
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+<div id="cls-Ext.DatePicker"></div>/**\r
* @class Ext.DatePicker\r
* @extends Ext.Component\r
* Simple date picker class.\r
Ext.DatePicker.superclass.initComponent.call(this);\r
\r
this.value = this.value ?\r
- this.value.clearTime() : new Date().clearTime();\r
+ this.value.clearTime(true) : new Date().clearTime();\r
\r
this.addEvents(\r
<div id="event-Ext.DatePicker-select"></div>/**\r
* @param {Date} value The date to set\r
*/\r
setValue : function(value){\r
- var old = this.value;\r
this.value = value.clearTime(true);\r
- if(this.el){\r
- this.update(this.value);\r
- }\r
+ this.update(this.value);\r
},\r
\r
<div id="method-Ext.DatePicker-getValue"></div>/**\r
\r
// private\r
focus : function(){\r
- if(this.el){\r
- this.update(this.activeDate);\r
- }\r
+ this.update(this.activeDate);\r
},\r
\r
// private\r
\r
// private\r
update : function(date, forceRefresh){\r
- var vd = this.activeDate, vis = this.isVisible();\r
- this.activeDate = date;\r
- if(!forceRefresh && vd && this.el){\r
- var t = date.getTime();\r
- if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){\r
- this.cells.removeClass('x-date-selected');\r
- this.cells.each(function(c){\r
- if(c.dom.firstChild.dateValue == t){\r
- c.addClass('x-date-selected');\r
- if(vis){\r
- Ext.fly(c.dom.firstChild).focus(50);\r
- }\r
- return false;\r
- }\r
- });\r
- return;\r
- }\r
- }\r
- var days = date.getDaysInMonth();\r
- var firstOfMonth = date.getFirstDateOfMonth();\r
- var startingPos = firstOfMonth.getDay()-this.startDay;\r
-\r
- if(startingPos <= this.startDay){\r
- startingPos += 7;\r
- }\r
-\r
- var pm = date.add('mo', -1);\r
- var prevStart = pm.getDaysInMonth()-startingPos;\r
-\r
- var cells = this.cells.elements;\r
- var textEls = this.textNodes;\r
- days += startingPos;\r
-\r
- // convert everything to numbers so it's fast\r
- var day = 86400000;\r
- var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();\r
- var today = new Date().clearTime().getTime();\r
- var sel = date.clearTime().getTime();\r
- var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;\r
- var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;\r
- var ddMatch = this.disabledDatesRE;\r
- var ddText = this.disabledDatesText;\r
- var ddays = this.disabledDays ? this.disabledDays.join('') : false;\r
- var ddaysText = this.disabledDaysText;\r
- var format = this.format;\r
-\r
- if(this.showToday){\r
- var td = new Date().clearTime();\r
- var disable = (td < min || td > max ||\r
- (ddMatch && format && ddMatch.test(td.dateFormat(format))) ||\r
- (ddays && ddays.indexOf(td.getDay()) != -1));\r
-\r
- if(!this.disabled){\r
- this.todayBtn.setDisabled(disable);\r
- this.todayKeyListener[disable ? 'disable' : 'enable']();\r
- }\r
- }\r
-\r
- var setCellClass = function(cal, cell){\r
- cell.title = '';\r
- var t = d.getTime();\r
- cell.firstChild.dateValue = t;\r
- if(t == today){\r
- cell.className += ' x-date-today';\r
- cell.title = cal.todayText;\r
- }\r
- if(t == sel){\r
- cell.className += ' x-date-selected';\r
- if(vis){\r
- Ext.fly(cell.firstChild).focus(50);\r
- }\r
- }\r
- // disabling\r
- if(t < min) {\r
- cell.className = ' x-date-disabled';\r
- cell.title = cal.minText;\r
- return;\r
- }\r
- if(t > max) {\r
- cell.className = ' x-date-disabled';\r
- cell.title = cal.maxText;\r
- return;\r
- }\r
- if(ddays){\r
- if(ddays.indexOf(d.getDay()) != -1){\r
- cell.title = ddaysText;\r
- cell.className = ' x-date-disabled';\r
- }\r
- }\r
- if(ddMatch && format){\r
- var fvalue = d.dateFormat(format);\r
- if(ddMatch.test(fvalue)){\r
- cell.title = ddText.replace('%0', fvalue);\r
- cell.className = ' x-date-disabled';\r
- }\r
- }\r
- };\r
-\r
- var i = 0;\r
- for(; i < startingPos; i++) {\r
- textEls[i].innerHTML = (++prevStart);\r
- d.setDate(d.getDate()+1);\r
- cells[i].className = 'x-date-prevday';\r
- setCellClass(this, cells[i]);\r
- }\r
- for(; i < days; i++){\r
- var intDay = i - startingPos + 1;\r
- textEls[i].innerHTML = (intDay);\r
- d.setDate(d.getDate()+1);\r
- cells[i].className = 'x-date-active';\r
- setCellClass(this, cells[i]);\r
- }\r
- var extraDays = 0;\r
- for(; i < 42; i++) {\r
- textEls[i].innerHTML = (++extraDays);\r
- d.setDate(d.getDate()+1);\r
- cells[i].className = 'x-date-nextday';\r
- setCellClass(this, cells[i]);\r
- }\r
-\r
- this.mbtn.setText(this.monthNames[date.getMonth()] + ' ' + date.getFullYear());\r
-\r
- if(!this.internalRender){\r
- var main = this.el.dom.firstChild;\r
- var w = main.offsetWidth;\r
- this.el.setWidth(w + this.el.getBorderWidth('lr'));\r
- Ext.fly(main).setWidth(w);\r
- this.internalRender = true;\r
- // opera does not respect the auto grow header center column\r
- // then, after it gets a width opera refuses to recalculate\r
- // without a second pass\r
- if(Ext.isOpera && !this.secondPass){\r
- main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + 'px';\r
- this.secondPass = true;\r
- this.update.defer(10, this, [date]);\r
- }\r
+ if(this.rendered){\r
+ var vd = this.activeDate, vis = this.isVisible();\r
+ this.activeDate = date;\r
+ if(!forceRefresh && vd && this.el){\r
+ var t = date.getTime();\r
+ if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){\r
+ this.cells.removeClass('x-date-selected');\r
+ this.cells.each(function(c){\r
+ if(c.dom.firstChild.dateValue == t){\r
+ c.addClass('x-date-selected');\r
+ if(vis){\r
+ Ext.fly(c.dom.firstChild).focus(50);\r
+ }\r
+ return false;\r
+ }\r
+ });\r
+ return;\r
+ }\r
+ }\r
+ var days = date.getDaysInMonth(),\r
+ firstOfMonth = date.getFirstDateOfMonth(),\r
+ startingPos = firstOfMonth.getDay()-this.startDay;\r
+ \r
+ if(startingPos < 0){\r
+ startingPos += 7;\r
+ }\r
+ days += startingPos;\r
+ \r
+ var pm = date.add('mo', -1),\r
+ prevStart = pm.getDaysInMonth()-startingPos,\r
+ cells = this.cells.elements,\r
+ textEls = this.textNodes,\r
+ // convert everything to numbers so it's fast\r
+ day = 86400000,\r
+ d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime(),\r
+ today = new Date().clearTime().getTime(),\r
+ sel = date.clearTime(true).getTime(),\r
+ min = this.minDate ? this.minDate.clearTime(true) : Number.NEGATIVE_INFINITY,\r
+ max = this.maxDate ? this.maxDate.clearTime(true) : Number.POSITIVE_INFINITY,\r
+ ddMatch = this.disabledDatesRE,\r
+ ddText = this.disabledDatesText,\r
+ ddays = this.disabledDays ? this.disabledDays.join('') : false,\r
+ ddaysText = this.disabledDaysText,\r
+ format = this.format;\r
+ \r
+ if(this.showToday){\r
+ var td = new Date().clearTime(),\r
+ disable = (td < min || td > max ||\r
+ (ddMatch && format && ddMatch.test(td.dateFormat(format))) ||\r
+ (ddays && ddays.indexOf(td.getDay()) != -1));\r
+ \r
+ if(!this.disabled){\r
+ this.todayBtn.setDisabled(disable);\r
+ this.todayKeyListener[disable ? 'disable' : 'enable']();\r
+ }\r
+ }\r
+ \r
+ var setCellClass = function(cal, cell){\r
+ cell.title = '';\r
+ var t = d.getTime();\r
+ cell.firstChild.dateValue = t;\r
+ if(t == today){\r
+ cell.className += ' x-date-today';\r
+ cell.title = cal.todayText;\r
+ }\r
+ if(t == sel){\r
+ cell.className += ' x-date-selected';\r
+ if(vis){\r
+ Ext.fly(cell.firstChild).focus(50);\r
+ }\r
+ }\r
+ // disabling\r
+ if(t < min) {\r
+ cell.className = ' x-date-disabled';\r
+ cell.title = cal.minText;\r
+ return;\r
+ }\r
+ if(t > max) {\r
+ cell.className = ' x-date-disabled';\r
+ cell.title = cal.maxText;\r
+ return;\r
+ }\r
+ if(ddays){\r
+ if(ddays.indexOf(d.getDay()) != -1){\r
+ cell.title = ddaysText;\r
+ cell.className = ' x-date-disabled';\r
+ }\r
+ }\r
+ if(ddMatch && format){\r
+ var fvalue = d.dateFormat(format);\r
+ if(ddMatch.test(fvalue)){\r
+ cell.title = ddText.replace('%0', fvalue);\r
+ cell.className = ' x-date-disabled';\r
+ }\r
+ }\r
+ };\r
+ \r
+ var i = 0;\r
+ for(; i < startingPos; i++) {\r
+ textEls[i].innerHTML = (++prevStart);\r
+ d.setDate(d.getDate()+1);\r
+ cells[i].className = 'x-date-prevday';\r
+ setCellClass(this, cells[i]);\r
+ }\r
+ for(; i < days; i++){\r
+ var intDay = i - startingPos + 1;\r
+ textEls[i].innerHTML = (intDay);\r
+ d.setDate(d.getDate()+1);\r
+ cells[i].className = 'x-date-active';\r
+ setCellClass(this, cells[i]);\r
+ }\r
+ var extraDays = 0;\r
+ for(; i < 42; i++) {\r
+ textEls[i].innerHTML = (++extraDays);\r
+ d.setDate(d.getDate()+1);\r
+ cells[i].className = 'x-date-nextday';\r
+ setCellClass(this, cells[i]);\r
+ }\r
+ \r
+ this.mbtn.setText(this.monthNames[date.getMonth()] + ' ' + date.getFullYear());\r
+ \r
+ if(!this.internalRender){\r
+ var main = this.el.dom.firstChild,\r
+ w = main.offsetWidth;\r
+ this.el.setWidth(w + this.el.getBorderWidth('lr'));\r
+ Ext.fly(main).setWidth(w);\r
+ this.internalRender = true;\r
+ // opera does not respect the auto grow header center column\r
+ // then, after it gets a width opera refuses to recalculate\r
+ // without a second pass\r
+ if(Ext.isOpera && !this.secondPass){\r
+ main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + 'px';\r
+ this.secondPass = true;\r
+ this.update.defer(10, this, [date]);\r
+ }\r
+ }\r
}\r
},\r
\r
});\r
\r
Ext.reg('datepicker', Ext.DatePicker);\r
-</pre> \r
-</body>\r
+</pre>
+</body>
</html>
\ No newline at end of file