Calendar: Remove selected property from $.date

This commit is contained in:
Felix Nagel 2015-01-24 02:23:24 +01:00
parent bbe1eff498
commit ec0d679e64
2 changed files with 9 additions and 13 deletions

9
external/date.js vendored
View File

@ -32,7 +32,6 @@ $.date = function( date, globalFormat ) {
this.dateObject = this.dateObject || new Date();
this.globalFormat = globalFormat;
this.selected = null;
};
$.date.prototype = {
@ -153,7 +152,6 @@ $.date.prototype = {
lead: printDate.getMonth() != date.getMonth(),
date: printDate.getDate(),
timestamp: printDate.getTime(),
current: this.selected && this.selected.equal( printDate ),
today: today.equal( printDate )
};
day.render = day.selectable = !day.lead;
@ -180,13 +178,6 @@ $.date.prototype = {
result[ result.length - 1 ].last = true;
return result;
},
select: function() {
this.selected = this.clone();
return this;
},
selectedDate: function() {
return this.selected.date();
},
clone: function() {
var date = this.dateObject;
return new $.date( new Date( date.getFullYear(), date.getMonth(),

View File

@ -61,8 +61,9 @@ return $.widget( "ui.calendar", {
this.labels = Globalize.translate( "datepicker" );
this.buttonClickContext = this.element[ 0 ];
this.date = $.date( this.options.value, this.options.dateFormat ).select();
this.date = $.date( this.options.value, this.options.dateFormat );
this.date.eachDay = this.options.eachDay;
this.options.value = this.date.date();
this._on( this.element, {
"click .ui-calendar-prev": function( event ) {
@ -332,7 +333,7 @@ return $.widget( "ui.calendar", {
var content = "",
attributes = [
"role='gridcell'",
"aria-selected='" + ( day.current ? true : false ) + "'"
"aria-selected='" + ( this._isCurrent( day ) ? true : false ) + "'"
],
selectable = ( day.selectable && this._isValid( new Date( day.timestamp ) ) );
@ -357,7 +358,7 @@ return $.widget( "ui.calendar", {
if ( day === this.date && selectable ) {
classes.push( "ui-state-focus" );
}
if ( day.current ) {
if ( this._isCurrent( day ) ) {
classes.push( "ui-state-active" );
}
if ( day.today ) {
@ -383,6 +384,10 @@ return $.widget( "ui.calendar", {
return content;
},
_isCurrent: function( day ) {
return day.timestamp === this.options.value.getTime();
},
_createButtonPane: function() {
this.buttonPane = $( "<div>" )
.addClass( "ui-calendar-buttonpane ui-widget-content ui-helper-clearfix" );
@ -558,7 +563,7 @@ return $.widget( "ui.calendar", {
_setOption: function( key, value ) {
if ( key === "value" ) {
if ( this._isValid( value ) ) {
this.date.setTime( value.getTime() ).select();
this.date.setTime( value.getTime() );
this._super( key, value );
}
return;