@@ -264,7 +264,7 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
set_startDate: function(value) {
|
||||
// The property of the start date for range
|
||||
if(this._startDate != value) {
|
||||
this._startDate = this._parseDateSortableFormat(value);
|
||||
this._startDate = new Date(value);
|
||||
this.raisePropertyChanged('startDate');
|
||||
}
|
||||
},
|
||||
@@ -274,7 +274,7 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
},
|
||||
set_endDate: function(value) {
|
||||
if(this._endDate != value) {
|
||||
this._endDate = this._parseDateSortableFormat(value);
|
||||
this._endDate = new Date(value);
|
||||
this.raisePropertyChanged('endDate');
|
||||
}
|
||||
},
|
||||
@@ -324,7 +324,7 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
},
|
||||
set_selectedDate: function(value) {
|
||||
if(value && (String.isInstanceOfType(value)) && (value.length != 0)) {
|
||||
value = this._parseDateSortableFormat(value);
|
||||
value = Date.fromISO(value);
|
||||
}
|
||||
|
||||
if(this._selectedDate != value) {
|
||||
@@ -332,7 +332,7 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
this._selectedDateChanging = true;
|
||||
var text = "";
|
||||
if(value) {
|
||||
text = value.localeFormat(this._format);
|
||||
text = this._convertToLocal(value).localeFormat(this._format);
|
||||
|
||||
// If we don't clear the time then we transfer the time from the
|
||||
// textbox to the selected value
|
||||
@@ -344,12 +344,12 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
if(tbvalue) {
|
||||
if(value != tbvalue.getDateOnly()) {
|
||||
// Transfer time from textbox to selected value
|
||||
value.setHours(tbvalue.getHours());
|
||||
value.setMinutes(tbvalue.getMinutes());
|
||||
value.setSeconds(tbvalue.getSeconds());
|
||||
value.setMilliseconds(tbvalue.getMilliseconds());
|
||||
value.setUTCHours(tbvalue.getUTCHours());
|
||||
value.setUTCMinutes(tbvalue.getUTCMinutes());
|
||||
value.setUTCSeconds(tbvalue.getUTCSeconds());
|
||||
value.setUTCMilliseconds(tbvalue.getUTCMilliseconds());
|
||||
|
||||
text = value.localeFormat(this._format);
|
||||
text = this._convertToLocal(value).localeFormat(this._format);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -385,7 +385,7 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
}
|
||||
|
||||
if(this._visibleDate != value) {
|
||||
this._switchView(value, Sys.Extended.UI.CalendarSwitchViewMode.RangeZoom, !this._isOpen);
|
||||
this._switchMonth(value, !this._isOpen);
|
||||
this.raisePropertyChanged("visibleDate");
|
||||
}
|
||||
},
|
||||
@@ -683,7 +683,7 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
this._popupBehavior.show();
|
||||
|
||||
if(this._firstPopUp) {
|
||||
this._switchView(null, Sys.Extended.UI.CalendarSwitchViewMode.RangeZoom, true);
|
||||
this._switchMonth(null, true);
|
||||
switch(this._defaultView) {
|
||||
case Sys.Extended.UI.CalendarDefaultView.Months:
|
||||
this._switchMode("months", true);
|
||||
@@ -995,7 +995,7 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
_isInDateRange: function(date, part, switchMode) {
|
||||
_isInDateRange: function(date, part) {
|
||||
switch(part) {
|
||||
case "d":
|
||||
if((this._startDate) && (this._getDateOnly(date) < this._getDateOnly(this._startDate))) { return false; }
|
||||
@@ -1006,73 +1006,111 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
if((this._endDate) && (this._getMonthOnly(date) > this._getMonthOnly(this._endDate))) { return false; }
|
||||
break;
|
||||
case "y":
|
||||
if((this._startDate) && (date.getFullYear() < this._startDate.getFullYear())) { return false; }
|
||||
if((this._endDate) && (date.getFullYear() > this._endDate.getFullYear())) { return false; }
|
||||
if((this._startDate) && (date.getUTCFullYear() < this._startDate.getUTCFullYear())) { return false; }
|
||||
if((this._endDate) && (date.getUTCFullYear() > this._endDate.getUTCFullYear())) { return false; }
|
||||
break;
|
||||
case "yy":
|
||||
if(this._startDate && this._endDate) {
|
||||
return this._isInYearsDateRange(date, switchMode);
|
||||
} else {
|
||||
if(!this._startDate && !this._endDate)
|
||||
return true;
|
||||
var startYear = date.getUTCFullYear();
|
||||
var endYear = date.getUTCFullYear() + 9;
|
||||
|
||||
var startYear = this._getRangeStartYear(date);
|
||||
if(this._endDate && startYear < this._endDate.getFullYear())
|
||||
return true;
|
||||
|
||||
var endYear = this._getRangeEndYear(date);
|
||||
if (this._startDate && endYear > this._startDate.getFullYear())
|
||||
if (this._startDate && this._endDate) {
|
||||
if (startYear < this._startDate.getUTCFullYear()
|
||||
&&
|
||||
endYear > this._endDate.getUTCFullYear())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if(!this._startDate && !this._endDate)
|
||||
return true;
|
||||
|
||||
if (this._startDate && endYear > this._startDate.getUTCFullYear())
|
||||
return true;
|
||||
|
||||
if (this._endDate && startYear < this._endDate.getUTCFullYear())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
_isInNextDateRange: function (date, part) {
|
||||
switch (part) {
|
||||
case "d":
|
||||
if ((this._startDate) && (this._getDateOnly(date) > this._getDateOnly(this._startDate))) { return false; }
|
||||
break;
|
||||
case "M":
|
||||
if ((this._startDate) && (this._getMonthOnly(date) > this._getMonthOnly(this._startDate))) { return false; }
|
||||
break;
|
||||
case "y":
|
||||
if ((this._startDate) && (date.getUTCFullYear() > this._startDate.getUTCFullYear())) { return false; }
|
||||
break;
|
||||
case "yy":
|
||||
var startYear = date.getUTCFullYear();
|
||||
var endYear = date.getUTCFullYear();
|
||||
if ((this._startDate) && (date.getUTCFullYear() > this._startDate.getUTCFullYear())) { return false; }
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
_isInPrevDateRange: function (date, part) {
|
||||
switch (part) {
|
||||
case "d":
|
||||
if ((this._endDate) && (this._getDateOnly(date) < this._getDateOnly(this._endDate))) { return false; }
|
||||
break;
|
||||
case "M":
|
||||
if ((this._endDate) && (this._getMonthOnly(date) < this._getMonthOnly(this._endDate))) { return false; }
|
||||
break;
|
||||
case "y":
|
||||
if ((this._endDate) && (date.getUTCFullYear() < this._endDate.getUTCFullYear())) { return false; }
|
||||
break;
|
||||
case "yy":
|
||||
var startYear = date.getUTCFullYear();
|
||||
var endYear = date.getUTCFullYear() + 9;
|
||||
|
||||
if (this._startDate || this._endDate)
|
||||
{
|
||||
if (startYear < this._startDate.getUTCFullYear()
|
||||
&&
|
||||
endYear > this._endDate.getUTCFullYear())
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
_isInYearsDateRange: function(date, switchMode) {
|
||||
var startYear = this._getRangeStartYear(date);
|
||||
var endYear = this._getRangeEndYear(date);
|
||||
|
||||
switch(switchMode) {
|
||||
case Sys.Extended.UI.CalendarSwitchViewMode.PreviousRange:
|
||||
if(endYear > this._startDate.getFullYear())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
case Sys.Extended.UI.CalendarSwitchViewMode.NextRange:
|
||||
if(startYear < this._endDate.getFullYear())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
case Sys.Extended.UI.CalendarSwitchViewMode.RangeZoom:
|
||||
if(startYear > this._startDate.getFullYear()
|
||||
&&
|
||||
endYear < this._endDate.getFullYear())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
default:
|
||||
throw Error.invalidOperation();
|
||||
}
|
||||
},
|
||||
|
||||
_getRangeStartYear: function(date) {
|
||||
return date.getFullYear();
|
||||
},
|
||||
|
||||
_getRangeEndYear: function(date) {
|
||||
return date.getFullYear() + 9;
|
||||
},
|
||||
|
||||
_getDateOnly: function(date) {
|
||||
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
||||
return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()));
|
||||
},
|
||||
|
||||
_getMonthOnly: function(date) {
|
||||
return new Date(date.getFullYear(), date.getMonth(), 1);
|
||||
return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), 1));
|
||||
},
|
||||
|
||||
_convertToUTC: function(value) {
|
||||
// Converts a local date such as 1/1/2007 into 1/1/2007 GMT without adjusting for time zone
|
||||
if(value) {
|
||||
value = new Date(Date.UTC(value.getFullYear(), value.getMonth(), value.getDate(), value.getHours(), value.getMinutes(), value.getSeconds(), value.getMilliseconds()));
|
||||
}
|
||||
return value;
|
||||
},
|
||||
|
||||
_convertToLocal: function(value) {
|
||||
// Converts a UTC date such as 1/1/2007 GMT into 1/1/2007 without adjusting for time zone
|
||||
|
||||
var result = new Date(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate(), value.getUTCHours(), value.getUTCMinutes(), value.getUTCSeconds(), value.getUTCMilliseconds());
|
||||
|
||||
// Handle daylight savings time offset (The first hour of September 25 becomes the last hour of September 24 when DST starts)
|
||||
if(result.getDate() != value.getUTCDate()) {
|
||||
result = new Date(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate(), value.getUTCHours() + 1, value.getUTCMinutes(), value.getUTCSeconds(), value.getUTCMilliseconds());
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
_performLayout: function() {
|
||||
@@ -1091,12 +1129,12 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
case "days":
|
||||
|
||||
var firstDayOfWeek = this._getFirstDayOfWeek();
|
||||
var daysToBacktrack = visibleDate.getDay() - firstDayOfWeek;
|
||||
var daysToBacktrack = visibleDate.getUTCDay() - firstDayOfWeek;
|
||||
if(daysToBacktrack <= 0)
|
||||
daysToBacktrack += 7;
|
||||
|
||||
var startDate = new Date(visibleDate);
|
||||
startDate.setDate(startDate.getDate() - daysToBacktrack);
|
||||
startDate.setUTCDate(startDate.getUTCDate() - daysToBacktrack);
|
||||
var currentDate = new Date(startDate);
|
||||
|
||||
for(var i = 0; i < 7; i++) {
|
||||
@@ -1113,8 +1151,8 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
if(dayCell.firstChild) {
|
||||
dayCell.removeChild(dayCell.firstChild);
|
||||
}
|
||||
dayCell.appendChild(document.createTextNode(currentDate.getDate()));
|
||||
dayCell.title = currentDate.localeFormat("D");
|
||||
dayCell.appendChild(document.createTextNode(currentDate.getUTCDate()));
|
||||
dayCell.title = this._convertToLocal(currentDate).localeFormat("D");
|
||||
dayCell.date = currentDate;
|
||||
$common.removeCssClasses(dayCell.parentNode, ["ajax__calendar_other", "ajax__calendar_active", "ajax__calendar_today"]);
|
||||
|
||||
@@ -1127,17 +1165,17 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
}
|
||||
|
||||
currentDate = new Date(currentDate);
|
||||
currentDate.setDate(currentDate.getDate() + 1);
|
||||
currentDate.setUTCDate(currentDate.getUTCDate() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
this._prevArrow.date = new Date(visibleDate.getFullYear(), visibleDate.getMonth() - 1, 1);
|
||||
this._nextArrow.date = new Date(visibleDate.getFullYear(), visibleDate.getMonth() + 1, 1);
|
||||
this._prevArrow.date = new Date(Date.UTC(visibleDate.getUTCFullYear(), visibleDate.getUTCMonth() - 1, 1));
|
||||
this._nextArrow.date = new Date(Date.UTC(visibleDate.getUTCFullYear(), visibleDate.getUTCMonth() + 1, 1));
|
||||
if(this._title.firstChild) {
|
||||
this._title.removeChild(this._title.firstChild);
|
||||
}
|
||||
|
||||
this._title.appendChild(document.createTextNode(visibleDate.localeFormat(this.get_daysModeTitleFormat())));
|
||||
this._title.appendChild(document.createTextNode(this._convertToLocal(visibleDate).localeFormat(this.get_daysModeTitleFormat())));
|
||||
this._title.date = visibleDate;
|
||||
|
||||
break;
|
||||
@@ -1146,8 +1184,8 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
var row = this._monthsBody.rows[i];
|
||||
for(var j = 0; j < row.cells.length; j++) {
|
||||
var cell = row.cells[j].firstChild;
|
||||
cell.date = new Date(visibleDate.getFullYear(), cell.month, 1);
|
||||
cell.title = cell.date.localeFormat("Y");
|
||||
cell.date = new Date(Date.UTC(visibleDate.getUTCFullYear(), cell.month, 1));
|
||||
cell.title = this._convertToLocal(cell.date).localeFormat("Y");
|
||||
|
||||
if(!this._isInDateRange(cell.date, "M")) {
|
||||
$common.removeCssClasses(cell.parentNode, ["ajax__calendar_other", "ajax__calendar_active"]);
|
||||
@@ -1165,20 +1203,20 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
this._title.removeChild(this._title.firstChild);
|
||||
}
|
||||
|
||||
this._title.appendChild(document.createTextNode(visibleDate.localeFormat("yyyy")));
|
||||
this._title.appendChild(document.createTextNode(this._convertToLocal(visibleDate).localeFormat("yyyy")));
|
||||
this._title.date = visibleDate;
|
||||
this._prevArrow.date = new Date(visibleDate.getFullYear() - 1, 0, 1);
|
||||
this._nextArrow.date = new Date(visibleDate.getFullYear() + 1, 0, 1);
|
||||
this._prevArrow.date = new Date(Date.UTC(visibleDate.getUTCFullYear() - 1, 0, 1));
|
||||
this._nextArrow.date = new Date(Date.UTC(visibleDate.getUTCFullYear() + 1, 0, 1));
|
||||
|
||||
break;
|
||||
case "years":
|
||||
|
||||
var minYear = (Math.floor(visibleDate.getFullYear() / 10) * 10);
|
||||
var minYear = (Math.floor(visibleDate.getUTCFullYear() / 10) * 10);
|
||||
for(var i = 0; i < this._yearsBody.rows.length; i++) {
|
||||
var row = this._yearsBody.rows[i];
|
||||
for(var j = 0; j < row.cells.length; j++) {
|
||||
var cell = row.cells[j].firstChild;
|
||||
cell.date = new Date(minYear + cell.year, 0, 1);
|
||||
cell.date = new Date(Date.UTC(minYear + cell.year, 0, 1));
|
||||
if(cell.firstChild) {
|
||||
cell.removeChild(cell.lastChild);
|
||||
} else {
|
||||
@@ -1203,8 +1241,8 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
|
||||
this._title.appendChild(document.createTextNode(minYear.toString() + "-" + (minYear + 9).toString()));
|
||||
this._title.date = visibleDate;
|
||||
this._prevArrow.date = new Date(minYear - 10, 0, 1);
|
||||
this._nextArrow.date = new Date(minYear + 10, 0, 1);
|
||||
this._prevArrow.date = new Date(Date.UTC(minYear - 10, 0, 1));
|
||||
this._nextArrow.date = new Date(Date.UTC(minYear + 10, 0, 1));
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -1218,7 +1256,7 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
Sys.UI.DomElement.addCssClass(this._today.parentNode, "ajax__calendar_invalid");
|
||||
}
|
||||
|
||||
this._today.date = todaysDate;
|
||||
this._today.date = this._convertToUTC(todaysDate);
|
||||
},
|
||||
|
||||
_ensureCalendar: function() {
|
||||
@@ -1261,7 +1299,7 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
elt.dispatchEvent(e);
|
||||
}
|
||||
},
|
||||
_switchView: function(date, switchMode, dontAnimate) {
|
||||
_switchMonth: function(date, dontAnimate) {
|
||||
// Switches the visible month in the days view
|
||||
// param name "date" of type "Date" is the visible date to switch to
|
||||
// param name "dontAnimate" of type "Boolean" prevents animation from occuring if the control is animated
|
||||
@@ -1272,7 +1310,7 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
}
|
||||
|
||||
// Check if can switch month depending on the startDate and endDAte
|
||||
if(date && !this._canSwitchMonth(date, switchMode)) {
|
||||
if(date && !this._canSwitchMonth(date)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1282,96 +1320,219 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
}
|
||||
|
||||
if(this._animated && !dontAnimate) {
|
||||
this._animateViewSwitch(date, visibleDate);
|
||||
this._isAnimating = true;
|
||||
|
||||
var newElement = this._modes[this._mode];
|
||||
var oldElement = newElement.cloneNode(true);
|
||||
this._body.appendChild(oldElement);
|
||||
if(visibleDate > date) {
|
||||
|
||||
// animating down
|
||||
// the newIndex element is the top
|
||||
// the oldIndex element is the bottom (visible)
|
||||
|
||||
// move in, fade in
|
||||
$common.setLocation(newElement, { x: -162, y: 0 });
|
||||
$common.setVisible(newElement, true);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_propertyKey("left");
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_target(newElement);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_startValue(-this._width);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_endValue(0);
|
||||
|
||||
// move out, fade out
|
||||
$common.setLocation(oldElement, { x: 0, y: 0 });
|
||||
$common.setVisible(oldElement, true);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_propertyKey("left");
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_target(oldElement);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_startValue(0);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_endValue(this._width);
|
||||
|
||||
} else {
|
||||
// animating up
|
||||
// the oldIndex element is the top (visible)
|
||||
// the newIndex element is the bottom
|
||||
|
||||
// move out, fade out
|
||||
$common.setLocation(oldElement, { x: 0, y: 0 });
|
||||
$common.setVisible(oldElement, true);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_propertyKey("left");
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_target(oldElement);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_endValue(-this._width);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_startValue(0);
|
||||
|
||||
// move in, fade in
|
||||
$common.setLocation(newElement, { x: 162, y: 0 });
|
||||
$common.setVisible(newElement, true);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_propertyKey("left");
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_target(newElement);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_endValue(0);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_startValue(this._width);
|
||||
}
|
||||
this._visibleDate = date;
|
||||
this.invalidate();
|
||||
|
||||
var endHandler = Function.createDelegate(this, function() {
|
||||
this._body.removeChild(oldElement);
|
||||
oldElement = null;
|
||||
this._isAnimating = false;
|
||||
this._modeChangeAnimation.remove_ended(endHandler);
|
||||
});
|
||||
this._modeChangeAnimation.add_ended(endHandler);
|
||||
this._modeChangeAnimation.play();
|
||||
} else {
|
||||
this._visibleDate = date;
|
||||
this.invalidate();
|
||||
}
|
||||
},
|
||||
_switchNextRange: function(date, dontAnimate) {
|
||||
// Switches the visible month in the days view
|
||||
// param name "date" of type "Date" is the visible date to switch to
|
||||
// param name "dontAnimate" of type "Boolean" prevents animation from occuring if the control is animated
|
||||
|
||||
_animateViewSwitch: function(date, visibleDate) {
|
||||
this._isAnimating = true;
|
||||
|
||||
var newElement = this._modes[this._mode];
|
||||
var oldElement = newElement.cloneNode(true);
|
||||
this._body.appendChild(oldElement);
|
||||
if(visibleDate > date) {
|
||||
|
||||
// animating down
|
||||
// the newIndex element is the top
|
||||
// the oldIndex element is the bottom (visible)
|
||||
|
||||
// move in, fade in
|
||||
$common.setLocation(newElement, { x: -162, y: 0 });
|
||||
$common.setVisible(newElement, true);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_propertyKey("left");
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_target(newElement);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_startValue(-this._width);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_endValue(0);
|
||||
|
||||
// move out, fade out
|
||||
$common.setLocation(oldElement, { x: 0, y: 0 });
|
||||
$common.setVisible(oldElement, true);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_propertyKey("left");
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_target(oldElement);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_startValue(0);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_endValue(this._width);
|
||||
|
||||
} else {
|
||||
// animating up
|
||||
// the oldIndex element is the top (visible)
|
||||
// the newIndex element is the bottom
|
||||
|
||||
// move out, fade out
|
||||
$common.setLocation(oldElement, { x: 0, y: 0 });
|
||||
$common.setVisible(oldElement, true);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_propertyKey("left");
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_target(oldElement);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_endValue(-this._width);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_startValue(0);
|
||||
|
||||
// move in, fade in
|
||||
$common.setLocation(newElement, { x: 162, y: 0 });
|
||||
$common.setVisible(newElement, true);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_propertyKey("left");
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_target(newElement);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_endValue(0);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_startValue(this._width);
|
||||
// Check _isAnimating to make sure we don't animate horizontally and vertically at the same time
|
||||
if(this._isAnimating) {
|
||||
return;
|
||||
}
|
||||
this._visibleDate = date;
|
||||
this.invalidate();
|
||||
|
||||
var endHandler = Function.createDelegate(this, function() {
|
||||
this._body.removeChild(oldElement);
|
||||
oldElement = null;
|
||||
this._isAnimating = false;
|
||||
this._modeChangeAnimation.remove_ended(endHandler);
|
||||
});
|
||||
this._modeChangeAnimation.add_ended(endHandler);
|
||||
this._modeChangeAnimation.play();
|
||||
// Check if can switch month depending on the startDate and endDAte
|
||||
if(date && !this._canSwitchNextRange(date)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._switchRange(date, dontAnimate);
|
||||
},
|
||||
_switchPrevRange: function (date, dontAnimate) {
|
||||
// Switches the visible month in the days view
|
||||
// param name "date" of type "Date" is the visible date to switch to
|
||||
// param name "dontAnimate" of type "Boolean" prevents animation from occuring if the control is animated
|
||||
|
||||
_canSwitchMonth: function(date, switchMode) {
|
||||
// Check _isAnimating to make sure we don't animate horizontally and vertically at the same time
|
||||
if (this._isAnimating) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if can switch month depending on the startDate and endDAte
|
||||
if (date && !this._canSwitchPrevRange(date)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._switchRange(date, dontAnimate);
|
||||
},
|
||||
_switchRange: function (date, dontAnimate)
|
||||
{
|
||||
var visibleDate = this._getEffectiveVisibleDate();
|
||||
if((date && date.getFullYear() == visibleDate.getFullYear() && date.getMonth() == visibleDate.getMonth())) {
|
||||
dontAnimate = true;
|
||||
}
|
||||
|
||||
if(this._animated && !dontAnimate) {
|
||||
this._isAnimating = true;
|
||||
|
||||
var newElement = this._modes[this._mode];
|
||||
var oldElement = newElement.cloneNode(true);
|
||||
this._body.appendChild(oldElement);
|
||||
if(visibleDate > date) {
|
||||
|
||||
// animating down
|
||||
// the newIndex element is the top
|
||||
// the oldIndex element is the bottom (visible)
|
||||
|
||||
// move in, fade in
|
||||
$common.setLocation(newElement, { x: -162, y: 0 });
|
||||
$common.setVisible(newElement, true);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_propertyKey("left");
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_target(newElement);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_startValue(-this._width);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_endValue(0);
|
||||
|
||||
// move out, fade out
|
||||
$common.setLocation(oldElement, { x: 0, y: 0 });
|
||||
$common.setVisible(oldElement, true);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_propertyKey("left");
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_target(oldElement);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_startValue(0);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_endValue(this._width);
|
||||
|
||||
} else {
|
||||
// animating up
|
||||
// the oldIndex element is the top (visible)
|
||||
// the newIndex element is the bottom
|
||||
|
||||
// move out, fade out
|
||||
$common.setLocation(oldElement, { x: 0, y: 0 });
|
||||
$common.setVisible(oldElement, true);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_propertyKey("left");
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_target(oldElement);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_endValue(-this._width);
|
||||
this._modeChangeMoveTopOrLeftAnimation.set_startValue(0);
|
||||
|
||||
// move in, fade in
|
||||
$common.setLocation(newElement, { x: 162, y: 0 });
|
||||
$common.setVisible(newElement, true);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_propertyKey("left");
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_target(newElement);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_endValue(0);
|
||||
this._modeChangeMoveBottomOrRightAnimation.set_startValue(this._width);
|
||||
}
|
||||
this._visibleDate = date;
|
||||
this.invalidate();
|
||||
|
||||
var endHandler = Function.createDelegate(this, function() {
|
||||
this._body.removeChild(oldElement);
|
||||
oldElement = null;
|
||||
this._isAnimating = false;
|
||||
this._modeChangeAnimation.remove_ended(endHandler);
|
||||
});
|
||||
this._modeChangeAnimation.add_ended(endHandler);
|
||||
this._modeChangeAnimation.play();
|
||||
} else {
|
||||
this._visibleDate = date;
|
||||
this.invalidate();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
_canSwitchMonth: function(date) {
|
||||
switch(this._mode) {
|
||||
case "days":
|
||||
if(!this._isInDateRange(date, "M", switchMode)) {
|
||||
if(!this._isInDateRange(date, "M")) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "months":
|
||||
if(!this._isInDateRange(date, "y", switchMode)) {
|
||||
if(!this._isInDateRange(date, "y")) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "years":
|
||||
if(!this._isInDateRange(date, "yy", switchMode)) {
|
||||
if(!this._isInDateRange(date, "yy")) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
},
|
||||
_canSwitchNextRange: function (date) {
|
||||
switch (this._mode) {
|
||||
case "days":
|
||||
return this._isInNextDateRange(date, "M");
|
||||
case "months":
|
||||
return this._isInNextDateRange(date, "y");
|
||||
case "years":
|
||||
return this._isInNextDateRange(date, "yy");
|
||||
}
|
||||
},
|
||||
_canSwitchPrevRange: function (date) {
|
||||
switch (this._mode) {
|
||||
case "days":
|
||||
return this._isInPrevDateRange(date, "M");
|
||||
case "months":
|
||||
return this._isInPrevDateRange(date, "y");
|
||||
case "years":
|
||||
return this._isInPrevDateRange(date, "yy");
|
||||
}
|
||||
},
|
||||
|
||||
_switchMode: function(mode, dontAnimate) {
|
||||
// Switches the visible view from "days" to "months" to "years"
|
||||
// param name "mode" of type "String" is the view mode to switch to
|
||||
@@ -1458,13 +1619,13 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
if(!value) return false;
|
||||
switch(part) {
|
||||
case 'd':
|
||||
if(date.getDate() != value.getDate()) return false;
|
||||
if(date.getUTCDate() != value.getUTCDate()) return false;
|
||||
// goto case 'M';
|
||||
case 'M':
|
||||
if(date.getMonth() != value.getMonth()) return false;
|
||||
if(date.getUTCMonth() != value.getUTCMonth()) return false;
|
||||
// goto case 'y';
|
||||
case 'y':
|
||||
if(date.getFullYear() != value.getFullYear()) return false;
|
||||
if(date.getUTCFullYear() != value.getUTCFullYear()) return false;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
@@ -1478,18 +1639,18 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
var value = this._getEffectiveVisibleDate();
|
||||
switch(part) {
|
||||
case 'd':
|
||||
return (date.getFullYear() != value.getFullYear() || date.getMonth() != value.getMonth());
|
||||
return (date.getUTCFullYear() != value.getUTCFullYear() || date.getUTCMonth() != value.getUTCMonth());
|
||||
case 'M':
|
||||
return false;
|
||||
case 'y':
|
||||
var minYear = (Math.floor(value.getFullYear() / 10) * 10);
|
||||
return date.getFullYear() < minYear || (minYear + 10) <= date.getFullYear();
|
||||
var minYear = (Math.floor(value.getUTCFullYear() / 10) * 10);
|
||||
return date.getUTCFullYear() < minYear || (minYear + 10) <= date.getUTCFullYear();
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
_isTodaysDate: function(date) {
|
||||
return this._getDateOnly(this.get_todaysDate()).valueOf() === this._getDateOnly(date).valueOf();
|
||||
return this._getDateOnly(this._convertToUTC(this.get_todaysDate())).valueOf() === this._getDateOnly(date).valueOf();
|
||||
},
|
||||
|
||||
_getCssClass: function(date, part) {
|
||||
@@ -1515,23 +1676,12 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
if(value == null)
|
||||
value = this.get_todaysDate();
|
||||
|
||||
if (this._endDate && value > this._endDate)
|
||||
value = this._endDate;
|
||||
else if (this._startDate && value < this._startDate)
|
||||
value = this._startDate;
|
||||
|
||||
value = new Date(value);
|
||||
value.setDate(1);
|
||||
value.setUTCDate(1);
|
||||
|
||||
return this._getDateOnly(value);
|
||||
},
|
||||
getMonthStartDate: function(date)
|
||||
{
|
||||
var value = new Date(date);
|
||||
value.setDate(1);
|
||||
|
||||
return this._getDateOnly(value);
|
||||
},
|
||||
|
||||
_getFirstDayOfWeek: function() {
|
||||
// Gets the first day of the week
|
||||
@@ -1546,9 +1696,7 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
|
||||
var value = null;
|
||||
if(text) {
|
||||
value = Date.parseLocale(text, this.get_format());
|
||||
if(value && value.getFullYear() < 100)
|
||||
value.setYear(value.getFullYear());
|
||||
value = this._convertToUTC(Date.parseLocale(text, this.get_format()));
|
||||
}
|
||||
if(isNaN(value)) {
|
||||
value = null;
|
||||
@@ -1578,7 +1726,7 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
var value = this._parseTextValue(this._textbox.get_Value());
|
||||
this._selectedDate = value;
|
||||
if(this._isOpen) {
|
||||
this._switchView(this._selectedDate, Sys.Extended.UI.CalendarSwitchViewMode.RangeZoom, this._selectedDate == null);
|
||||
this._switchMonth(this._selectedDate, this._selectedDate == null);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1669,10 +1817,10 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
Sys.UI.DomElement.removeCssClass(target.parentNode, "ajax__calendar_hover");
|
||||
switch(target.mode) {
|
||||
case "prev":
|
||||
this._switchView(target.date, Sys.Extended.UI.CalendarSwitchViewMode.PreviousRange);
|
||||
this._switchMonth(target.date);
|
||||
break;
|
||||
case "next":
|
||||
this._switchView(target.date, Sys.Extended.UI.CalendarSwitchViewMode.NextRange);
|
||||
this._switchMonth(target.date);
|
||||
break;
|
||||
case "title":
|
||||
switch(this._mode) {
|
||||
@@ -1681,7 +1829,7 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
}
|
||||
break;
|
||||
case "month":
|
||||
if(target.month == visibleDate.getMonth()) {
|
||||
if(target.month == visibleDate.getUTCMonth()) {
|
||||
this._switchMode("days");
|
||||
} else {
|
||||
this._visibleDate = target.date;
|
||||
@@ -1698,13 +1846,13 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
break;
|
||||
case "day":
|
||||
this.set_selectedDate(target.date);
|
||||
this._switchView(target.date, Sys.Extended.UI.CalendarSwitchViewMode.RangeZoom);
|
||||
this._switchMonth(target.date);
|
||||
this._blur.post(true);
|
||||
this.raise_dateSelectionChanged();
|
||||
break;
|
||||
case "today":
|
||||
this.set_selectedDate(target.date);
|
||||
this._switchView(target.date, Sys.Extended.UI.CalendarSwitchViewMode.RangeZoom);
|
||||
this._switchMonth(target.date);
|
||||
this._blur.post(true);
|
||||
this.raise_dateSelectionChanged();
|
||||
break;
|
||||
@@ -1753,38 +1901,31 @@ Sys.Extended.UI.CalendarBehavior.prototype = {
|
||||
}
|
||||
// make sure we clean up the flag due to issues with alert/alt-tab/etc
|
||||
this._popupMouseDown = false;
|
||||
},
|
||||
_parseDateSortableFormat: function (dateString) {
|
||||
var dateParts = /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.?(\d{0,7})?/.exec(dateString);
|
||||
|
||||
return new Date(
|
||||
dateParts[1],
|
||||
dateParts[2] - 1,
|
||||
dateParts[3],
|
||||
dateParts[4],
|
||||
dateParts[5],
|
||||
dateParts[6]);
|
||||
}
|
||||
}
|
||||
Sys.Extended.UI.CalendarBehavior.registerClass("Sys.Extended.UI.CalendarBehavior", Sys.Extended.UI.BehaviorBase);
|
||||
|
||||
Sys.Extended.UI.CalendarPosition = {
|
||||
Sys.Extended.UI.CalendarPosition = function() {
|
||||
// Position of the popup relative to the target control
|
||||
throw Error.invalidOperation();
|
||||
}
|
||||
Sys.Extended.UI.CalendarPosition.prototype = {
|
||||
BottomLeft: 0,
|
||||
BottomRight: 1,
|
||||
TopLeft: 2,
|
||||
TopRight: 3,
|
||||
Right: 4,
|
||||
Left: 5
|
||||
};
|
||||
}
|
||||
Sys.Extended.UI.CalendarPosition.registerEnum('Sys.Extended.UI.CalendarPosition');
|
||||
|
||||
Sys.Extended.UI.CalendarDefaultView = {
|
||||
Sys.Extended.UI.CalendarDefaultView = function() {
|
||||
// Choices for default view of the calendar when it first pops up.
|
||||
throw Error.invalidOperation();
|
||||
}
|
||||
Sys.Extended.UI.CalendarDefaultView.prototype = {
|
||||
Days: 0,
|
||||
Months: 1,
|
||||
Years: 2
|
||||
};
|
||||
|
||||
Sys.Extended.UI.CalendarSwitchViewMode = {
|
||||
PreviousRange: 0,
|
||||
NextRange: 1,
|
||||
RangeZoom: 2
|
||||
};
|
||||
}
|
||||
Sys.Extended.UI.CalendarDefaultView.registerEnum('Sys.Extended.UI.CalendarDefaultView');
|
||||
Reference in New Issue
Block a user