*/
setValue : function(value){
var old = this.value;
+
+ if (typeof(value) == 'string') {
+
+ value = Date.parseDate(value, this.format);
+ }
+ if (!value) {
+ value = new Date();
+ }
+
this.value = value.clearTime(true);
if(this.el){
this.update(this.value);
}
},
- // private
+ // privateval
onRender : function(container, position){
var m = [
{
value = this.formatDate(value);
if(!Roo.form.DateField.superclass.validateValue.call(this, value)){
+ Roo.log('super failed');
return false;
}
if(value.length < 1){ // if it's blank and textfield didn't flag it then it's valid
var svalue = value;
value = this.parseDate(value);
if(!value){
+ Roo.log('parse date failed' + svalue);
this.markInvalid(String.format(this.invalidText, svalue, this.format));
return false;
}
this.hiddenField.value = this.formatDate(this.parseDate(date), 'Y-m-d');
}
Roo.form.DateField.superclass.setValue.call(this, this.formatDate(this.parseDate(date)));
+ // make sure the value field is always stored as a date..
+ this.value = this.parseDate(date);
+
+
},
// private
return value;
}
var v = Date.parseDate(value, this.format);
+ if (!v && this.useIso) {
+ v = Date.parseDate(value, 'Y-m-d');
+ }
if(!v && this.altFormats){
if(!this.altFormatsArray){
this.altFormatsArray = this.altFormats.split("|");
// private
menuListeners : {
select: function(m, d){
+
this.setValue(d);
this.fireEvent('select', this, d);
},
disabledDatesText : this.disabledDatesText,
disabledDays : this.disabledDays,
disabledDaysText : this.disabledDaysText,
- format : this.format,
+ format : this.useIso ? 'Y-m-d' : this.format,
minText : String.format(this.minText, this.formatDate(this.minValue)),
maxText : String.format(this.maxText, this.formatDate(this.maxValue))
});
* The default date format string which can be overriden for localization support. The format must be
* valid according to {@link Date#parseDate} (defaults to 'm/d/y').
*/
- format : "M-Y",
+ format : "M Y",
/**
* @cfg {String} altFormats
* Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
* format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
*/
- altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
+ altFormats : "M Y|m/Y|m-y|m-Y|my|mY",
/**
* @cfg {Array} disabledDays
* An array of days to disable, 0 based. For example, [0, 6] disables Sunday and Saturday (defaults to null).
*/
minText : "The date in this field must be equal to or after {0}",
/**
- * @cfg {String} maxText
+ * @cfg {String} maxTextf
* The error text to display when the date in the cell is after maxValue (defaults to
* 'The date in this field must be before {maxValue}').
*/
validateValue : function(value)
{
value = this.formatDate(value);
- if(!Roo.form.DateField.superclass.validateValue.call(this, value)){
+ if(!Roo.form.MonthField.superclass.validateValue.call(this, value)){
return false;
}
if(value.length < 1){ // if it's blank and textfield didn't flag it then it's valid
this.markInvalid(String.format(this.maxText, this.formatDate(this.maxValue)));
return false;
}
- if(this.disabledDays){
+ /*if(this.disabledDays){
var day = value.getDay();
for(var i = 0; i < this.disabledDays.length; i++) {
if(day === this.disabledDays[i]){
}
}
}
+ */
var fvalue = this.formatDate(value);
- if(this.ddMatch && this.ddMatch.test(fvalue)){
+ /*if(this.ddMatch && this.ddMatch.test(fvalue)){
this.markInvalid(String.format(this.disabledDatesText, fvalue));
return false;
}
+ */
return true;
},
*/
getValue : function(){
+
+
return this.hiddenField ?
this.hiddenField.value :
- this.parseDate(Roo.form.DateField.superclass.getValue.call(this)) || "";
+ this.parseDate(Roo.form.MonthField.superclass.getValue.call(this)) || "";
},
/**
* Sets the value of the date field. You can pass a date object or any string that can be parsed into a valid
- * date, using monthField.format as the date format, according to the same rules as {@link Date#parseDate}
+ * date, using MonthField.format as the date format, according to the same rules as {@link Date#parseDate}
* (the default format used is "m/d/y").
* <br />Usage:
* <pre><code>
* @param {String/Date} date The date or valid date string
*/
setValue : function(date){
+ Roo.log('month setValue' + date);
+ // can only be first of month..
+
+ var val = this.parseDate(date);
+
if (this.hiddenField) {
this.hiddenField.value = this.formatDate(this.parseDate(date), 'Y-m-d');
}
- Roo.form.DateField.superclass.setValue.call(this, this.formatDate(this.parseDate(date)));
+ Roo.form.MonthField.superclass.setValue.call(this, this.formatDate(this.parseDate(date)));
+ this.value = this.parseDate(date);
},
// private
parseDate : function(value){
if(!value || value instanceof Date){
+ value = value ? Date.parseDate(value.format('Y-m') + '-01', 'Y-m-d') : null;
return value;
}
var v = Date.parseDate(value, this.format);
+ if (!v && this.useIso) {
+ v = Date.parseDate(value, 'Y-m-d');
+ }
+ if (v) {
+ //
+ v = Date.parseDate(v.format('Y-m') +'-01', 'Y-m-d');
+ }
+
+
if(!v && this.altFormats){
if(!this.altFormatsArray){
this.altFormatsArray = this.altFormats.split("|");
}
if(this.menu == null){
this.menu = new Roo.menu.DateMenu();
+
}
Roo.apply(this.menu.picker, {
disabledDatesRE : this.ddMatch,
disabledDatesText : this.disabledDatesText,
- format : this.format,
+ format : this.useIso ? 'Y-m-d' : this.format,
minText : String.format(this.minText, this.formatDate(this.minValue)),
maxText : String.format(this.maxText, this.formatDate(this.maxValue))
});
-
- this.menu.on(Roo.apply({}, this.menuListeners, {
+ this.menu.on(Roo.apply({}, this.menuListeners, {
scope:this
}));
+
var m = this.menu;
var p = m.picker;
- p.setValue(this.getValue() || new Date());
- m.show(this.el, "tl-bl?");
- // hidden the day picker
- Roo.select('.x-date-picker table', true).first().dom.style.visibility = "hidden";
-
- (function() {
- p.showMonthPicker();
- }).defer(100);
+ // hide month picker get's called when we called by 'before hide';
+ var ignorehide = true;
p.hideMonthPicker = function(disableAnim){
- if(this.monthPicker){
+ if (ignorehide) {
+ return;
+ }
+ if(this.monthPicker){
+ Roo.log("hideMonthPicker called");
if(disableAnim === true){
this.monthPicker.hide();
}else{
this.monthPicker.slideOut('t', {duration:.2});
- p.setValue(new Date(m.picker.mpSelYear, m.picker.mpSelMonth));
+ p.setValue(new Date(m.picker.mpSelYear, m.picker.mpSelMonth, 1));
p.fireEvent("select", this, this.value);
m.hide();
}
}
}
+
+ Roo.log('picker set value');
+ Roo.log(this.getValue());
+ p.setValue(this.getValue() ? this.parseDate(this.getValue()) : new Date());
+ m.show(this.el, 'tl-bl?');
+ ignorehide = false;
+ // this will trigger hideMonthPicker..
+
+
+ // hidden the day picker
+ Roo.select('.x-date-picker table', true).first().dom.style.visibility = "hidden";
+
+
+
+
+
+ p.showMonthPicker.defer(100, p);
+
+
+
},
beforeBlur : function(){
this.setValue(this.originalValue);
this.clearInvalid();
this.lastData = false;
+ if (this.view) {
+ this.view.clearSelections();
+ }
},
// private
findRecord : function(prop, value){