Browse Source

Using vis as internal namespace now. All module related stuff is now located on a single place, in module.js

css_transitions
josdejong 11 years ago
parent
commit
3e4e9313e3
22 changed files with 121 additions and 275 deletions
  1. +14
    -14
      examples/timeline/01_basic.html
  2. +30
    -30
      examples/timeline/02_dataset.html
  3. +1
    -6
      src/component/component.js
  4. +1
    -12
      src/component/item/item.js
  5. +1
    -12
      src/component/item/itembox.js
  6. +1
    -12
      src/component/item/itempoint.js
  7. +1
    -12
      src/component/item/itemrange.js
  8. +2
    -7
      src/component/itemset.js
  9. +1
    -6
      src/component/panel.js
  10. +1
    -6
      src/component/rootpanel.js
  11. +1
    -6
      src/component/timeaxis.js
  12. +2
    -4
      src/controller.js
  13. +1
    -3
      src/dataset.js
  14. +1
    -3
      src/events.js
  15. +18
    -10
      src/module.js
  16. +1
    -3
      src/range.js
  17. +1
    -3
      src/stack.js
  18. +1
    -3
      src/timestep.js
  19. +1
    -3
      src/util.js
  20. +1
    -3
      src/visualization/timeline.js
  21. +37
    -114
      vis.js
  22. +3
    -3
      vis.min.js

+ 14
- 14
examples/timeline/01_basic.html View File

@ -12,20 +12,20 @@
<script src="../../vis.js"></script>
</head>
<body>
<div id="visualization"></div>
<div id="visualization"></div>
<script type="text/javascript">
var container = document.getElementById('visualization');
var data = [
{id: 1, content: 'item 1', start: '2013-04-20'},
{id: 2, content: 'item 2', start: '2013-04-14'},
{id: 3, content: 'item 3', start: '2013-04-18'},
{id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
{id: 5, content: 'item 5', start: '2013-04-25'},
{id: 6, content: 'item 6', start: '2013-04-27'}
];
var options = {};
var timeline = new vis.Timeline(container, data, options);
</script>
<script type="text/javascript">
var container = document.getElementById('visualization');
var data = [
{id: 1, content: 'item 1', start: '2013-04-20'},
{id: 2, content: 'item 2', start: '2013-04-14'},
{id: 3, content: 'item 3', start: '2013-04-18'},
{id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
{id: 5, content: 'item 5', start: '2013-04-25'},
{id: 6, content: 'item 6', start: '2013-04-27'}
];
var options = {};
var timeline = new vis.Timeline(container, data, options);
</script>
</body>
</html>

+ 30
- 30
examples/timeline/02_dataset.html View File

@ -2,7 +2,6 @@
<html>
<head>
<title>Timeline demo</title>
<script src="../../vis.js"></script>
<style>
body, html {
@ -21,36 +20,37 @@
}
</style>
<script src="../../vis.js"></script>
</head>
<body>
<div id="visualization"></div>
<script>
// create a dataset with items
var now = moment().minutes(0).seconds(0).milliseconds(0);
var data = new vis.DataSet({
fieldTypes: {
start: 'Date',
end: 'Date'
}
});
data.add([
{id: 1, content: 'item 1<br>start', start: now.clone().add('days', 4).toDate()},
{id: 2, content: 'item 2', start: now.clone().add('days', -2).toDate() },
{id: 3, content: 'item 3', start: now.clone().add('days', 2).toDate()},
{id: 4, content: 'item 4', start: now.clone().add('days', 0).toDate(), end: now.clone().add('days', 3).toDate()},
{id: 5, content: 'item 5', start: now.clone().add('days', 9).toDate(), type:'point'},
{id: 6, content: 'item 6', start: now.clone().add('days', 11).toDate()}
]);
var container = document.getElementById('visualization');
var options = {
start: now.clone().add('days', -3).valueOf(),
end: now.clone().add('days', 7).valueOf()
};
var timeline = new vis.Timeline(container, data, options);
</script>
<div id="visualization"></div>
<script>
// create a dataset with items
var now = moment().minutes(0).seconds(0).milliseconds(0);
var data = new vis.DataSet({
fieldTypes: {
start: 'Date',
end: 'Date'
}
});
data.add([
{id: 1, content: 'item 1<br>start', start: now.clone().add('days', 4).toDate()},
{id: 2, content: 'item 2', start: now.clone().add('days', -2).toDate() },
{id: 3, content: 'item 3', start: now.clone().add('days', 2).toDate()},
{id: 4, content: 'item 4', start: now.clone().add('days', 0).toDate(), end: now.clone().add('days', 3).toDate()},
{id: 5, content: 'item 5', start: now.clone().add('days', 9).toDate(), type:'point'},
{id: 6, content: 'item 6', start: now.clone().add('days', 11).toDate()}
]);
var container = document.getElementById('visualization');
var options = {
start: now.clone().add('days', -3).valueOf(),
end: now.clone().add('days', 7).valueOf()
};
var timeline = new vis.Timeline(container, data, options);
</script>
</body>
</html>

+ 1
- 6
src/component/component.js View File

@ -116,9 +116,4 @@ Component.prototype.on = function (event, callback) {
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.Component = Component;
}
vis.component.Component = Component;

+ 1
- 12
src/component/item/item.js View File

@ -32,16 +32,5 @@ Item.prototype.unselect = function () {
this.selected = false;
};
// create a namespace for all item types
var itemTypes = {};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
if (!('item' in exports.component)) {
exports.component.item = {};
}
exports.component.item.Item = Item;
}
vis.component.item.Item = Item;

+ 1
- 12
src/component/item/itembox.js View File

@ -28,9 +28,6 @@ function ItemBox (parent, data, options) {
ItemBox.prototype = new Item (null, null);
// register the ItemBox in the item types
itemTypes['box'] = ItemBox;
/**
* Select the item
* @override
@ -269,12 +266,4 @@ ItemBox.prototype.reposition = function () {
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
if (!('item' in exports.component)) {
exports.component.item = {};
}
exports.component.item.ItemBox = ItemBox;
}
vis.component.item.box = ItemBox;

+ 1
- 12
src/component/item/itempoint.js View File

@ -25,9 +25,6 @@ function ItemPoint (parent, data, options) {
ItemPoint.prototype = new Item (null, null);
// register the ItemPoint in the item types
itemTypes['point'] = ItemPoint;
/**
* Select the item
* @override
@ -209,12 +206,4 @@ ItemPoint.prototype.reposition = function () {
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
if (!('item' in exports.component)) {
exports.component.item = {};
}
exports.component.item.ItemPoint = ItemPoint;
}
vis.component.item.point = ItemPoint;

+ 1
- 12
src/component/item/itemrange.js View File

@ -20,9 +20,6 @@ function ItemRange (parent, data, options) {
ItemRange.prototype = new Item (null, null);
// register the ItemBox in the item types
itemTypes['range'] = ItemRange;
/**
* Select the item
* @override
@ -219,12 +216,4 @@ ItemRange.prototype.reposition = function () {
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
if (!('item' in exports.component)) {
exports.component.item = {};
}
exports.component.item.ItemRange = ItemRange;
}
vis.component.item.range = ItemRange;

+ 2
- 7
src/component/itemset.js View File

@ -160,7 +160,7 @@ ItemSet.prototype.repaint = function () {
var type = itemData.type ||
(itemData.start && itemData.end && 'range') ||
'box';
var constructor = itemTypes[type];
var constructor = vis.component.item[type];
// TODO: how to handle items with invalid data? hide them and give a warning? or throw an error?
if (item) {
@ -442,9 +442,4 @@ ItemSet.prototype.toScreen = function(time) {
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.ItemSet = ItemSet;
}
vis.component.ItemSet = ItemSet;

+ 1
- 6
src/component/panel.js View File

@ -101,9 +101,4 @@ Panel.prototype.reflow = function () {
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.Panel = Panel;
}
vis.component.Panel = Panel;

+ 1
- 6
src/component/rootpanel.js View File

@ -200,9 +200,4 @@ RootPanel.prototype._updateEventEmitters = function () {
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.RootPanel = RootPanel;
}
vis.component.RootPanel = RootPanel;

+ 1
- 6
src/component/timeaxis.js View File

@ -524,9 +524,4 @@ TimeAxis.prototype._updateConversion = function() {
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.TimeAxis = TimeAxis;
}
vis.component.TimeAxis = TimeAxis;

+ 2
- 4
src/controller.js View File

@ -138,7 +138,5 @@ Controller.prototype.reflow = function () {
// TODO: limit the number of nested reflows/repaints, prevent loop
};
// export
if (typeof exports !== 'undefined') {
exports.Controller = Controller;
}
// exports
vis.Controller = Controller;

+ 1
- 3
src/dataset.js View File

@ -547,6 +547,4 @@ DataSet.prototype._appendRow = function (dataTable, columns, item) {
};
// exports
if (typeof exports !== 'undefined') {
exports.DataSet = DataSet;
}
vis.DataSet = DataSet;

+ 1
- 3
src/events.js View File

@ -116,6 +116,4 @@ var events = {
};
// exports
if (typeof exports !== 'undefined') {
exports.events = events;
}
vis.events = events;

+ 18
- 10
src/module.js View File

@ -1,3 +1,9 @@
// Define namespace vis
var vis = {
component: {
item: {}
}
};
/**
* load css from text
@ -26,24 +32,26 @@ var loadCss = function (css) {
/**
* Define CommonJS module exports when not available
*/
if (typeof exports === 'undefined') {
var exports = {};
if (typeof exports !== 'undefined') {
exports = vis;
}
if (typeof module === 'undefined') {
var module = {
exports: exports
};
if (typeof module !== 'undefined') {
module.exports = vis;
}
/**
* AMD module exports
*/
if (typeof(require) != 'undefined' && typeof(define) != 'undefined') {
if (typeof(define) === 'function') {
define(function () {
return exports;
return vis;
});
}
else {
/**
* Window exports
*/
if (typeof window !== 'undefined') {
// attach the module to the window, load as a regular javascript file
window['vis'] = exports;
window['vis'] = vis;
}

+ 1
- 3
src/range.js View File

@ -524,6 +524,4 @@ Range.prototype.move = function(moveFactor) {
};
// exports
if (typeof exports !== 'undefined') {
exports.Range = Range;
}
vis.Range = Range;

+ 1
- 3
src/stack.js View File

@ -157,6 +157,4 @@ Stack.prototype.collision = function(a, b, margin) {
};
// exports
if (typeof exports !== 'undefined') {
exports.Stack = Stack;
}
vis.Stack = Stack;

+ 1
- 3
src/timestep.js View File

@ -450,6 +450,4 @@ TimeStep.prototype.getLabelMajor = function(date) {
};
// export
if (typeof exports !== 'undefined') {
exports.TimeStep = TimeStep;
}
vis.TimeStep = TimeStep;

+ 1
- 3
src/util.js View File

@ -764,6 +764,4 @@ if(!Array.isArray) {
// export
if (typeof exports !== 'undefined') {
exports.util = util;
}
vis.util = util;

+ 1
- 3
src/visualization/timeline.js View File

@ -140,6 +140,4 @@ Timeline.prototype.setData = function(data) {
};
// exports
if (typeof exports !== 'undefined') {
exports.Timeline = Timeline;
}
vis.Timeline = Timeline;

+ 37
- 114
vis.js View File

@ -24,6 +24,12 @@
*/
(function () {
// Define namespace vis
var vis = {
component: {
item: {}
}
};
/**
* load css from text
@ -52,26 +58,28 @@ var loadCss = function (css) {
/**
* Define CommonJS module exports when not available
*/
if (typeof exports === 'undefined') {
var exports = {};
if (typeof exports !== 'undefined') {
exports = vis;
}
if (typeof module === 'undefined') {
var module = {
exports: exports
};
if (typeof module !== 'undefined') {
module.exports = vis;
}
/**
* AMD module exports
*/
if (typeof(require) != 'undefined' && typeof(define) != 'undefined') {
if (typeof(define) === 'function') {
define(function () {
return exports;
return vis;
});
}
else {
/**
* Window exports
*/
if (typeof window !== 'undefined') {
// attach the module to the window, load as a regular javascript file
window['vis'] = exports;
window['vis'] = vis;
}
@ -840,9 +848,7 @@ if(!Array.isArray) {
// export
if (typeof exports !== 'undefined') {
exports.util = util;
}
vis.util = util;
/**
@ -962,9 +968,7 @@ var events = {
};
// exports
if (typeof exports !== 'undefined') {
exports.events = events;
}
vis.events = events;
/**
* @constructor TimeStep
@ -1418,9 +1422,7 @@ TimeStep.prototype.getLabelMajor = function(date) {
};
// export
if (typeof exports !== 'undefined') {
exports.TimeStep = TimeStep;
}
vis.TimeStep = TimeStep;
/**
* DataSet
@ -1971,9 +1973,7 @@ DataSet.prototype._appendRow = function (dataTable, columns, item) {
};
// exports
if (typeof exports !== 'undefined') {
exports.DataSet = DataSet;
}
vis.DataSet = DataSet;
/**
* @constructor Stack
@ -2134,9 +2134,7 @@ Stack.prototype.collision = function(a, b, margin) {
};
// exports
if (typeof exports !== 'undefined') {
exports.Stack = Stack;
}
vis.Stack = Stack;
/**
* @constructor Range
@ -2664,9 +2662,7 @@ Range.prototype.move = function(moveFactor) {
};
// exports
if (typeof exports !== 'undefined') {
exports.Range = Range;
}
vis.Range = Range;
/**
* @constructor Controller
@ -2808,10 +2804,8 @@ Controller.prototype.reflow = function () {
// TODO: limit the number of nested reflows/repaints, prevent loop
};
// export
if (typeof exports !== 'undefined') {
exports.Controller = Controller;
}
// exports
vis.Controller = Controller;
/**
* Prototype for visual components
@ -2931,12 +2925,7 @@ Component.prototype.on = function (event, callback) {
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.Component = Component;
}
vis.component.Component = Component;
/**
* A panel can contain components
@ -3041,12 +3030,7 @@ Panel.prototype.reflow = function () {
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.Panel = Panel;
}
vis.component.Panel = Panel;
/**
* A root panel can hold components. The root panel must be initialized with
@ -3250,12 +3234,7 @@ RootPanel.prototype._updateEventEmitters = function () {
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.RootPanel = RootPanel;
}
vis.component.RootPanel = RootPanel;
/**
* A horizontal time axis
@ -3783,12 +3762,7 @@ TimeAxis.prototype._updateConversion = function() {
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.TimeAxis = TimeAxis;
}
vis.component.TimeAxis = TimeAxis;
/**
* An ItemSet holds a set of items and ranges which can be displayed in a
@ -3952,7 +3926,7 @@ ItemSet.prototype.repaint = function () {
var type = itemData.type ||
(itemData.start && itemData.end && 'range') ||
'box';
var constructor = itemTypes[type];
var constructor = vis.component.item[type];
// TODO: how to handle items with invalid data? hide them and give a warning? or throw an error?
if (item) {
@ -4234,12 +4208,7 @@ ItemSet.prototype.toScreen = function(time) {
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.ItemSet = ItemSet;
}
vis.component.ItemSet = ItemSet;
/**
@ -4275,19 +4244,8 @@ Item.prototype.unselect = function () {
this.selected = false;
};
// create a namespace for all item types
var itemTypes = {};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
if (!('item' in exports.component)) {
exports.component.item = {};
}
exports.component.item.Item = Item;
}
vis.component.item.Item = Item;
/**
* @constructor ItemBox
@ -4319,9 +4277,6 @@ function ItemBox (parent, data, options) {
ItemBox.prototype = new Item (null, null);
// register the ItemBox in the item types
itemTypes['box'] = ItemBox;
/**
* Select the item
* @override
@ -4560,15 +4515,7 @@ ItemBox.prototype.reposition = function () {
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
if (!('item' in exports.component)) {
exports.component.item = {};
}
exports.component.item.ItemBox = ItemBox;
}
vis.component.item.box = ItemBox;
/**
* @constructor ItemPoint
@ -4597,9 +4544,6 @@ function ItemPoint (parent, data, options) {
ItemPoint.prototype = new Item (null, null);
// register the ItemPoint in the item types
itemTypes['point'] = ItemPoint;
/**
* Select the item
* @override
@ -4781,15 +4725,7 @@ ItemPoint.prototype.reposition = function () {
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
if (!('item' in exports.component)) {
exports.component.item = {};
}
exports.component.item.ItemPoint = ItemPoint;
}
vis.component.item.point = ItemPoint;
/**
* @constructor ItemRange
@ -4813,9 +4749,6 @@ function ItemRange (parent, data, options) {
ItemRange.prototype = new Item (null, null);
// register the ItemBox in the item types
itemTypes['range'] = ItemRange;
/**
* Select the item
* @override
@ -5012,15 +4945,7 @@ ItemRange.prototype.reposition = function () {
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
if (!('item' in exports.component)) {
exports.component.item = {};
}
exports.component.item.ItemRange = ItemRange;
}
vis.component.item.range = ItemRange;
/**
* Create a timeline visualization
@ -5164,9 +5089,7 @@ Timeline.prototype.setData = function(data) {
};
// exports
if (typeof exports !== 'undefined') {
exports.Timeline = Timeline;
}
vis.Timeline = Timeline;
// moment.js
// version : 2.0.0

+ 3
- 3
vis.min.js
File diff suppressed because it is too large
View File


Loading…
Cancel
Save