Browse Source

Timeline and Graph2d now extend Core instead of loading it mixin wise

v3_develop
jos 10 years ago
parent
commit
a2c9433601
2 changed files with 9 additions and 14 deletions
  1. +4
    -6
      lib/timeline/Graph2d.js
  2. +5
    -8
      lib/timeline/Timeline.js

+ 4
- 6
lib/timeline/Graph2d.js View File

@ -16,14 +16,9 @@ var LineGraph = require('./component/LineGraph');
* @param {vis.DataSet | Array | google.visualization.DataTable} [items] * @param {vis.DataSet | Array | google.visualization.DataTable} [items]
* @param {Object} [options] See Graph2d.setOptions for the available options. * @param {Object} [options] See Graph2d.setOptions for the available options.
* @constructor * @constructor
* @extends Core
*/ */
function Graph2d (container, items, options, groups) { function Graph2d (container, items, options, groups) {
for (var coreProp in Core.prototype) {
if (Core.prototype.hasOwnProperty(coreProp) && !Graph2d.prototype.hasOwnProperty(coreProp)) {
Graph2d.prototype[coreProp] = Core.prototype[coreProp];
}
}
var me = this; var me = this;
this.defaultOptions = { this.defaultOptions = {
start: null, start: null,
@ -107,6 +102,9 @@ function Graph2d (container, items, options, groups) {
} }
} }
// Extend the functionality from Core
Graph2d.prototype = new Core();
/** /**
* Set options. Options will be passed to all components loaded in the Graph2d. * Set options. Options will be passed to all components loaded in the Graph2d.
* @param {Object} [options] * @param {Object} [options]

+ 5
- 8
lib/timeline/Timeline.js View File

@ -16,15 +16,9 @@ var ItemSet = require('./component/ItemSet');
* @param {vis.DataSet | Array | google.visualization.DataTable} [items] * @param {vis.DataSet | Array | google.visualization.DataTable} [items]
* @param {Object} [options] See Timeline.setOptions for the available options. * @param {Object} [options] See Timeline.setOptions for the available options.
* @constructor * @constructor
* @extends Core
*/ */
function Timeline (container, items, options) { function Timeline (container, items, options) {
// mix the core properties in here
for (var coreProp in Core.prototype) {
if (Core.prototype.hasOwnProperty(coreProp) && !Timeline.prototype.hasOwnProperty(coreProp)) {
Timeline.prototype[coreProp] = Core.prototype[coreProp];
}
}
if (!(this instanceof Timeline)) { if (!(this instanceof Timeline)) {
throw new SyntaxError('Constructor must be called with the new operator'); throw new SyntaxError('Constructor must be called with the new operator');
} }
@ -107,6 +101,9 @@ function Timeline (container, items, options) {
} }
} }
// Extend the functionality from Core
Timeline.prototype = new Core();
/** /**
* Set options. Options will be passed to all components loaded in the Timeline. * Set options. Options will be passed to all components loaded in the Timeline.
* @param {Object} [options] * @param {Object} [options]
@ -135,7 +132,7 @@ function Timeline (container, items, options) {
Timeline.prototype.setOptions = function (options) { Timeline.prototype.setOptions = function (options) {
if (options) { if (options) {
// copy the known options // copy the known options
var fields = ['width', 'height', 'minHeight', 'maxHeight', 'autoResize', 'start', 'end', 'orientation'];
var fields = ['width', 'height', 'minHeight', 'maxHeight', 'autoResize', 'start', 'end', 'orientation', 'activatable'];
util.selectiveExtend(fields, this.options, options); util.selectiveExtend(fields, this.options, options);
// enable/disable autoResize // enable/disable autoResize

Loading…
Cancel
Save