vis-rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +5 -13
  2. data/lib/vis/rails/version.rb +1 -1
  3. data/vendor/assets/component/emitter.js +162 -0
  4. data/vendor/assets/javascripts/vis.js +1 -0
  5. data/vendor/assets/vis/DataSet.js +8 -2
  6. data/vendor/assets/vis/DataView.js +8 -4
  7. data/vendor/assets/vis/graph/Edge.js +210 -78
  8. data/vendor/assets/vis/graph/Graph.js +474 -652
  9. data/vendor/assets/vis/graph/Node.js +119 -82
  10. data/vendor/assets/vis/graph/css/graph-manipulation.css +128 -0
  11. data/vendor/assets/vis/graph/css/graph-navigation.css +62 -0
  12. data/vendor/assets/vis/graph/graphMixins/ClusterMixin.js +1141 -0
  13. data/vendor/assets/vis/graph/graphMixins/HierarchicalLayoutMixin.js +296 -0
  14. data/vendor/assets/vis/graph/graphMixins/ManipulationMixin.js +433 -0
  15. data/vendor/assets/vis/graph/graphMixins/MixinLoader.js +201 -0
  16. data/vendor/assets/vis/graph/graphMixins/NavigationMixin.js +173 -0
  17. data/vendor/assets/vis/graph/graphMixins/SectorsMixin.js +552 -0
  18. data/vendor/assets/vis/graph/graphMixins/SelectionMixin.js +558 -0
  19. data/vendor/assets/vis/graph/graphMixins/physics/BarnesHut.js +373 -0
  20. data/vendor/assets/vis/graph/graphMixins/physics/HierarchialRepulsion.js +64 -0
  21. data/vendor/assets/vis/graph/graphMixins/physics/PhysicsMixin.js +513 -0
  22. data/vendor/assets/vis/graph/graphMixins/physics/Repulsion.js +66 -0
  23. data/vendor/assets/vis/graph/img/acceptDeleteIcon.png +0 -0
  24. data/vendor/assets/vis/graph/img/addNodeIcon.png +0 -0
  25. data/vendor/assets/vis/graph/img/backIcon.png +0 -0
  26. data/vendor/assets/vis/graph/img/connectIcon.png +0 -0
  27. data/vendor/assets/vis/graph/img/cross.png +0 -0
  28. data/vendor/assets/vis/graph/img/cross2.png +0 -0
  29. data/vendor/assets/vis/graph/img/deleteIcon.png +0 -0
  30. data/vendor/assets/vis/graph/img/downArrow.png +0 -0
  31. data/vendor/assets/vis/graph/img/editIcon.png +0 -0
  32. data/vendor/assets/vis/graph/img/leftArrow.png +0 -0
  33. data/vendor/assets/vis/graph/img/rightArrow.png +0 -0
  34. data/vendor/assets/vis/graph/img/upArrow.png +0 -0
  35. data/vendor/assets/vis/module/exports.js +0 -2
  36. data/vendor/assets/vis/module/header.js +2 -2
  37. data/vendor/assets/vis/module/imports.js +1 -2
  38. data/vendor/assets/vis/timeline/Controller.js +56 -45
  39. data/vendor/assets/vis/timeline/Range.js +68 -62
  40. data/vendor/assets/vis/timeline/Stack.js +11 -13
  41. data/vendor/assets/vis/timeline/TimeStep.js +43 -38
  42. data/vendor/assets/vis/timeline/Timeline.js +215 -93
  43. data/vendor/assets/vis/timeline/component/Component.js +19 -3
  44. data/vendor/assets/vis/timeline/component/CurrentTime.js +1 -1
  45. data/vendor/assets/vis/timeline/component/CustomTime.js +39 -120
  46. data/vendor/assets/vis/timeline/component/GroupSet.js +35 -1
  47. data/vendor/assets/vis/timeline/component/ItemSet.js +272 -9
  48. data/vendor/assets/vis/timeline/component/RootPanel.js +59 -47
  49. data/vendor/assets/vis/timeline/component/TimeAxis.js +10 -0
  50. data/vendor/assets/vis/timeline/component/css/item.css +53 -22
  51. data/vendor/assets/vis/timeline/component/item/Item.js +40 -5
  52. data/vendor/assets/vis/timeline/component/item/ItemBox.js +3 -1
  53. data/vendor/assets/vis/timeline/component/item/ItemPoint.js +3 -1
  54. data/vendor/assets/vis/timeline/component/item/ItemRange.js +67 -3
  55. data/vendor/assets/vis/timeline/component/item/ItemRangeOverflow.js +37 -9
  56. data/vendor/assets/vis/timeline/img/delete.png +0 -0
  57. data/vendor/assets/vis/util.js +169 -30
  58. metadata +39 -12
@@ -16,6 +16,22 @@ function ItemRangeOverflow (parent, data, options, defaultOptions) {
16
16
  }
17
17
  };
18
18
 
19
+ // define a private property _width, which is the with of the range box
20
+ // adhering to the ranges start and end date. The property width has a
21
+ // getter which returns the max of border width and content width
22
+ this._width = 0;
23
+ Object.defineProperty(this, 'width', {
24
+ get: function () {
25
+ return (this.props.content && this._width < this.props.content.width) ?
26
+ this.props.content.width :
27
+ this._width;
28
+ },
29
+
30
+ set: function (width) {
31
+ this._width = width;
32
+ }
33
+ });
34
+
19
35
  ItemRange.call(this, parent, data, options, defaultOptions);
20
36
  }
21
37
 
@@ -62,13 +78,18 @@ ItemRangeOverflow.prototype.repaint = function repaint() {
62
78
  dom.content.innerHTML = this.content;
63
79
  }
64
80
  else {
65
- throw new Error('Property "content" missing in item ' + this.data.id);
81
+ throw new Error('Property "content" missing in item ' + this.id);
66
82
  }
67
83
  changed = true;
68
84
  }
69
85
 
86
+ this._repaintDeleteButton(dom.box);
87
+ this._repaintDragLeft();
88
+ this._repaintDragRight();
89
+
70
90
  // update class
71
- var className = this.data.className ? (' ' + this.data.className) : '';
91
+ var className = (this.data.className? ' ' + this.data.className : '') +
92
+ (this.selected ? ' selected' : '');
72
93
  if (this.className != className) {
73
94
  this.className = className;
74
95
  dom.box.className = 'item rangeoverflow' + className;
@@ -80,12 +101,19 @@ ItemRangeOverflow.prototype.repaint = function repaint() {
80
101
  };
81
102
 
82
103
  /**
83
- * Return the items width
84
- * @return {Number} width
104
+ * Reposition the item, recalculate its left, top, and width, using the current
105
+ * range and size of the items itemset
106
+ * @override
85
107
  */
86
- ItemRangeOverflow.prototype.getWidth = function getWidth() {
87
- if (this.props.content !== undefined && this.width < this.props.content.width)
88
- return this.props.content.width;
89
- else
90
- return this.width;
108
+ ItemRangeOverflow.prototype.reposition = function reposition() {
109
+ var dom = this.dom,
110
+ props = this.props;
111
+
112
+ if (dom) {
113
+ dom.box.style.top = this.top + 'px';
114
+ dom.box.style.left = this.left + 'px';
115
+ dom.box.style.width = this._width + 'px';
116
+
117
+ dom.content.style.left = props.content.left + 'px';
118
+ }
91
119
  };
@@ -533,21 +533,6 @@ util.getTarget = function getTarget(event) {
533
533
  return target;
534
534
  };
535
535
 
536
- /**
537
- * Stop event propagation
538
- */
539
- util.stopPropagation = function stopPropagation(event) {
540
- if (!event)
541
- event = window.event;
542
-
543
- if (event.stopPropagation) {
544
- event.stopPropagation(); // non-IE browsers
545
- }
546
- else {
547
- event.cancelBubble = true; // IE browsers
548
- }
549
- };
550
-
551
536
  /**
552
537
  * Fake a hammer.js gesture. Event can be a ScrollEvent or MouseMoveEvent
553
538
  * @param {Element} element
@@ -557,28 +542,23 @@ util.fakeGesture = function fakeGesture (element, event) {
557
542
  var eventType = null;
558
543
 
559
544
  // for hammer.js 1.0.5
560
- //return Hammer.event.collectEventData(this, eventType, event);
545
+ // var gesture = Hammer.event.collectEventData(this, eventType, event);
561
546
 
562
547
  // for hammer.js 1.0.6
563
548
  var touches = Hammer.event.getTouchList(event, eventType);
564
- return Hammer.event.collectEventData(this, eventType, touches, event);
565
- };
566
-
567
- /**
568
- * Cancels the event if it is cancelable, without stopping further propagation of the event.
569
- */
570
- util.preventDefault = function preventDefault (event) {
571
- if (!event)
572
- event = window.event;
549
+ var gesture = Hammer.event.collectEventData(this, eventType, touches, event);
573
550
 
574
- if (event.preventDefault) {
575
- event.preventDefault(); // non-IE browsers
551
+ // on IE in standards mode, no touches are recognized by hammer.js,
552
+ // resulting in NaN values for center.pageX and center.pageY
553
+ if (isNaN(gesture.center.pageX)) {
554
+ gesture.center.pageX = event.pageX;
576
555
  }
577
- else {
578
- event.returnValue = false; // IE browsers
556
+ if (isNaN(gesture.center.pageY)) {
557
+ gesture.center.pageY = event.pageY;
579
558
  }
580
- };
581
559
 
560
+ return gesture;
561
+ };
582
562
 
583
563
  util.option = {};
584
564
 
@@ -671,3 +651,162 @@ util.option.asElement = function (value, defaultValue) {
671
651
 
672
652
  return value || defaultValue || null;
673
653
  };
654
+
655
+
656
+
657
+ util.GiveDec = function GiveDec(Hex)
658
+ {
659
+ if(Hex == "A")
660
+ Value = 10;
661
+ else
662
+ if(Hex == "B")
663
+ Value = 11;
664
+ else
665
+ if(Hex == "C")
666
+ Value = 12;
667
+ else
668
+ if(Hex == "D")
669
+ Value = 13;
670
+ else
671
+ if(Hex == "E")
672
+ Value = 14;
673
+ else
674
+ if(Hex == "F")
675
+ Value = 15;
676
+ else
677
+ Value = eval(Hex)
678
+ return Value;
679
+ }
680
+
681
+ util.GiveHex = function GiveHex(Dec)
682
+ {
683
+ if(Dec == 10)
684
+ Value = "A";
685
+ else
686
+ if(Dec == 11)
687
+ Value = "B";
688
+ else
689
+ if(Dec == 12)
690
+ Value = "C";
691
+ else
692
+ if(Dec == 13)
693
+ Value = "D";
694
+ else
695
+ if(Dec == 14)
696
+ Value = "E";
697
+ else
698
+ if(Dec == 15)
699
+ Value = "F";
700
+ else
701
+ Value = "" + Dec;
702
+ return Value;
703
+ }
704
+
705
+ /**
706
+ * http://www.yellowpipe.com/yis/tools/hex-to-rgb/color-converter.php
707
+ *
708
+ * @param {String} hex
709
+ * @returns {{r: *, g: *, b: *}}
710
+ */
711
+ util.hexToRGB = function hexToRGB(hex) {
712
+ hex = hex.replace("#","").toUpperCase();
713
+
714
+ var a = util.GiveDec(hex.substring(0, 1));
715
+ var b = util.GiveDec(hex.substring(1, 2));
716
+ var c = util.GiveDec(hex.substring(2, 3));
717
+ var d = util.GiveDec(hex.substring(3, 4));
718
+ var e = util.GiveDec(hex.substring(4, 5));
719
+ var f = util.GiveDec(hex.substring(5, 6));
720
+
721
+ var r = (a * 16) + b;
722
+ var g = (c * 16) + d;
723
+ var b = (e * 16) + f;
724
+
725
+ return {r:r,g:g,b:b};
726
+ };
727
+
728
+ util.RGBToHex = function RGBToHex(red,green,blue) {
729
+ var a = util.GiveHex(Math.floor(red / 16));
730
+ var b = util.GiveHex(red % 16);
731
+ var c = util.GiveHex(Math.floor(green / 16));
732
+ var d = util.GiveHex(green % 16);
733
+ var e = util.GiveHex(Math.floor(blue / 16));
734
+ var f = util.GiveHex(blue % 16);
735
+
736
+ var hex = a + b + c + d + e + f;
737
+ return "#" + hex;
738
+ };
739
+
740
+
741
+ /**
742
+ * http://www.javascripter.net/faq/rgb2hsv.htm
743
+ *
744
+ * @param red
745
+ * @param green
746
+ * @param blue
747
+ * @returns {*}
748
+ * @constructor
749
+ */
750
+ util.RGBToHSV = function RGBToHSV (red,green,blue) {
751
+ red=red/255; green=green/255; blue=blue/255;
752
+ var minRGB = Math.min(red,Math.min(green,blue));
753
+ var maxRGB = Math.max(red,Math.max(green,blue));
754
+
755
+ // Black-gray-white
756
+ if (minRGB == maxRGB) {
757
+ return {h:0,s:0,v:minRGB};
758
+ }
759
+
760
+ // Colors other than black-gray-white:
761
+ var d = (red==minRGB) ? green-blue : ((blue==minRGB) ? red-green : blue-red);
762
+ var h = (red==minRGB) ? 3 : ((blue==minRGB) ? 1 : 5);
763
+ var hue = 60*(h - d/(maxRGB - minRGB))/360;
764
+ var saturation = (maxRGB - minRGB)/maxRGB;
765
+ var value = maxRGB;
766
+ return {h:hue,s:saturation,v:value};
767
+ };
768
+
769
+
770
+ /**
771
+ * https://gist.github.com/mjijackson/5311256
772
+ * @param hue
773
+ * @param saturation
774
+ * @param value
775
+ * @returns {{r: number, g: number, b: number}}
776
+ * @constructor
777
+ */
778
+ util.HSVToRGB = function HSVToRGB(h, s, v) {
779
+ var r, g, b;
780
+
781
+ var i = Math.floor(h * 6);
782
+ var f = h * 6 - i;
783
+ var p = v * (1 - s);
784
+ var q = v * (1 - f * s);
785
+ var t = v * (1 - (1 - f) * s);
786
+
787
+ switch (i % 6) {
788
+ case 0: r = v, g = t, b = p; break;
789
+ case 1: r = q, g = v, b = p; break;
790
+ case 2: r = p, g = v, b = t; break;
791
+ case 3: r = p, g = q, b = v; break;
792
+ case 4: r = t, g = p, b = v; break;
793
+ case 5: r = v, g = p, b = q; break;
794
+ }
795
+
796
+ return {r:Math.floor(r * 255), g:Math.floor(g * 255), b:Math.floor(b * 255) };
797
+ };
798
+
799
+ util.HSVToHex = function HSVToHex(h,s,v) {
800
+ var rgb = util.HSVToRGB(h,s,v);
801
+ return util.RGBToHex(rgb.r,rgb.g,rgb.b);
802
+ }
803
+
804
+ util.hexToHSV = function hexToHSV(hex) {
805
+ var rgb = util.hexToRGB(hex);
806
+ return util.RGBToHSV(rgb.r,rgb.g,rgb.b);
807
+ }
808
+
809
+ util.isValidHex = function isValidHex(hex) {
810
+ var isOk = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(hex);
811
+ return isOk;
812
+ }
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vis-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - AlexVangelov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-06 00:00:00.000000000 Z
11
+ date: 2014-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: momentjs-rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: hammerjs-rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
@@ -56,14 +56,14 @@ dependencies:
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: This gem provides Rails driver for http://visjs.org browser-based visualization
@@ -85,9 +85,9 @@ files:
85
85
  - lib/vis/rails.rb
86
86
  - lib/vis/rails/engine.rb
87
87
  - lib/vis/rails/version.rb
88
+ - vendor/assets/component/emitter.js
88
89
  - vendor/assets/javascripts/vis.js
89
90
  - vendor/assets/stylesheets/vis.css
90
- - vis-rails.gemspec
91
91
  - vendor/assets/vis/.gitignore
92
92
  - vendor/assets/vis/DataSet.js
93
93
  - vendor/assets/vis/DataView.js
@@ -103,12 +103,37 @@ files:
103
103
  - vendor/assets/vis/graph/Popup.js
104
104
  - vendor/assets/vis/graph/SectorsMixin.js
105
105
  - vendor/assets/vis/graph/SelectionMixin.js
106
+ - vendor/assets/vis/graph/css/graph-manipulation.css
107
+ - vendor/assets/vis/graph/css/graph-navigation.css
106
108
  - vendor/assets/vis/graph/dotparser.js
109
+ - vendor/assets/vis/graph/graphMixins/ClusterMixin.js
110
+ - vendor/assets/vis/graph/graphMixins/HierarchicalLayoutMixin.js
111
+ - vendor/assets/vis/graph/graphMixins/ManipulationMixin.js
112
+ - vendor/assets/vis/graph/graphMixins/MixinLoader.js
113
+ - vendor/assets/vis/graph/graphMixins/NavigationMixin.js
114
+ - vendor/assets/vis/graph/graphMixins/SectorsMixin.js
115
+ - vendor/assets/vis/graph/graphMixins/SelectionMixin.js
116
+ - vendor/assets/vis/graph/graphMixins/physics/BarnesHut.js
117
+ - vendor/assets/vis/graph/graphMixins/physics/HierarchialRepulsion.js
118
+ - vendor/assets/vis/graph/graphMixins/physics/PhysicsMixin.js
119
+ - vendor/assets/vis/graph/graphMixins/physics/Repulsion.js
120
+ - vendor/assets/vis/graph/img/acceptDeleteIcon.png
121
+ - vendor/assets/vis/graph/img/addNodeIcon.png
122
+ - vendor/assets/vis/graph/img/backIcon.png
123
+ - vendor/assets/vis/graph/img/connectIcon.png
124
+ - vendor/assets/vis/graph/img/cross.png
125
+ - vendor/assets/vis/graph/img/cross2.png
126
+ - vendor/assets/vis/graph/img/deleteIcon.png
127
+ - vendor/assets/vis/graph/img/downArrow.png
107
128
  - vendor/assets/vis/graph/img/downarrow.png
129
+ - vendor/assets/vis/graph/img/editIcon.png
130
+ - vendor/assets/vis/graph/img/leftArrow.png
108
131
  - vendor/assets/vis/graph/img/leftarrow.png
109
132
  - vendor/assets/vis/graph/img/minus.png
110
133
  - vendor/assets/vis/graph/img/plus.png
134
+ - vendor/assets/vis/graph/img/rightArrow.png
111
135
  - vendor/assets/vis/graph/img/rightarrow.png
136
+ - vendor/assets/vis/graph/img/upArrow.png
112
137
  - vendor/assets/vis/graph/img/uparrow.png
113
138
  - vendor/assets/vis/graph/img/zoomExtends.png
114
139
  - vendor/assets/vis/graph/shapes.js
@@ -144,7 +169,9 @@ files:
144
169
  - vendor/assets/vis/timeline/component/item/ItemPoint.js
145
170
  - vendor/assets/vis/timeline/component/item/ItemRange.js
146
171
  - vendor/assets/vis/timeline/component/item/ItemRangeOverflow.js
172
+ - vendor/assets/vis/timeline/img/delete.png
147
173
  - vendor/assets/vis/util.js
174
+ - vis-rails.gemspec
148
175
  homepage: https://github.com/AlexVangelov/vis-rails
149
176
  licenses:
150
177
  - MIT
@@ -155,17 +182,17 @@ require_paths:
155
182
  - lib
156
183
  required_ruby_version: !ruby/object:Gem::Requirement
157
184
  requirements:
158
- - - ! '>='
185
+ - - '>='
159
186
  - !ruby/object:Gem::Version
160
187
  version: '0'
161
188
  required_rubygems_version: !ruby/object:Gem::Requirement
162
189
  requirements:
163
- - - ! '>='
190
+ - - '>='
164
191
  - !ruby/object:Gem::Version
165
192
  version: '0'
166
193
  requirements: []
167
194
  rubyforge_project:
168
- rubygems_version: 2.1.10
195
+ rubygems_version: 2.2.2
169
196
  signing_key:
170
197
  specification_version: 4
171
198
  summary: Using http://visjs.org visualization library with Rails