|
@ -112,9 +112,13 @@ function validateDirection (direction) { |
|
|
* If animate is a number, the |
|
|
* If animate is a number, the |
|
|
* number is taken as duration |
|
|
* number is taken as duration |
|
|
* Default duration is 500 ms. |
|
|
* Default duration is 500 ms. |
|
|
|
|
|
* @param {Boolean} [byUser=false] |
|
|
* |
|
|
* |
|
|
*/ |
|
|
*/ |
|
|
Range.prototype.setRange = function(start, end, animate) { |
|
|
|
|
|
|
|
|
Range.prototype.setRange = function(start, end, animate, byUser) { |
|
|
|
|
|
if (byUser !== true) { |
|
|
|
|
|
byUser = false; |
|
|
|
|
|
} |
|
|
var _start = start != undefined ? util.convert(start, 'Date').valueOf() : null; |
|
|
var _start = start != undefined ? util.convert(start, 'Date').valueOf() : null; |
|
|
var _end = end != undefined ? util.convert(end, 'Date').valueOf() : null; |
|
|
var _end = end != undefined ? util.convert(end, 'Date').valueOf() : null; |
|
|
this._cancelAnimation(); |
|
|
this._cancelAnimation(); |
|
@ -139,12 +143,12 @@ Range.prototype.setRange = function(start, end, animate) { |
|
|
DateUtil.updateHiddenDates(me.body, me.options.hiddenDates); |
|
|
DateUtil.updateHiddenDates(me.body, me.options.hiddenDates); |
|
|
anyChanged = anyChanged || changed; |
|
|
anyChanged = anyChanged || changed; |
|
|
if (changed) { |
|
|
if (changed) { |
|
|
me.body.emitter.emit('rangechange', {start: new Date(me.start), end: new Date(me.end)}); |
|
|
|
|
|
|
|
|
me.body.emitter.emit('rangechange', {start: new Date(me.start), end: new Date(me.end), byUser:byUser}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (done) { |
|
|
if (done) { |
|
|
if (anyChanged) { |
|
|
if (anyChanged) { |
|
|
me.body.emitter.emit('rangechanged', {start: new Date(me.start), end: new Date(me.end)}); |
|
|
|
|
|
|
|
|
me.body.emitter.emit('rangechanged', {start: new Date(me.start), end: new Date(me.end), byUser:byUser}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
@ -161,7 +165,7 @@ Range.prototype.setRange = function(start, end, animate) { |
|
|
var changed = this._applyRange(_start, _end); |
|
|
var changed = this._applyRange(_start, _end); |
|
|
DateUtil.updateHiddenDates(this.body, this.options.hiddenDates); |
|
|
DateUtil.updateHiddenDates(this.body, this.options.hiddenDates); |
|
|
if (changed) { |
|
|
if (changed) { |
|
|
var params = {start: new Date(this.start), end: new Date(this.end)}; |
|
|
|
|
|
|
|
|
var params = {start: new Date(this.start), end: new Date(this.end), byUser:byUser}; |
|
|
this.body.emitter.emit('rangechange', params); |
|
|
this.body.emitter.emit('rangechange', params); |
|
|
this.body.emitter.emit('rangechanged', params); |
|
|
this.body.emitter.emit('rangechanged', params); |
|
|
} |
|
|
} |
|
@ -412,7 +416,8 @@ Range.prototype._onDrag = function (event) { |
|
|
// fire a rangechange event
|
|
|
// fire a rangechange event
|
|
|
this.body.emitter.emit('rangechange', { |
|
|
this.body.emitter.emit('rangechange', { |
|
|
start: new Date(this.start), |
|
|
start: new Date(this.start), |
|
|
end: new Date(this.end) |
|
|
|
|
|
|
|
|
end: new Date(this.end), |
|
|
|
|
|
byUser: true |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -437,7 +442,8 @@ Range.prototype._onDragEnd = function (event) { |
|
|
// fire a rangechanged event
|
|
|
// fire a rangechanged event
|
|
|
this.body.emitter.emit('rangechanged', { |
|
|
this.body.emitter.emit('rangechanged', { |
|
|
start: new Date(this.start), |
|
|
start: new Date(this.start), |
|
|
end: new Date(this.end) |
|
|
|
|
|
|
|
|
end: new Date(this.end), |
|
|
|
|
|
byUser: true |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -552,7 +558,7 @@ Range.prototype._onPinch = function (event) { |
|
|
newEnd = safeEnd; |
|
|
newEnd = safeEnd; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.setRange(newStart, newEnd); |
|
|
|
|
|
|
|
|
this.setRange(newStart, newEnd, false, true); |
|
|
|
|
|
|
|
|
this.startToFront = false; // revert to default
|
|
|
this.startToFront = false; // revert to default
|
|
|
this.endToFront = true; // revert to default
|
|
|
this.endToFront = true; // revert to default
|
|
@ -629,7 +635,7 @@ Range.prototype.zoom = function(scale, center, delta) { |
|
|
newEnd = safeEnd; |
|
|
newEnd = safeEnd; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.setRange(newStart, newEnd); |
|
|
|
|
|
|
|
|
this.setRange(newStart, newEnd, false, true); |
|
|
|
|
|
|
|
|
this.startToFront = false; // revert to default
|
|
|
this.startToFront = false; // revert to default
|
|
|
this.endToFront = true; // revert to default
|
|
|
this.endToFront = true; // revert to default
|
|
|