vis-rails 0.0.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vis/rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/vis.js +2 -9
  4. data/vendor/assets/vis/DataSet.js +17 -9
  5. data/vendor/assets/vis/graph/Edge.js +49 -24
  6. data/vendor/assets/vis/graph/Graph.js +268 -64
  7. data/vendor/assets/vis/graph/Groups.js +1 -1
  8. data/vendor/assets/vis/graph/Node.js +18 -67
  9. data/vendor/assets/vis/graph/Popup.js +40 -13
  10. data/vendor/assets/vis/graph/css/graph-navigation.css +18 -14
  11. data/vendor/assets/vis/graph/graphMixins/ClusterMixin.js +7 -5
  12. data/vendor/assets/vis/graph/graphMixins/HierarchicalLayoutMixin.js +20 -5
  13. data/vendor/assets/vis/graph/graphMixins/ManipulationMixin.js +33 -33
  14. data/vendor/assets/vis/graph/graphMixins/MixinLoader.js +30 -32
  15. data/vendor/assets/vis/graph/graphMixins/NavigationMixin.js +33 -1
  16. data/vendor/assets/vis/graph/graphMixins/SectorsMixin.js +2 -2
  17. data/vendor/assets/vis/graph/graphMixins/SelectionMixin.js +72 -60
  18. data/vendor/assets/vis/graph/graphMixins/physics/BarnesHut.js +43 -18
  19. data/vendor/assets/vis/graph/graphMixins/physics/HierarchialRepulsion.js +8 -8
  20. data/vendor/assets/vis/graph/graphMixins/physics/PhysicsMixin.js +309 -129
  21. data/vendor/assets/vis/graph/graphMixins/physics/Repulsion.js +10 -10
  22. data/vendor/assets/vis/module/exports.js +1 -2
  23. data/vendor/assets/vis/module/header.js +2 -2
  24. data/vendor/assets/vis/timeline/Range.js +53 -93
  25. data/vendor/assets/vis/timeline/Timeline.js +328 -224
  26. data/vendor/assets/vis/timeline/component/Component.js +17 -95
  27. data/vendor/assets/vis/timeline/component/CurrentTime.js +54 -59
  28. data/vendor/assets/vis/timeline/component/CustomTime.js +55 -83
  29. data/vendor/assets/vis/timeline/component/Group.js +398 -75
  30. data/vendor/assets/vis/timeline/component/ItemSet.js +662 -403
  31. data/vendor/assets/vis/timeline/component/Panel.js +118 -60
  32. data/vendor/assets/vis/timeline/component/RootPanel.js +80 -132
  33. data/vendor/assets/vis/timeline/component/TimeAxis.js +191 -277
  34. data/vendor/assets/vis/timeline/component/css/item.css +16 -23
  35. data/vendor/assets/vis/timeline/component/css/itemset.css +25 -4
  36. data/vendor/assets/vis/timeline/component/css/labelset.css +34 -0
  37. data/vendor/assets/vis/timeline/component/css/panel.css +15 -1
  38. data/vendor/assets/vis/timeline/component/css/timeaxis.css +8 -8
  39. data/vendor/assets/vis/timeline/component/item/Item.js +48 -26
  40. data/vendor/assets/vis/timeline/component/item/ItemBox.js +156 -230
  41. data/vendor/assets/vis/timeline/component/item/ItemPoint.js +118 -166
  42. data/vendor/assets/vis/timeline/component/item/ItemRange.js +135 -187
  43. data/vendor/assets/vis/timeline/component/item/ItemRangeOverflow.js +29 -92
  44. data/vendor/assets/vis/timeline/stack.js +112 -0
  45. data/vendor/assets/vis/util.js +136 -38
  46. metadata +4 -18
  47. data/vendor/assets/vis/.gitignore +0 -1
  48. data/vendor/assets/vis/EventBus.js +0 -89
  49. data/vendor/assets/vis/events.js +0 -116
  50. data/vendor/assets/vis/graph/ClusterMixin.js +0 -1019
  51. data/vendor/assets/vis/graph/NavigationMixin.js +0 -245
  52. data/vendor/assets/vis/graph/SectorsMixin.js +0 -547
  53. data/vendor/assets/vis/graph/SelectionMixin.js +0 -515
  54. data/vendor/assets/vis/graph/img/downarrow.png +0 -0
  55. data/vendor/assets/vis/graph/img/leftarrow.png +0 -0
  56. data/vendor/assets/vis/graph/img/rightarrow.png +0 -0
  57. data/vendor/assets/vis/graph/img/uparrow.png +0 -0
  58. data/vendor/assets/vis/timeline/Controller.js +0 -183
  59. data/vendor/assets/vis/timeline/Stack.js +0 -190
  60. data/vendor/assets/vis/timeline/component/ContentPanel.js +0 -113
  61. data/vendor/assets/vis/timeline/component/GroupSet.js +0 -580
  62. data/vendor/assets/vis/timeline/component/css/groupset.css +0 -59
@@ -1,580 +0,0 @@
1
- /**
2
- * An GroupSet holds a set of groups
3
- * @param {Component} parent
4
- * @param {Component[]} [depends] Components on which this components depends
5
- * (except for the parent)
6
- * @param {Object} [options] See GroupSet.setOptions for the available
7
- * options.
8
- * @constructor GroupSet
9
- * @extends Panel
10
- */
11
- function GroupSet(parent, depends, options) {
12
- this.id = util.randomUUID();
13
- this.parent = parent;
14
- this.depends = depends;
15
-
16
- this.options = options || {};
17
-
18
- this.range = null; // Range or Object {start: number, end: number}
19
- this.itemsData = null; // DataSet with items
20
- this.groupsData = null; // DataSet with groups
21
-
22
- this.groups = {}; // map with groups
23
-
24
- this.dom = {};
25
- this.props = {
26
- labels: {
27
- width: 0
28
- }
29
- };
30
-
31
- // TODO: implement right orientation of the labels
32
-
33
- // changes in groups are queued key/value map containing id/action
34
- this.queue = {};
35
-
36
- var me = this;
37
- this.listeners = {
38
- 'add': function (event, params) {
39
- me._onAdd(params.items);
40
- },
41
- 'update': function (event, params) {
42
- me._onUpdate(params.items);
43
- },
44
- 'remove': function (event, params) {
45
- me._onRemove(params.items);
46
- }
47
- };
48
- }
49
-
50
- GroupSet.prototype = new Panel();
51
-
52
- /**
53
- * Set options for the GroupSet. Existing options will be extended/overwritten.
54
- * @param {Object} [options] The following options are available:
55
- * {String | function} groupsOrder
56
- * TODO: describe options
57
- */
58
- GroupSet.prototype.setOptions = Component.prototype.setOptions;
59
-
60
- GroupSet.prototype.setRange = function (range) {
61
- // TODO: implement setRange
62
- };
63
-
64
- /**
65
- * Set items
66
- * @param {vis.DataSet | null} items
67
- */
68
- GroupSet.prototype.setItems = function setItems(items) {
69
- this.itemsData = items;
70
-
71
- for (var id in this.groups) {
72
- if (this.groups.hasOwnProperty(id)) {
73
- var group = this.groups[id];
74
- group.setItems(items);
75
- }
76
- }
77
- };
78
-
79
- /**
80
- * Get items
81
- * @return {vis.DataSet | null} items
82
- */
83
- GroupSet.prototype.getItems = function getItems() {
84
- return this.itemsData;
85
- };
86
-
87
- /**
88
- * Set range (start and end).
89
- * @param {Range | Object} range A Range or an object containing start and end.
90
- */
91
- GroupSet.prototype.setRange = function setRange(range) {
92
- this.range = range;
93
- };
94
-
95
- /**
96
- * Set groups
97
- * @param {vis.DataSet} groups
98
- */
99
- GroupSet.prototype.setGroups = function setGroups(groups) {
100
- var me = this,
101
- ids;
102
-
103
- // unsubscribe from current dataset
104
- if (this.groupsData) {
105
- util.forEach(this.listeners, function (callback, event) {
106
- me.groupsData.unsubscribe(event, callback);
107
- });
108
-
109
- // remove all drawn groups
110
- ids = this.groupsData.getIds();
111
- this._onRemove(ids);
112
- }
113
-
114
- // replace the dataset
115
- if (!groups) {
116
- this.groupsData = null;
117
- }
118
- else if (groups instanceof DataSet) {
119
- this.groupsData = groups;
120
- }
121
- else {
122
- this.groupsData = new DataSet({
123
- convert: {
124
- start: 'Date',
125
- end: 'Date'
126
- }
127
- });
128
- this.groupsData.add(groups);
129
- }
130
-
131
- if (this.groupsData) {
132
- // subscribe to new dataset
133
- var id = this.id;
134
- util.forEach(this.listeners, function (callback, event) {
135
- me.groupsData.on(event, callback, id);
136
- });
137
-
138
- // draw all new groups
139
- ids = this.groupsData.getIds();
140
- this._onAdd(ids);
141
- }
142
- };
143
-
144
- /**
145
- * Get groups
146
- * @return {vis.DataSet | null} groups
147
- */
148
- GroupSet.prototype.getGroups = function getGroups() {
149
- return this.groupsData;
150
- };
151
-
152
- /**
153
- * Set selected items by their id. Replaces the current selection.
154
- * Unknown id's are silently ignored.
155
- * @param {Array} [ids] An array with zero or more id's of the items to be
156
- * selected. If ids is an empty array, all items will be
157
- * unselected.
158
- */
159
- GroupSet.prototype.setSelection = function setSelection(ids) {
160
- var selection = [],
161
- groups = this.groups;
162
-
163
- // iterate over each of the groups
164
- for (var id in groups) {
165
- if (groups.hasOwnProperty(id)) {
166
- var group = groups[id];
167
- group.setSelection(ids);
168
- }
169
- }
170
-
171
- return selection;
172
- };
173
-
174
- /**
175
- * Get the selected items by their id
176
- * @return {Array} ids The ids of the selected items
177
- */
178
- GroupSet.prototype.getSelection = function getSelection() {
179
- var selection = [],
180
- groups = this.groups;
181
-
182
- // iterate over each of the groups
183
- for (var id in groups) {
184
- if (groups.hasOwnProperty(id)) {
185
- var group = groups[id];
186
- selection = selection.concat(group.getSelection());
187
- }
188
- }
189
-
190
- return selection;
191
- };
192
-
193
- /**
194
- * Repaint the component
195
- * @return {Boolean} changed
196
- */
197
- GroupSet.prototype.repaint = function repaint() {
198
- var changed = 0,
199
- i, id, group, label,
200
- update = util.updateProperty,
201
- asSize = util.option.asSize,
202
- asElement = util.option.asElement,
203
- options = this.options,
204
- frame = this.dom.frame,
205
- labels = this.dom.labels,
206
- labelSet = this.dom.labelSet;
207
-
208
- // create frame
209
- if (!this.parent) {
210
- throw new Error('Cannot repaint groupset: no parent attached');
211
- }
212
- var parentContainer = this.parent.getContainer();
213
- if (!parentContainer) {
214
- throw new Error('Cannot repaint groupset: parent has no container element');
215
- }
216
- if (!frame) {
217
- frame = document.createElement('div');
218
- frame.className = 'groupset';
219
- frame['timeline-groupset'] = this;
220
- this.dom.frame = frame;
221
-
222
- var className = options.className;
223
- if (className) {
224
- util.addClassName(frame, util.option.asString(className));
225
- }
226
-
227
- changed += 1;
228
- }
229
- if (!frame.parentNode) {
230
- parentContainer.appendChild(frame);
231
- changed += 1;
232
- }
233
-
234
- // create labels
235
- var labelContainer = asElement(options.labelContainer);
236
- if (!labelContainer) {
237
- throw new Error('Cannot repaint groupset: option "labelContainer" not defined');
238
- }
239
- if (!labels) {
240
- labels = document.createElement('div');
241
- labels.className = 'labels';
242
- this.dom.labels = labels;
243
- }
244
- if (!labelSet) {
245
- labelSet = document.createElement('div');
246
- labelSet.className = 'label-set';
247
- labels.appendChild(labelSet);
248
- this.dom.labelSet = labelSet;
249
- }
250
- if (!labels.parentNode || labels.parentNode != labelContainer) {
251
- if (labels.parentNode) {
252
- labels.parentNode.removeChild(labels.parentNode);
253
- }
254
- labelContainer.appendChild(labels);
255
- }
256
-
257
- // reposition frame
258
- changed += update(frame.style, 'height', asSize(options.height, this.height + 'px'));
259
- changed += update(frame.style, 'top', asSize(options.top, '0px'));
260
- changed += update(frame.style, 'left', asSize(options.left, '0px'));
261
- changed += update(frame.style, 'width', asSize(options.width, '100%'));
262
-
263
- // reposition labels
264
- changed += update(labelSet.style, 'top', asSize(options.top, '0px'));
265
- changed += update(labelSet.style, 'height', asSize(options.height, this.height + 'px'));
266
-
267
- var me = this,
268
- queue = this.queue,
269
- groups = this.groups,
270
- groupsData = this.groupsData;
271
-
272
- // show/hide added/changed/removed groups
273
- var ids = Object.keys(queue);
274
- if (ids.length) {
275
- ids.forEach(function (id) {
276
- var action = queue[id];
277
- var group = groups[id];
278
-
279
- //noinspection FallthroughInSwitchStatementJS
280
- switch (action) {
281
- case 'add':
282
- case 'update':
283
- if (!group) {
284
- var groupOptions = Object.create(me.options);
285
- util.extend(groupOptions, {
286
- height: null,
287
- maxHeight: null
288
- });
289
-
290
- group = new Group(me, id, groupOptions);
291
- group.setItems(me.itemsData); // attach items data
292
- groups[id] = group;
293
-
294
- me.controller.add(group);
295
- }
296
-
297
- // TODO: update group data
298
- group.data = groupsData.get(id);
299
-
300
- delete queue[id];
301
- break;
302
-
303
- case 'remove':
304
- if (group) {
305
- group.setItems(); // detach items data
306
- delete groups[id];
307
-
308
- me.controller.remove(group);
309
- }
310
-
311
- // update lists
312
- delete queue[id];
313
- break;
314
-
315
- default:
316
- console.log('Error: unknown action "' + action + '"');
317
- }
318
- });
319
-
320
- // the groupset depends on each of the groups
321
- //this.depends = this.groups; // TODO: gives a circular reference through the parent
322
-
323
- // TODO: apply dependencies of the groupset
324
-
325
- // update the top positions of the groups in the correct order
326
- var orderedGroups = this.groupsData.getIds({
327
- order: this.options.groupOrder
328
- });
329
- for (i = 0; i < orderedGroups.length; i++) {
330
- (function (group, prevGroup) {
331
- var top = 0;
332
- if (prevGroup) {
333
- top = function () {
334
- // TODO: top must reckon with options.maxHeight
335
- return prevGroup.top + prevGroup.height;
336
- }
337
- }
338
- group.setOptions({
339
- top: top
340
- });
341
- })(groups[orderedGroups[i]], groups[orderedGroups[i - 1]]);
342
- }
343
-
344
- // (re)create the labels
345
- while (labelSet.firstChild) {
346
- labelSet.removeChild(labelSet.firstChild);
347
- }
348
- for (i = 0; i < orderedGroups.length; i++) {
349
- id = orderedGroups[i];
350
- label = this._createLabel(id);
351
- labelSet.appendChild(label);
352
- }
353
-
354
- changed++;
355
- }
356
-
357
- // reposition the labels
358
- // TODO: labels are not displayed correctly when orientation=='top'
359
- // TODO: width of labelPanel is not immediately updated on a change in groups
360
- for (id in groups) {
361
- if (groups.hasOwnProperty(id)) {
362
- group = groups[id];
363
- label = group.label;
364
- if (label) {
365
- label.style.top = group.top + 'px';
366
- label.style.height = group.height + 'px';
367
- }
368
- }
369
- }
370
-
371
- return (changed > 0);
372
- };
373
-
374
- /**
375
- * Create a label for group with given id
376
- * @param {Number} id
377
- * @return {Element} label
378
- * @private
379
- */
380
- GroupSet.prototype._createLabel = function(id) {
381
- var group = this.groups[id];
382
- var label = document.createElement('div');
383
- label.className = 'vlabel';
384
- var inner = document.createElement('div');
385
- inner.className = 'inner';
386
- label.appendChild(inner);
387
-
388
- var content = group.data && group.data.content;
389
- if (content instanceof Element) {
390
- inner.appendChild(content);
391
- }
392
- else if (content != undefined) {
393
- inner.innerHTML = content;
394
- }
395
-
396
- var className = group.data && group.data.className;
397
- if (className) {
398
- util.addClassName(label, className);
399
- }
400
-
401
- group.label = label; // TODO: not so nice, parking labels in the group this way!!!
402
-
403
- return label;
404
- };
405
-
406
- /**
407
- * Get container element
408
- * @return {HTMLElement} container
409
- */
410
- GroupSet.prototype.getContainer = function getContainer() {
411
- return this.dom.frame;
412
- };
413
-
414
- /**
415
- * Get the width of the group labels
416
- * @return {Number} width
417
- */
418
- GroupSet.prototype.getLabelsWidth = function getContainer() {
419
- return this.props.labels.width;
420
- };
421
-
422
- /**
423
- * Reflow the component
424
- * @return {Boolean} resized
425
- */
426
- GroupSet.prototype.reflow = function reflow() {
427
- var changed = 0,
428
- id, group,
429
- options = this.options,
430
- update = util.updateProperty,
431
- asNumber = util.option.asNumber,
432
- asSize = util.option.asSize,
433
- frame = this.dom.frame;
434
-
435
- if (frame) {
436
- var maxHeight = asNumber(options.maxHeight);
437
- var fixedHeight = (asSize(options.height) != null);
438
- var height;
439
- if (fixedHeight) {
440
- height = frame.offsetHeight;
441
- }
442
- else {
443
- // height is not specified, calculate the sum of the height of all groups
444
- height = 0;
445
-
446
- for (id in this.groups) {
447
- if (this.groups.hasOwnProperty(id)) {
448
- group = this.groups[id];
449
- height += group.height;
450
- }
451
- }
452
- }
453
- if (maxHeight != null) {
454
- height = Math.min(height, maxHeight);
455
- }
456
- changed += update(this, 'height', height);
457
-
458
- changed += update(this, 'top', frame.offsetTop);
459
- changed += update(this, 'left', frame.offsetLeft);
460
- changed += update(this, 'width', frame.offsetWidth);
461
- }
462
-
463
- // calculate the maximum width of the labels
464
- var width = 0;
465
- for (id in this.groups) {
466
- if (this.groups.hasOwnProperty(id)) {
467
- group = this.groups[id];
468
- var labelWidth = group.props && group.props.label && group.props.label.width || 0;
469
- width = Math.max(width, labelWidth);
470
- }
471
- }
472
- changed += update(this.props.labels, 'width', width);
473
-
474
- return (changed > 0);
475
- };
476
-
477
- /**
478
- * Hide the component from the DOM
479
- * @return {Boolean} changed
480
- */
481
- GroupSet.prototype.hide = function hide() {
482
- if (this.dom.frame && this.dom.frame.parentNode) {
483
- this.dom.frame.parentNode.removeChild(this.dom.frame);
484
- return true;
485
- }
486
- else {
487
- return false;
488
- }
489
- };
490
-
491
- /**
492
- * Show the component in the DOM (when not already visible).
493
- * A repaint will be executed when the component is not visible
494
- * @return {Boolean} changed
495
- */
496
- GroupSet.prototype.show = function show() {
497
- if (!this.dom.frame || !this.dom.frame.parentNode) {
498
- return this.repaint();
499
- }
500
- else {
501
- return false;
502
- }
503
- };
504
-
505
- /**
506
- * Handle updated groups
507
- * @param {Number[]} ids
508
- * @private
509
- */
510
- GroupSet.prototype._onUpdate = function _onUpdate(ids) {
511
- this._toQueue(ids, 'update');
512
- };
513
-
514
- /**
515
- * Handle changed groups
516
- * @param {Number[]} ids
517
- * @private
518
- */
519
- GroupSet.prototype._onAdd = function _onAdd(ids) {
520
- this._toQueue(ids, 'add');
521
- };
522
-
523
- /**
524
- * Handle removed groups
525
- * @param {Number[]} ids
526
- * @private
527
- */
528
- GroupSet.prototype._onRemove = function _onRemove(ids) {
529
- this._toQueue(ids, 'remove');
530
- };
531
-
532
- /**
533
- * Put groups in the queue to be added/updated/remove
534
- * @param {Number[]} ids
535
- * @param {String} action can be 'add', 'update', 'remove'
536
- */
537
- GroupSet.prototype._toQueue = function _toQueue(ids, action) {
538
- var queue = this.queue;
539
- ids.forEach(function (id) {
540
- queue[id] = action;
541
- });
542
-
543
- if (this.controller) {
544
- //this.requestReflow();
545
- this.requestRepaint();
546
- }
547
- };
548
-
549
- /**
550
- * Find the Group from an event target:
551
- * searches for the attribute 'timeline-groupset' in the event target's element
552
- * tree, then finds the right group in this groupset
553
- * @param {Event} event
554
- * @return {Group | null} group
555
- */
556
- GroupSet.groupFromTarget = function groupFromTarget (event) {
557
- var groupset,
558
- target = event.target;
559
-
560
- while (target) {
561
- if (target.hasOwnProperty('timeline-groupset')) {
562
- groupset = target['timeline-groupset'];
563
- break;
564
- }
565
- target = target.parentNode;
566
- }
567
-
568
- if (groupset) {
569
- for (var groupId in groupset.groups) {
570
- if (groupset.groups.hasOwnProperty(groupId)) {
571
- var group = groupset.groups[groupId];
572
- if (group.itemset && ItemSet.itemSetFromTarget(event) == group.itemset) {
573
- return group;
574
- }
575
- }
576
- }
577
- }
578
-
579
- return null;
580
- };