Browse Source

Implemented functions `setWindow` and `getWindow`

css_transitions
josdejong 11 years ago
parent
commit
a59b7f8d25
3 changed files with 36 additions and 1 deletions
  1. +1
    -0
      HISTORY.md
  2. +13
    -1
      docs/timeline.html
  3. +22
    -0
      src/timeline/Timeline.js

+ 1
- 0
HISTORY.md View File

@ -10,6 +10,7 @@ http://visjs.org
- Implemented options `selectable`, `editable`.
- Added events when dragging the custom time bar.
- Multiple items can be selected using ctrl+click or shift+click.
- Implemented functions `setWindow(start, end)` and `getWindow()`.
### DataSet

+ 13
- 1
docs/timeline.html View File

@ -599,10 +599,16 @@ var options = {
<tr>
<td>getSelection()</td>
<td>ids</td>
<td>Number[]</td>
<td>Get an array with the ids of the currently selected items.</td>
</tr>
<tr>
<td>getWindow()</td>
<td>Object</td>
<td>Get the current visible window. Returns an object with properties <code>start: Date</code> and <code>end: Date</code>.</td>
</tr>
<tr>
<td>on(event, callback)</td>
<td>none</td>
@ -649,6 +655,12 @@ var options = {
</td>
</tr>
<tr>
<td>setWindow(start, end)</td>
<td>none</td>
<td>Set the current visible window. The parameters <code>start</code> and <code>end</code> can be a <code>Date</code>, <code>Number</code>, or <code>String</code>. If the parameter value of <code>start</code> or <code>end</code> is null, the parameter will be left unchanged.</td>
</tr>
</table>

+ 22
- 0
src/timeline/Timeline.js View File

@ -432,6 +432,28 @@ Timeline.prototype.getSelection = function getSelection() {
return this.content ? this.content.getSelection() : [];
};
/**
* Set the visible window. Both parameters are optional, you can change only
* start or only end.
* @param {Date | Number | String} [start] Start date of visible window
* @param {Date | Number | String} [end] End date of visible window
*/
Timeline.prototype.setWindow = function setWindow(start, end) {
this.range.setRange(start, end);
};
/**
* Get the visible window
* @return {{start: Date, end: Date}} Visible range
*/
Timeline.prototype.getWindow = function setWindow() {
var range = this.range.getRange();
return {
start: new Date(range.start),
end: new Date(range.end)
};
};
/**
* Handle selecting/deselecting an item when tapping it
* @param {Event} event

Loading…
Cancel
Save