From 5c14597bb9364a74de27f022dd4b990ea04be5b8 Mon Sep 17 00:00:00 2001
From: josdejong
Date: Tue, 23 Apr 2013 13:51:42 +0200
Subject: [PATCH] Implemented namespacing, closure, and support for require.js
---
HISTORY.md | 4 +-
Jakefile.js | 13 +-
README.md | 28 ++-
examples/timeline/01_basic.html | 5 +-
examples/timeline/02_dataset.html | 4 +-
.../timeline/03_requirejs/03_requirejs.html | 11 +
.../timeline/03_requirejs/scripts/main.js | 19 ++
.../timeline/03_requirejs/scripts/require.js | 35 +++
src/component/component.js | 8 +
src/component/item/item.js | 13 +-
src/component/item/itembox.js | 11 +
src/component/item/itempoint.js | 11 +
src/component/item/itemrange.js | 11 +
src/component/itemset.js | 11 +-
src/component/panel.js | 8 +
src/component/rootpanel.js | 10 +-
src/component/timeaxis.js | 8 +
src/controller.js | 5 +
src/dataset.js | 7 +-
src/events.js | 5 +
src/module.js | 30 ++-
src/range.js | 5 +
src/stack.js | 5 +
src/timestep.js | 5 +
src/util.js | 6 +
src/visualization/timeline.js | 5 +
vis.js | 210 +++++++++++++++---
vis.min.js | 6 +-
28 files changed, 448 insertions(+), 51 deletions(-)
create mode 100644 examples/timeline/03_requirejs/03_requirejs.html
create mode 100644 examples/timeline/03_requirejs/scripts/main.js
create mode 100644 examples/timeline/03_requirejs/scripts/require.js
diff --git a/HISTORY.md b/HISTORY.md
index ccfb6928..cbc644c4 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -1,9 +1,11 @@
vis.js history
http://visjs.org
-##
+## version 0.0.6
- Css is now packaged in the javascript file, and automatically loaded.
+- The library has neat namespacing now, is in a closure and, and can be used
+ with require.js.
## 2012-04-16, version 0.0.5
diff --git a/Jakefile.js b/Jakefile.js
index 1e412574..a6ad052b 100644
--- a/Jakefile.js
+++ b/Jakefile.js
@@ -16,7 +16,7 @@ task('default', ['vis'], function () {
});
/**
- * vis.js, vis.css
+ * build the visualization library vis.js
*/
desc('Build the visualization library vis.js');
task('vis', function () {
@@ -39,7 +39,8 @@ task('vis', function () {
concat({
dest: VIS,
src: [
- './src/header.js',
+ './src/module.js',
+
'./src/util.js',
'./src/events.js',
'./src/timestep.js',
@@ -47,7 +48,6 @@ task('vis', function () {
'./src/stack.js',
'./src/range.js',
'./src/controller.js',
- './src/module.js',
'./src/component/component.js',
'./src/component/panel.js',
@@ -60,11 +60,16 @@ task('vis', function () {
'./lib/moment.js'
],
+
+ header: read('./src/header.js') + '\n' +
+ '(function () { ', // start of closure
+
separator: '\n',
// Note: we insert the css as a string in the javascript code here
// the css will be injected on load of the javascript library
- footer: 'loadCss(' + cssText + ');'
+ footer: 'loadCss(' + cssText + ');\n' +
+ '})();' // end of closure
});
// minify javascript
diff --git a/README.md b/README.md
index 65ceee62..95296e82 100644
--- a/README.md
+++ b/README.md
@@ -23,12 +23,36 @@ Or download the library from the github project:
## Load
-To use a component, include the javascript file of vis in your webpage.
+To use a component, include the javascript file of vis in your webpage:
```html
-
+
+
+
+
+
+
+
+
+
+```
+
+or load vis.js using require.js:
+
+```js
+require.config({
+ paths: {
+ vis: 'path/to/vis',
+ }
+});
+require(['vis'], function (math) {
+ // ... load a visualization
+});
```
+
A timeline can be instantiated as:
```js
diff --git a/examples/timeline/01_basic.html b/examples/timeline/01_basic.html
index 6e4811fc..7d73e901 100644
--- a/examples/timeline/01_basic.html
+++ b/examples/timeline/01_basic.html
@@ -2,13 +2,14 @@
Timeline basic demo
-
+
+
@@ -24,7 +25,7 @@
{id: 6, content: 'item 6', start: '2013-04-27'}
];
var options = {};
- var timeline = new Timeline(container, data, options);
+ var timeline = new vis.Timeline(container, data, options);
\ No newline at end of file
diff --git a/examples/timeline/02_dataset.html b/examples/timeline/02_dataset.html
index ee816f4c..7188129e 100644
--- a/examples/timeline/02_dataset.html
+++ b/examples/timeline/02_dataset.html
@@ -28,7 +28,7 @@
+
+
diff --git a/examples/timeline/03_requirejs/03_requirejs.html b/examples/timeline/03_requirejs/03_requirejs.html
new file mode 100644
index 00000000..764a75ba
--- /dev/null
+++ b/examples/timeline/03_requirejs/03_requirejs.html
@@ -0,0 +1,11 @@
+
+
+