bootstrap_widgets 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46301614810e9b3192290335414a0c28fe422918
4
- data.tar.gz: db668ecdcd0775c3738895276f452c13480ea0d7
3
+ metadata.gz: 6976493224d556fbe0cf68ed6c580f7a6fa9b9ab
4
+ data.tar.gz: d5c841209b7ad24d904f89e6b7bb40ca007744e2
5
5
  SHA512:
6
- metadata.gz: 1e4ad395b3a4880ef9016589188ea1581d13fc60650651d124e8e6aeb74326e5f72bb0cdbd1dc9fcf24b1788228a65a29783bc3b41b8e847189672a315e4e4a2
7
- data.tar.gz: 84a5af371dae284d8045a5d9e1cb591c120be984d0ecb981fa93ec9c8235c0db595a3267ae828c876c96e187ec8f27c06c8fa0eadb05917d9dc86a53319c039b
6
+ metadata.gz: 510a54bd2d22f2f076e777776c2619eee127603ce5ddb9282b1c2423d70c5d3afa1483de857d5203f9cfeec3b7359bc48da10095f3ed55edd1eabacd543631a1
7
+ data.tar.gz: 3a6e87a837abc05ebacbc881a071822e6ce628fe54e94db5ee74f5c5fd53fb473f049fbdc783fe24fbc150716402b81418c22260726ca62c1d229d554f2b79e1
@@ -1,3 +1,3 @@
1
1
  module BootstrapWidgets
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -11,8 +11,12 @@ class GraphWidget < Widget
11
11
  end
12
12
 
13
13
  def self.graph(data={}, title, graph, labels, opts)
14
- output = "<div id='#{graph}-#{title.parameterize}' class='graph'></div>"
15
- output << "<script>#{graph}(#{json_data(data)},#{labels},'#{title.parameterize}',#{opts.to_json})</script>"
14
+ json_data = json_data(data)
15
+ link_data = link_data(data)
16
+ extra_classes = link_data.size > 0 ? "clickable_graph" : ""
17
+
18
+ output = "<div id='#{graph}-#{title.parameterize}' class='graph #{extra_classes}'></div>"
19
+ output << "<script>#{graph}(#{json_data},#{labels},'#{title.parameterize}',#{opts.to_json}, #{link_data.to_json.html_safe})</script>"
16
20
  output
17
21
  end
18
22
 
@@ -37,8 +37,24 @@ protected
37
37
 
38
38
  def self.json_data(data={})
39
39
  jsdata = []
40
- data.each {|key, value| jsdata << { label: "#{key}", value: value } }
40
+ data.each do |key, value|
41
+ if value.is_a? Hash
42
+ jsdata << { label: "#{key}", value: value[:data] }
43
+ else
44
+ jsdata << { label: "#{key}", value: value }
45
+ end
46
+ end
41
47
  jsdata.to_json.html_safe
42
48
  end
43
49
 
50
+ def self.link_data(data={})
51
+ jsdata = []
52
+ data.each do |key, value|
53
+ if value.is_a? Hash
54
+ jsdata << value[:link]
55
+ end
56
+ end
57
+ jsdata.compact
58
+ end
59
+
44
60
  end
@@ -6,7 +6,7 @@
6
6
 
7
7
  window.graphs = []
8
8
 
9
- window.bar_graph = (json_data, labels, title, opts) ->
9
+ window.bar_graph = (json_data, labels, title, opts, links=[]) ->
10
10
  options = $.extend({},opts,{
11
11
  element: 'bar_graph-' + title,
12
12
  data: json_data,
@@ -17,9 +17,13 @@ window.bar_graph = (json_data, labels, title, opts) ->
17
17
  resize: true
18
18
  })
19
19
  graph = new Morris.Bar options
20
+ graph.links = links
21
+ graph.on "click", (data) ->
22
+ if graph.links[data]
23
+ window.location = graph.links[data]
20
24
  window.graphs.push graph
21
25
 
22
- window.line_graph = (json_data, labels, title, opts) ->
26
+ window.line_graph = (json_data, labels, title, opts, links=[]) ->
23
27
  options = $.extend({},opts,{
24
28
  element: 'line_graph-' + title,
25
29
  parseTime: false,
@@ -30,9 +34,13 @@ window.line_graph = (json_data, labels, title, opts) ->
30
34
  resize: true
31
35
  })
32
36
  graph = new Morris.Line options
37
+ graph.links = links
38
+ graph.on "click", (data) ->
39
+ if graph.links[data]
40
+ window.location = graph.links[data]
33
41
  window.graphs.push graph
34
42
 
35
- window.area_graph = (json_data, labels, title, opts) ->
43
+ window.area_graph = (json_data, labels, title, opts, links=[]) ->
36
44
  options = $.extend({},opts,{
37
45
  element: 'area_graph-' + title,
38
46
  parseTime: false,
@@ -43,9 +51,12 @@ window.area_graph = (json_data, labels, title, opts) ->
43
51
  resize: true
44
52
  })
45
53
  graph = new Morris.Area options
54
+ graph.on "click", (data) ->
55
+ if graph.links[data]
56
+ window.location = graph.links[data]
46
57
  window.graphs.push graph
47
58
 
48
- window.donut_graph = (json_data, labels, title, opts) ->
59
+ window.donut_graph = (json_data, labels, title, opts, links=[]) ->
49
60
  options = $.extend({},opts,{
50
61
  element: 'donut_graph-' + title,
51
62
  parseTime: false,
@@ -53,6 +64,10 @@ window.donut_graph = (json_data, labels, title, opts) ->
53
64
  resize: true
54
65
  })
55
66
  graph = new Morris.Donut options
67
+ graph.links = links
68
+ graph.on "click", (data) ->
69
+ if graph.links[data]
70
+ window.location = graph.links[data]
56
71
  window.graphs.push graph
57
72
 
58
73
  # ===== REDRAWING/RESIZING ====
@@ -71,12 +86,9 @@ window.redraw = (idx) ->
71
86
  $(window).resize ->
72
87
  if window.graphs.length > 0
73
88
  $('.loading-view').show()
74
- if window.graphs.length > 3
75
- waitForFinalEvent (->
76
- resize()
77
- ), 250, "bootstrap-widgets.resize.redrawing"
78
- else
89
+ waitForFinalEvent (->
79
90
  resize()
91
+ ), 250, "bootstrap-widgets.resize.redrawing"
80
92
 
81
93
  $(document).on "ready page:change", ->
82
94
  if $('.masonry').length
@@ -1,4 +1,6 @@
1
- $break-small:1024px;
1
+ //= require morris.min
2
+
3
+ $break-small-dpi: 2.0;
2
4
 
3
5
  /**** LOADING ****/
4
6
  .loading-view {
@@ -67,17 +69,23 @@ $break-small:1024px;
67
69
  width: 40%;
68
70
  float: left;
69
71
  text-align: right;
70
- @media screen and (max-width: $break-small) {
71
- font-size: 13px;
72
- }
72
+ @media only screen and (min--moz-device-pixel-ratio: $break-small-dpi),
73
+ (-o-min-device-pixel-ratio: $break-small-dpi),
74
+ (-webkit-min-device-pixel-ratio: $break-small-dpi),
75
+ (min-device-pixel-ratio: $break-small-dpi) {
76
+ font-size: 13px;
77
+ }
73
78
  }
74
79
  .right-text {
75
80
  width: 60%;
76
81
  float: left;
77
82
  text-align: center;
78
- @media screen and (max-width: $break-small) {
79
- font-size: 13px;
80
- }
83
+ @media only screen and (min--moz-device-pixel-ratio: $break-small-dpi),
84
+ (-o-min-device-pixel-ratio: $break-small-dpi),
85
+ (-webkit-min-device-pixel-ratio: $break-small-dpi),
86
+ (min-device-pixel-ratio: $break-small-dpi) {
87
+ font-size: 13px;
88
+ }
81
89
  }
82
90
  }
83
91
  }
@@ -152,21 +160,27 @@ $break-small:1024px;
152
160
  line-height: 31px;
153
161
  margin-top: 20px;
154
162
  margin-bottom: 10px;
155
- @media screen and (max-width: $break-small) {
156
- line-height: 18px;
157
- font-size: 20px;
158
- float:right;
159
- margin-top:-50px;
160
- }
163
+ @media only screen and (min--moz-device-pixel-ratio: $break-small-dpi),
164
+ (-o-min-device-pixel-ratio: $break-small-dpi),
165
+ (-webkit-min-device-pixel-ratio: $break-small-dpi),
166
+ (min-device-pixel-ratio: $break-small-dpi) {
167
+ line-height: 18px;
168
+ font-size: 20px;
169
+ float:right;
170
+ margin-top:-50px;
171
+ }
161
172
  }
162
173
  .desc {
163
174
  font-size: 30px;
164
175
  font-weight: 100;
165
176
  color: rgba(255, 255, 255, 0.5);
166
- @media screen and (max-width: $break-small) {
167
- font-size: 24px;
168
- float: right;
169
- }
177
+ @media only screen and (min--moz-device-pixel-ratio: $break-small-dpi),
178
+ (-o-min-device-pixel-ratio: $break-small-dpi),
179
+ (-webkit-min-device-pixel-ratio: $break-small-dpi),
180
+ (min-device-pixel-ratio: $break-small-dpi) {
181
+ font-size: 24px;
182
+ float: right;
183
+ }
170
184
  }
171
185
  .desc, .number {
172
186
  text-align: right;
@@ -187,3 +201,15 @@ $break-small:1024px;
187
201
  text-align: right;
188
202
  }
189
203
  }
204
+
205
+ /***** GRAPH SPECIFIC *******/
206
+
207
+ .clickable_graph > svg > path,
208
+ .clickable_graph > svg > rect,
209
+ .clickable_graph > .morris-hover {
210
+ cursor: pointer;
211
+ }
212
+
213
+ .clickable_graph > .morris-hover:hover {
214
+ background: #fff;
215
+ }
@@ -0,0 +1,2 @@
1
+ .morris-hover{position:absolute;z-index:1000}.morris-hover.morris-default-style{border-radius:10px;padding:6px;color:#666;background:rgba(255,255,255,0.8);border:solid 2px rgba(230,230,230,0.8);font-family:sans-serif;font-size:12px;text-align:center}.morris-hover.morris-default-style .morris-hover-row-label{font-weight:bold;margin:0.25em 0}
2
+ .morris-hover.morris-default-style .morris-hover-point{white-space:nowrap;margin:0.1em 0}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_widgets
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Nadeau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-20 00:00:00.000000000 Z
11
+ date: 2014-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -200,6 +200,7 @@ files:
200
200
  - vendor/assets/javascripts/morris.min.js
201
201
  - vendor/assets/javascripts/raphael.min.js
202
202
  - vendor/assets/stylesheets/bootstrap_widgets.css.scss
203
+ - vendor/assets/stylesheets/morris.min.css
203
204
  homepage: http://github.com/jules2689/bootstrap_widgets
204
205
  licenses:
205
206
  - MIT