Browse Source

Implemented namespacing, closure, and support for require.js

css_transitions
josdejong 11 years ago
parent
commit
5c14597bb9
28 changed files with 448 additions and 51 deletions
  1. +3
    -1
      HISTORY.md
  2. +9
    -4
      Jakefile.js
  3. +26
    -2
      README.md
  4. +3
    -2
      examples/timeline/01_basic.html
  5. +2
    -2
      examples/timeline/02_dataset.html
  6. +11
    -0
      examples/timeline/03_requirejs/03_requirejs.html
  7. +19
    -0
      examples/timeline/03_requirejs/scripts/main.js
  8. +35
    -0
      examples/timeline/03_requirejs/scripts/require.js
  9. +8
    -0
      src/component/component.js
  10. +12
    -1
      src/component/item/item.js
  11. +11
    -0
      src/component/item/itembox.js
  12. +11
    -0
      src/component/item/itempoint.js
  13. +11
    -0
      src/component/item/itemrange.js
  14. +9
    -2
      src/component/itemset.js
  15. +8
    -0
      src/component/panel.js
  16. +9
    -1
      src/component/rootpanel.js
  17. +8
    -0
      src/component/timeaxis.js
  18. +5
    -0
      src/controller.js
  19. +6
    -1
      src/dataset.js
  20. +5
    -0
      src/events.js
  21. +27
    -3
      src/module.js
  22. +5
    -0
      src/range.js
  23. +5
    -0
      src/stack.js
  24. +5
    -0
      src/timestep.js
  25. +6
    -0
      src/util.js
  26. +5
    -0
      src/visualization/timeline.js
  27. +181
    -29
      vis.js
  28. +3
    -3
      vis.min.js

+ 3
- 1
HISTORY.md View File

@ -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

+ 9
- 4
Jakefile.js View File

@ -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

+ 26
- 2
README.md View File

@ -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
<script src="components/vis/vis.js"></script>
<!DOCTYPE HTML>
<html>
<head>
<script src="components/vis/vis.js"></script>
</head>
<body>
<script type="text/javascript">
// ... load a visualization
</script>
</body>
</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

+ 3
- 2
examples/timeline/01_basic.html View File

@ -2,13 +2,14 @@
<html>
<head>
<title>Timeline basic demo</title>
<script src="../../vis.js"></script>
<style type="text/css">
body, html {
font-family: sans-serif;
}
</style>
<script src="../../vis.js"></script>
</head>
<body>
<div id="visualization"></div>
@ -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);
</script>
</body>
</html>

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

@ -28,7 +28,7 @@
<script>
// create a dataset with items
var now = moment().minutes(0).seconds(0).milliseconds(0);
var data = new DataSet({
var data = new vis.DataSet({
fieldTypes: {
start: 'Date',
end: 'Date'
@ -49,7 +49,7 @@
end: now.clone().add('days', 7).valueOf()
};
var timeline = new Timeline(container, data, options);
var timeline = new vis.Timeline(container, data, options);
</script>
</body>

+ 11
- 0
examples/timeline/03_requirejs/03_requirejs.html View File

@ -0,0 +1,11 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Timeline requirejs demo</title>
<script data-main="scripts/main" src="scripts/require.js"></script>
</head>
<body>
<div id="visualization"></div>
</body>
</html>

+ 19
- 0
examples/timeline/03_requirejs/scripts/main.js View File

@ -0,0 +1,19 @@
require.config({
paths: {
vis: '../../../../vis'
}
});
require(['vis'], function (vis) {
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);
});

+ 35
- 0
examples/timeline/03_requirejs/scripts/require.js View File

@ -0,0 +1,35 @@
/*
RequireJS 2.1.2 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/jrburke/requirejs for details
*/
var requirejs,require,define;
(function(Y){function H(b){return"[object Function]"===L.call(b)}function I(b){return"[object Array]"===L.call(b)}function x(b,c){if(b){var d;for(d=0;d<b.length&&(!b[d]||!c(b[d],d,b));d+=1);}}function M(b,c){if(b){var d;for(d=b.length-1;-1<d&&(!b[d]||!c(b[d],d,b));d-=1);}}function r(b,c){return da.call(b,c)}function i(b,c){return r(b,c)&&b[c]}function E(b,c){for(var d in b)if(r(b,d)&&c(b[d],d))break}function Q(b,c,d,i){c&&E(c,function(c,h){if(d||!r(b,h))i&&"string"!==typeof c?(b[h]||(b[h]={}),Q(b[h],
c,d,i)):b[h]=c});return b}function t(b,c){return function(){return c.apply(b,arguments)}}function Z(b){if(!b)return b;var c=Y;x(b.split("."),function(b){c=c[b]});return c}function J(b,c,d,i){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=i;d&&(c.originalError=d);return c}function ea(b){function c(a,g,v){var e,n,b,c,d,j,f,h=g&&g.split("/");e=h;var l=m.map,k=l&&l["*"];if(a&&"."===a.charAt(0))if(g){e=i(m.pkgs,g)?h=[g]:h.slice(0,h.length-1);g=a=e.concat(a.split("/"));
for(e=0;g[e];e+=1)if(n=g[e],"."===n)g.splice(e,1),e-=1;else if(".."===n)if(1===e&&(".."===g[2]||".."===g[0]))break;else 0<e&&(g.splice(e-1,2),e-=2);e=i(m.pkgs,g=a[0]);a=a.join("/");e&&a===g+"/"+e.main&&(a=g)}else 0===a.indexOf("./")&&(a=a.substring(2));if(v&&(h||k)&&l){g=a.split("/");for(e=g.length;0<e;e-=1){b=g.slice(0,e).join("/");if(h)for(n=h.length;0<n;n-=1)if(v=i(l,h.slice(0,n).join("/")))if(v=i(v,b)){c=v;d=e;break}if(c)break;!j&&(k&&i(k,b))&&(j=i(k,b),f=e)}!c&&j&&(c=j,d=f);c&&(g.splice(0,d,
c),a=g.join("/"))}return a}function d(a){z&&x(document.getElementsByTagName("script"),function(g){if(g.getAttribute("data-requiremodule")===a&&g.getAttribute("data-requirecontext")===j.contextName)return g.parentNode.removeChild(g),!0})}function y(a){var g=i(m.paths,a);if(g&&I(g)&&1<g.length)return d(a),g.shift(),j.require.undef(a),j.require([a]),!0}function f(a){var g,b=a?a.indexOf("!"):-1;-1<b&&(g=a.substring(0,b),a=a.substring(b+1,a.length));return[g,a]}function h(a,g,b,e){var n,u,d=null,h=g?g.name:
null,l=a,m=!0,k="";a||(m=!1,a="_@r"+(L+=1));a=f(a);d=a[0];a=a[1];d&&(d=c(d,h,e),u=i(p,d));a&&(d?k=u&&u.normalize?u.normalize(a,function(a){return c(a,h,e)}):c(a,h,e):(k=c(a,h,e),a=f(k),d=a[0],k=a[1],b=!0,n=j.nameToUrl(k)));b=d&&!u&&!b?"_unnormalized"+(M+=1):"";return{prefix:d,name:k,parentMap:g,unnormalized:!!b,url:n,originalName:l,isDefine:m,id:(d?d+"!"+k:k)+b}}function q(a){var g=a.id,b=i(k,g);b||(b=k[g]=new j.Module(a));return b}function s(a,g,b){var e=a.id,n=i(k,e);if(r(p,e)&&(!n||n.defineEmitComplete))"defined"===
g&&b(p[e]);else q(a).on(g,b)}function C(a,g){var b=a.requireModules,e=!1;if(g)g(a);else if(x(b,function(g){if(g=i(k,g))g.error=a,g.events.error&&(e=!0,g.emit("error",a))}),!e)l.onError(a)}function w(){R.length&&(fa.apply(F,[F.length-1,0].concat(R)),R=[])}function A(a,g,b){var e=a.map.id;a.error?a.emit("error",a.error):(g[e]=!0,x(a.depMaps,function(e,c){var d=e.id,h=i(k,d);h&&(!a.depMatched[c]&&!b[d])&&(i(g,d)?(a.defineDep(c,p[d]),a.check()):A(h,g,b))}),b[e]=!0)}function B(){var a,g,b,e,n=(b=1E3*m.waitSeconds)&&
j.startTime+b<(new Date).getTime(),c=[],h=[],f=!1,l=!0;if(!T){T=!0;E(k,function(b){a=b.map;g=a.id;if(b.enabled&&(a.isDefine||h.push(b),!b.error))if(!b.inited&&n)y(g)?f=e=!0:(c.push(g),d(g));else if(!b.inited&&(b.fetched&&a.isDefine)&&(f=!0,!a.prefix))return l=!1});if(n&&c.length)return b=J("timeout","Load timeout for modules: "+c,null,c),b.contextName=j.contextName,C(b);l&&x(h,function(a){A(a,{},{})});if((!n||e)&&f)if((z||$)&&!U)U=setTimeout(function(){U=0;B()},50);T=!1}}function D(a){r(p,a[0])||
q(h(a[0],null,!0)).init(a[1],a[2])}function G(a){var a=a.currentTarget||a.srcElement,b=j.onScriptLoad;a.detachEvent&&!V?a.detachEvent("onreadystatechange",b):a.removeEventListener("load",b,!1);b=j.onScriptError;(!a.detachEvent||V)&&a.removeEventListener("error",b,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}function K(){var a;for(w();F.length;){a=F.shift();if(null===a[0])return C(J("mismatch","Mismatched anonymous define() module: "+a[a.length-1]));D(a)}}var T,W,j,N,U,m={waitSeconds:7,
baseUrl:"./",paths:{},pkgs:{},shim:{},map:{},config:{}},k={},X={},F=[],p={},S={},L=1,M=1;N={require:function(a){return a.require?a.require:a.require=j.makeRequire(a.map)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports?a.exports:a.exports=p[a.map.id]={}},module:function(a){return a.module?a.module:a.module={id:a.map.id,uri:a.map.url,config:function(){return m.config&&i(m.config,a.map.id)||{}},exports:p[a.map.id]}}};W=function(a){this.events=i(X,a.id)||{};this.map=a;this.shim=
i(m.shim,a.id);this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};W.prototype={init:function(a,b,c,e){e=e||{};if(!this.inited){this.factory=b;if(c)this.on("error",c);else this.events.error&&(c=t(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.errback=c;this.inited=!0;this.ignore=e.ignore;e.enabled||this.enabled?this.enable():this.check()}},defineDep:function(a,b){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=
b)},fetch:function(){if(!this.fetched){this.fetched=!0;j.startTime=(new Date).getTime();var a=this.map;if(this.shim)j.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],t(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=this.map.url;S[a]||(S[a]=!0,j.load(this.map.id,a))},check:function(){if(this.enabled&&!this.enabling){var a,b,c=this.map.id;b=this.depExports;var e=this.exports,n=this.factory;
if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(1>this.depCount&&!this.defined){if(H(n)){if(this.events.error)try{e=j.execCb(c,n,b,e)}catch(d){a=d}else e=j.execCb(c,n,b,e);this.map.isDefine&&((b=this.module)&&void 0!==b.exports&&b.exports!==this.exports?e=b.exports:void 0===e&&this.usingExports&&(e=this.exports));if(a)return a.requireMap=this.map,a.requireModules=[this.map.id],a.requireType="define",C(this.error=a)}else e=n;this.exports=e;if(this.map.isDefine&&
!this.ignore&&(p[c]=e,l.onResourceLoad))l.onResourceLoad(j,this.map,this.depMaps);delete k[c];this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else this.fetch()}},callPlugin:function(){var a=this.map,b=a.id,d=h(a.prefix);this.depMaps.push(d);s(d,"defined",t(this,function(e){var n,d;d=this.map.name;var v=this.map.parentMap?this.map.parentMap.name:null,f=j.makeRequire(a.parentMap,{enableBuildCallback:!0,
skipMap:!0});if(this.map.unnormalized){if(e.normalize&&(d=e.normalize(d,function(a){return c(a,v,!0)})||""),e=h(a.prefix+"!"+d,this.map.parentMap),s(e,"defined",t(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),d=i(k,e.id)){this.depMaps.push(e);if(this.events.error)d.on("error",t(this,function(a){this.emit("error",a)}));d.enable()}}else n=t(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),n.error=t(this,function(a){this.inited=!0;this.error=
a;a.requireModules=[b];E(k,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&delete k[a.map.id]});C(a)}),n.fromText=t(this,function(e,c){var d=a.name,u=h(d),v=O;c&&(e=c);v&&(O=!1);q(u);r(m.config,b)&&(m.config[d]=m.config[b]);try{l.exec(e)}catch(k){throw Error("fromText eval for "+d+" failed: "+k);}v&&(O=!0);this.depMaps.push(u);j.completeLoad(d);f([d],n)}),e.load(a.name,f,n,m)}));j.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){this.enabling=this.enabled=!0;x(this.depMaps,t(this,function(a,
b){var c,e;if("string"===typeof a){a=h(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=i(N,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;s(a,"defined",t(this,function(a){this.defineDep(b,a);this.check()}));this.errback&&s(a,"error",this.errback)}c=a.id;e=k[c];!r(N,c)&&(e&&!e.enabled)&&j.enable(a,this)}));E(this.pluginMaps,t(this,function(a){var b=i(k,a.id);b&&!b.enabled&&j.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=
this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){x(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};j={config:m,contextName:b,registry:k,defined:p,urlFetched:S,defQueue:F,Module:W,makeModuleMap:h,nextTick:l.nextTick,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=m.pkgs,c=m.shim,e={paths:!0,config:!0,map:!0};E(a,function(a,b){e[b]?"map"===b?Q(m[b],a,!0,!0):Q(m[b],a,!0):m[b]=a});a.shim&&(E(a.shim,function(a,
b){I(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn=j.makeShimExports(a);c[b]=a}),m.shim=c);a.packages&&(x(a.packages,function(a){a="string"===typeof a?{name:a}:a;b[a.name]={name:a.name,location:a.location||a.name,main:(a.main||"main").replace(ga,"").replace(aa,"")}}),m.pkgs=b);E(k,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=h(b))});if(a.deps||a.callback)j.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(Y,arguments));
return b||a.exports&&Z(a.exports)}},makeRequire:function(a,d){function f(e,c,u){var i,m;d.enableBuildCallback&&(c&&H(c))&&(c.__requireJsBuild=!0);if("string"===typeof e){if(H(c))return C(J("requireargs","Invalid require call"),u);if(a&&r(N,e))return N[e](k[a.id]);if(l.get)return l.get(j,e,a);i=h(e,a,!1,!0);i=i.id;return!r(p,i)?C(J("notloaded",'Module name "'+i+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):p[i]}K();j.nextTick(function(){K();m=q(h(null,a));m.skipMap=d.skipMap;
m.init(e,c,u,{enabled:!0});B()});return f}d=d||{};Q(f,{isBrowser:z,toUrl:function(b){var d=b.lastIndexOf("."),g=null;-1!==d&&(g=b.substring(d,b.length),b=b.substring(0,d));return j.nameToUrl(c(b,a&&a.id,!0),g)},defined:function(b){return r(p,h(b,a,!1,!0).id)},specified:function(b){b=h(b,a,!1,!0).id;return r(p,b)||r(k,b)}});a||(f.undef=function(b){w();var c=h(b,a,!0),d=i(k,b);delete p[b];delete S[c.url];delete X[b];d&&(d.events.defined&&(X[b]=d.events),delete k[b])});return f},enable:function(a){i(k,
a.id)&&q(a).enable()},completeLoad:function(a){var b,c,d=i(m.shim,a)||{},h=d.exports;for(w();F.length;){c=F.shift();if(null===c[0]){c[0]=a;if(b)break;b=!0}else c[0]===a&&(b=!0);D(c)}c=i(k,a);if(!b&&!r(p,a)&&c&&!c.inited){if(m.enforceDefine&&(!h||!Z(h)))return y(a)?void 0:C(J("nodefine","No define call for "+a,null,[a]));D([a,d.deps||[],d.exportsFn])}B()},nameToUrl:function(a,b){var c,d,h,f,j,k;if(l.jsExtRegExp.test(a))f=a+(b||"");else{c=m.paths;d=m.pkgs;f=a.split("/");for(j=f.length;0<j;j-=1)if(k=
f.slice(0,j).join("/"),h=i(d,k),k=i(c,k)){I(k)&&(k=k[0]);f.splice(0,j,k);break}else if(h){c=a===h.name?h.location+"/"+h.main:h.location;f.splice(0,j,c);break}f=f.join("/");f+=b||(/\?/.test(f)?"":".js");f=("/"===f.charAt(0)||f.match(/^[\w\+\.\-]+:/)?"":m.baseUrl)+f}return m.urlArgs?f+((-1===f.indexOf("?")?"?":"&")+m.urlArgs):f},load:function(a,b){l.load(j,a,b)},execCb:function(a,b,c,d){return b.apply(d,c)},onScriptLoad:function(a){if("load"===a.type||ha.test((a.currentTarget||a.srcElement).readyState))P=
null,a=G(a),j.completeLoad(a.id)},onScriptError:function(a){var b=G(a);if(!y(b.id))return C(J("scripterror","Script error",a,[b.id]))}};j.require=j.makeRequire();return j}var l,w,A,D,s,G,P,K,ba,ca,ia=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,ja=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,aa=/\.js$/,ga=/^\.\//;w=Object.prototype;var L=w.toString,da=w.hasOwnProperty,fa=Array.prototype.splice,z=!!("undefined"!==typeof window&&navigator&&document),$=!z&&"undefined"!==typeof importScripts,ha=z&&
"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,V="undefined"!==typeof opera&&"[object Opera]"===opera.toString(),B={},q={},R=[],O=!1;if("undefined"===typeof define){if("undefined"!==typeof requirejs){if(H(requirejs))return;q=requirejs;requirejs=void 0}"undefined"!==typeof require&&!H(require)&&(q=require,require=void 0);l=requirejs=function(b,c,d,y){var f,h="_";!I(b)&&"string"!==typeof b&&(f=b,I(c)?(b=c,c=d,d=y):b=[]);f&&f.context&&(h=f.context);(y=i(B,h))||(y=B[h]=l.s.newContext(h));
f&&y.configure(f);return y.require(b,c,d)};l.config=function(b){return l(b)};l.nextTick="undefined"!==typeof setTimeout?function(b){setTimeout(b,4)}:function(b){b()};require||(require=l);l.version="2.1.2";l.jsExtRegExp=/^\/|:|\?|\.js$/;l.isBrowser=z;w=l.s={contexts:B,newContext:ea};l({});x(["toUrl","undef","defined","specified"],function(b){l[b]=function(){var c=B._;return c.require[b].apply(c,arguments)}});if(z&&(A=w.head=document.getElementsByTagName("head")[0],D=document.getElementsByTagName("base")[0]))A=
w.head=D.parentNode;l.onError=function(b){throw b;};l.load=function(b,c,d){var i=b&&b.config||{},f;if(z)return f=i.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script"),f.type=i.scriptType||"text/javascript",f.charset="utf-8",f.async=!0,f.setAttribute("data-requirecontext",b.contextName),f.setAttribute("data-requiremodule",c),f.attachEvent&&!(f.attachEvent.toString&&0>f.attachEvent.toString().indexOf("[native code"))&&!V?(O=!0,f.attachEvent("onreadystatechange",
b.onScriptLoad)):(f.addEventListener("load",b.onScriptLoad,!1),f.addEventListener("error",b.onScriptError,!1)),f.src=d,K=f,D?A.insertBefore(f,D):A.appendChild(f),K=null,f;$&&(importScripts(d),b.completeLoad(c))};z&&M(document.getElementsByTagName("script"),function(b){A||(A=b.parentNode);if(s=b.getAttribute("data-main"))return q.baseUrl||(G=s.split("/"),ba=G.pop(),ca=G.length?G.join("/")+"/":"./",q.baseUrl=ca,s=ba),s=s.replace(aa,""),q.deps=q.deps?q.deps.concat(s):[s],!0});define=function(b,c,d){var i,
f;"string"!==typeof b&&(d=c,c=b,b=null);I(c)||(d=c,c=[]);!c.length&&H(d)&&d.length&&(d.toString().replace(ia,"").replace(ja,function(b,d){c.push(d)}),c=(1===d.length?["require"]:["require","exports","module"]).concat(c));if(O){if(!(i=K))P&&"interactive"===P.readyState||M(document.getElementsByTagName("script"),function(b){if("interactive"===b.readyState)return P=b}),i=P;i&&(b||(b=i.getAttribute("data-requiremodule")),f=B[i.getAttribute("data-requirecontext")])}(f?f.defQueue:R).push([b,c,d])};define.amd=
{jQuery:!0};l.exec=function(b){return eval(b)};l(q)}})(this);

+ 8
- 0
src/component/component.js View File

@ -114,3 +114,11 @@ Component.prototype.on = function (event, callback) {
throw new Error('Cannot attach event: no root panel found');
}
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.Component = Component;
}

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

@ -33,4 +33,15 @@ Item.prototype.unselect = function () {
};
// create a namespace for all item types
var itemTypes = {};
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;
}

+ 11
- 0
src/component/item/itembox.js View File

@ -267,3 +267,14 @@ ItemBox.prototype.reposition = function () {
dot.style.top = props.dot.top + 'px';
}
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
if (!('item' in exports.component)) {
exports.component.item = {};
}
exports.component.item.ItemBox = ItemBox;
}

+ 11
- 0
src/component/item/itempoint.js View File

@ -207,3 +207,14 @@ ItemPoint.prototype.reposition = function () {
dom.dot.style.top = props.dot.top + 'px';
}
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
if (!('item' in exports.component)) {
exports.component.item = {};
}
exports.component.item.ItemPoint = ItemPoint;
}

+ 11
- 0
src/component/item/itemrange.js View File

@ -217,3 +217,14 @@ ItemRange.prototype.reposition = function () {
dom.content.style.left = props.content.left + 'px';
}
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
if (!('item' in exports.component)) {
exports.component.item = {};
}
exports.component.item.ItemRange = ItemRange;
}

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

@ -438,6 +438,13 @@ ItemSet.prototype.toTime = function(x) {
*/
ItemSet.prototype.toScreen = function(time) {
var conversion = this.conversion;
var s = (time.valueOf() - conversion.offset) * conversion.factor;
return s;
return (time.valueOf() - conversion.offset) * conversion.factor;
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.ItemSet = ItemSet;
}

+ 8
- 0
src/component/panel.js View File

@ -99,3 +99,11 @@ Panel.prototype.reflow = function () {
return (changed > 0);
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.Panel = Panel;
}

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

@ -197,4 +197,12 @@ RootPanel.prototype._updateEventEmitters = function () {
// TODO: be able to delete event listeners
// TODO: be able to move event listeners to a parent when available
}
};
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.RootPanel = RootPanel;
}

+ 8
- 0
src/component/timeaxis.js View File

@ -522,3 +522,11 @@ TimeAxis.prototype._updateConversion = function() {
this.conversion = Range.conversion(range.start, range.end, this.width);
}
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.TimeAxis = TimeAxis;
}

+ 5
- 0
src/controller.js View File

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

+ 6
- 1
src/dataset.js View File

@ -464,7 +464,7 @@ DataSet.prototype._castItem = function (item, fieldTypes, fields) {
if (item) {
clone = {};
fieldTypes = fieldTypes || {};
if (fields) {
// output filtered fields
util.forEach(item, function (value, field) {
@ -545,3 +545,8 @@ DataSet.prototype._appendRow = function (dataTable, columns, item) {
dataTable.setValue(row, col, item[field]);
});
};
// exports
if (typeof exports !== 'undefined') {
exports.DataSet = DataSet;
}

+ 5
- 0
src/events.js View File

@ -114,3 +114,8 @@ var events = {
}
}
};
// exports
if (typeof exports !== 'undefined') {
exports.events = events;
}

+ 27
- 3
src/module.js View File

@ -1,13 +1,13 @@
/**
* load css from contents
* @param {String} css
* load css from text
* @param {String} css Text containing css
*/
var loadCss = function (css) {
// get the script location, and built the css file name from the js file name
// http://stackoverflow.com/a/2161748/1262753
var scripts = document.getElementsByTagName('script');
var jsFile = scripts[scripts.length-1].src.split('?')[0];
// var jsFile = scripts[scripts.length-1].src.split('?')[0];
// var cssFile = jsFile.substring(0, jsFile.length - 2) + 'css';
// inject css
@ -23,3 +23,27 @@ var loadCss = function (css) {
document.getElementsByTagName('head')[0].appendChild(style);
};
/**
* Define CommonJS module exports when not available
*/
if (typeof exports === 'undefined') {
var exports = {};
}
if (typeof module === 'undefined') {
var module = {
exports: exports
};
}
/**
* AMD module exports
*/
if (typeof(require) != 'undefined' && typeof(define) != 'undefined') {
define(function () {
return exports;
});
}
else {
// attach the module to the window, load as a regular javascript file
window['vis'] = exports;
}

+ 5
- 0
src/range.js View File

@ -522,3 +522,8 @@ Range.prototype.move = function(moveFactor) {
this.start = newStart;
this.end = newEnd;
};
// exports
if (typeof exports !== 'undefined') {
exports.Range = Range;
}

+ 5
- 0
src/stack.js View File

@ -155,3 +155,8 @@ Stack.prototype.collision = function(a, b, margin) {
(a.top - margin) < (b.top + b.height) &&
(a.top + a.height + margin) > b.top);
};
// exports
if (typeof exports !== 'undefined') {
exports.Stack = Stack;
}

+ 5
- 0
src/timestep.js View File

@ -448,3 +448,8 @@ TimeStep.prototype.getLabelMajor = function(date) {
default: return '';
}
};
// export
if (typeof exports !== 'undefined') {
exports.TimeStep = TimeStep;
}

+ 6
- 0
src/util.js View File

@ -761,3 +761,9 @@ if(!Array.isArray) {
return Object.prototype.toString.call(vArg) === "[object Array]";
};
}
// export
if (typeof exports !== 'undefined') {
exports.util = util;
}

+ 5
- 0
src/visualization/timeline.js View File

@ -138,3 +138,8 @@ Timeline.prototype.setData = function(data) {
this.itemset.setData(data);
}
};
// exports
if (typeof exports !== 'undefined') {
exports.Timeline = Timeline;
}

+ 181
- 29
vis.js View File

@ -23,6 +23,57 @@
* the License.
*/
(function () {
/**
* load css from text
* @param {String} css Text containing css
*/
var loadCss = function (css) {
// get the script location, and built the css file name from the js file name
// http://stackoverflow.com/a/2161748/1262753
var scripts = document.getElementsByTagName('script');
// var jsFile = scripts[scripts.length-1].src.split('?')[0];
// var cssFile = jsFile.substring(0, jsFile.length - 2) + 'css';
// inject css
// http://stackoverflow.com/questions/524696/how-to-create-a-style-tag-with-javascript
var style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
document.getElementsByTagName('head')[0].appendChild(style);
};
/**
* Define CommonJS module exports when not available
*/
if (typeof exports === 'undefined') {
var exports = {};
}
if (typeof module === 'undefined') {
var module = {
exports: exports
};
}
/**
* AMD module exports
*/
if (typeof(require) != 'undefined' && typeof(define) != 'undefined') {
define(function () {
return exports;
});
}
else {
// attach the module to the window, load as a regular javascript file
window['vis'] = exports;
}
// create namespace
var util = {};
@ -788,6 +839,12 @@ if(!Array.isArray) {
}
// export
if (typeof exports !== 'undefined') {
exports.util = util;
}
/**
* Event listener (singleton)
*/
@ -904,6 +961,11 @@ var events = {
}
};
// exports
if (typeof exports !== 'undefined') {
exports.events = events;
}
/**
* @constructor TimeStep
* The class TimeStep is an iterator for dates. You provide a start date and an
@ -1355,6 +1417,11 @@ TimeStep.prototype.getLabelMajor = function(date) {
}
};
// export
if (typeof exports !== 'undefined') {
exports.TimeStep = TimeStep;
}
/**
* DataSet
*
@ -1821,7 +1888,7 @@ DataSet.prototype._castItem = function (item, fieldTypes, fields) {
if (item) {
clone = {};
fieldTypes = fieldTypes || {};
if (fields) {
// output filtered fields
util.forEach(item, function (value, field) {
@ -1903,6 +1970,11 @@ DataSet.prototype._appendRow = function (dataTable, columns, item) {
});
};
// exports
if (typeof exports !== 'undefined') {
exports.DataSet = DataSet;
}
/**
* @constructor Stack
* Stacks items on top of each other.
@ -2061,6 +2133,11 @@ Stack.prototype.collision = function(a, b, margin) {
(a.top + a.height + margin) > b.top);
};
// exports
if (typeof exports !== 'undefined') {
exports.Stack = Stack;
}
/**
* @constructor Range
* A Range controls a numeric range with a start and end value.
@ -2586,6 +2663,11 @@ Range.prototype.move = function(moveFactor) {
this.end = newEnd;
};
// exports
if (typeof exports !== 'undefined') {
exports.Range = Range;
}
/**
* @constructor Controller
*
@ -2726,31 +2808,10 @@ Controller.prototype.reflow = function () {
// TODO: limit the number of nested reflows/repaints, prevent loop
};
/**
* load css from contents
* @param {String} css
*/
var loadCss = function (css) {
// get the script location, and built the css file name from the js file name
// http://stackoverflow.com/a/2161748/1262753
var scripts = document.getElementsByTagName('script');
var jsFile = scripts[scripts.length-1].src.split('?')[0];
// var cssFile = jsFile.substring(0, jsFile.length - 2) + 'css';
// inject css
// http://stackoverflow.com/questions/524696/how-to-create-a-style-tag-with-javascript
var style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
document.getElementsByTagName('head')[0].appendChild(style);
};
// export
if (typeof exports !== 'undefined') {
exports.Controller = Controller;
}
/**
* Prototype for visual components
@ -2869,6 +2930,14 @@ Component.prototype.on = function (event, callback) {
}
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.Component = Component;
}
/**
* A panel can contain components
* @param {Component} [parent]
@ -2971,6 +3040,14 @@ Panel.prototype.reflow = function () {
return (changed > 0);
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.Panel = Panel;
}
/**
* A root panel can hold components. The root panel must be initialized with
* a DOM element as container.
@ -3171,6 +3248,15 @@ RootPanel.prototype._updateEventEmitters = function () {
// TODO: be able to move event listeners to a parent when available
}
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.RootPanel = RootPanel;
}
/**
* A horizontal time axis
* @param {Component} parent
@ -3696,6 +3782,14 @@ TimeAxis.prototype._updateConversion = function() {
}
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.TimeAxis = TimeAxis;
}
/**
* An ItemSet holds a set of items and ranges which can be displayed in a
* range. The width is determined by the parent of the ItemSet, and the height
@ -4136,10 +4230,17 @@ ItemSet.prototype.toTime = function(x) {
*/
ItemSet.prototype.toScreen = function(time) {
var conversion = this.conversion;
var s = (time.valueOf() - conversion.offset) * conversion.factor;
return s;
return (time.valueOf() - conversion.offset) * conversion.factor;
};
// exports
if (typeof exports !== 'undefined') {
if (!('component' in exports)) {
exports.component = {};
}
exports.component.ItemSet = ItemSet;
}
/**
* @constructor Item
@ -4176,6 +4277,18 @@ Item.prototype.unselect = function () {
// 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;
}
/**
* @constructor ItemBox
* @extends Item
@ -4446,6 +4559,17 @@ 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;
}
/**
* @constructor ItemPoint
* @extends Item
@ -4656,6 +4780,17 @@ 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;
}
/**
* @constructor ItemRange
* @extends Item
@ -4876,6 +5011,17 @@ 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;
}
/**
* Create a timeline visualization
* @param {HTMLElement} container
@ -5017,6 +5163,11 @@ Timeline.prototype.setData = function(data) {
}
};
// exports
if (typeof exports !== 'undefined') {
exports.Timeline = Timeline;
}
// moment.js
// version : 2.0.0
// author : Tim Wood
@ -6418,4 +6569,5 @@ Timeline.prototype.setData = function(data) {
}
}).call(this);
loadCss("/* vis.js stylesheet */\n\n.graph {\n position: relative;\n border: 1px solid #bfbfbf;\n}\n\n.graph .panel {\n position: absolute;\n}\n\n.graph .itemset {\n position: absolute;\n}\n\n\n.graph .item {\n position: absolute;\n color: #1A1A1A;\n border-color: #97B0F8;\n background-color: #D5DDF6;\n display: inline-block;\n}\n\n.graph .item.selected {\n border-color: #FFC200;\n background-color: #FFF785;\n z-index: 999;\n}\n\n.graph .item.cluster {\n /* TODO: use another color or pattern? */\n background: #97B0F8 url('img/cluster_bg.png');\n color: white;\n}\n.graph .item.cluster.point {\n border-color: #D5DDF6;\n}\n\n.graph .item.box {\n text-align: center;\n border-style: solid;\n border-width: 1px;\n border-radius: 5px;\n -moz-border-radius: 5px; /* For Firefox 3.6 and older */\n}\n\n.graph .item.point {\n background: none;\n}\n\n.graph .dot {\n border: 5px solid #97B0F8;\n position: absolute;\n border-radius: 5px;\n -moz-border-radius: 5px; /* For Firefox 3.6 and older */\n}\n\n.graph .item.range {\n overflow: hidden;\n border-style: solid;\n border-width: 1px;\n border-radius: 2px;\n -moz-border-radius: 2px; /* For Firefox 3.6 and older */\n}\n\n.graph .item.range .drag-left {\n cursor: w-resize;\n z-index: 1000;\n}\n\n.graph .item.range .drag-right {\n cursor: e-resize;\n z-index: 1000;\n}\n\n.graph .item.range .content {\n position: relative;\n display: inline-block;\n}\n\n.graph .item.line {\n position: absolute;\n width: 0;\n border-left-width: 1px;\n border-left-style: solid;\n z-index: -1;\n}\n\n.graph .item .content {\n margin: 5px;\n white-space: nowrap;\n overflow: hidden;\n}\n\n/* TODO: better css name, 'graph' is way to generic */\n\n.graph {\n overflow: hidden;\n}\n\n.graph .axis {\n position: relative;\n}\n\n.graph .axis .text {\n position: absolute;\n color: #4d4d4d;\n padding: 3px;\n white-space: nowrap;\n}\n\n.graph .axis .text.measure {\n position: absolute;\n padding-left: 0;\n padding-right: 0;\n margin-left: 0;\n margin-right: 0;\n visibility: hidden;\n}\n\n.graph .axis .grid.vertical {\n position: absolute;\n width: 0;\n border-right: 1px solid;\n}\n\n.graph .axis .grid.horizontal {\n position: absolute;\n left: 0;\n width: 100%;\n height: 0;\n border-bottom: 1px solid;\n}\n\n.graph .axis .grid.minor {\n border-color: #e5e5e5;\n}\n\n.graph .axis .grid.major {\n border-color: #bfbfbf;\n}\n\n");
loadCss("/* vis.js stylesheet */\n\n.graph {\n position: relative;\n border: 1px solid #bfbfbf;\n}\n\n.graph .panel {\n position: absolute;\n}\n\n.graph .itemset {\n position: absolute;\n}\n\n\n.graph .item {\n position: absolute;\n color: #1A1A1A;\n border-color: #97B0F8;\n background-color: #D5DDF6;\n display: inline-block;\n}\n\n.graph .item.selected {\n border-color: #FFC200;\n background-color: #FFF785;\n z-index: 999;\n}\n\n.graph .item.cluster {\n /* TODO: use another color or pattern? */\n background: #97B0F8 url('img/cluster_bg.png');\n color: white;\n}\n.graph .item.cluster.point {\n border-color: #D5DDF6;\n}\n\n.graph .item.box {\n text-align: center;\n border-style: solid;\n border-width: 1px;\n border-radius: 5px;\n -moz-border-radius: 5px; /* For Firefox 3.6 and older */\n}\n\n.graph .item.point {\n background: none;\n}\n\n.graph .dot {\n border: 5px solid #97B0F8;\n position: absolute;\n border-radius: 5px;\n -moz-border-radius: 5px; /* For Firefox 3.6 and older */\n}\n\n.graph .item.range {\n overflow: hidden;\n border-style: solid;\n border-width: 1px;\n border-radius: 2px;\n -moz-border-radius: 2px; /* For Firefox 3.6 and older */\n}\n\n.graph .item.range .drag-left {\n cursor: w-resize;\n z-index: 1000;\n}\n\n.graph .item.range .drag-right {\n cursor: e-resize;\n z-index: 1000;\n}\n\n.graph .item.range .content {\n position: relative;\n display: inline-block;\n}\n\n.graph .item.line {\n position: absolute;\n width: 0;\n border-left-width: 1px;\n border-left-style: solid;\n z-index: -1;\n}\n\n.graph .item .content {\n margin: 5px;\n white-space: nowrap;\n overflow: hidden;\n}\n\n/* TODO: better css name, 'graph' is way to generic */\n\n.graph {\n overflow: hidden;\n}\n\n.graph .axis {\n position: relative;\n}\n\n.graph .axis .text {\n position: absolute;\n color: #4d4d4d;\n padding: 3px;\n white-space: nowrap;\n}\n\n.graph .axis .text.measure {\n position: absolute;\n padding-left: 0;\n padding-right: 0;\n margin-left: 0;\n margin-right: 0;\n visibility: hidden;\n}\n\n.graph .axis .grid.vertical {\n position: absolute;\n width: 0;\n border-right: 1px solid;\n}\n\n.graph .axis .grid.horizontal {\n position: absolute;\n left: 0;\n width: 100%;\n height: 0;\n border-bottom: 1px solid;\n}\n\n.graph .axis .grid.minor {\n border-color: #e5e5e5;\n}\n\n.graph .axis .grid.major {\n border-color: #bfbfbf;\n}\n\n");
})();

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


Loading…
Cancel
Save