kiteboard 0.1.0

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.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +109 -0
  7. data/Rakefile +6 -0
  8. data/app/assets/fonts/fontawesome-webfont.eot +0 -0
  9. data/app/assets/fonts/fontawesome-webfont.svg +414 -0
  10. data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
  11. data/app/assets/fonts/fontawesome-webfont.woff +0 -0
  12. data/app/assets/javascripts/clock.js +13 -0
  13. data/app/assets/javascripts/digit.js +37 -0
  14. data/app/assets/javascripts/graph.js +46 -0
  15. data/app/assets/javascripts/kiteboard.js +53 -0
  16. data/app/assets/javascripts/list.js +17 -0
  17. data/app/assets/javascripts/meter.js +13 -0
  18. data/app/assets/javascripts/temperature.js +30 -0
  19. data/app/assets/javascripts/text.js +11 -0
  20. data/app/assets/stylesheets/base.scss +263 -0
  21. data/app/assets/stylesheets/font-awesome.scss +1338 -0
  22. data/app/assets/stylesheets/jquery.gridster.css +121 -0
  23. data/app/assets/stylesheets/kiteboard.css +15 -0
  24. data/app/assets/stylesheets/widgets/clock.scss +13 -0
  25. data/app/assets/stylesheets/widgets/digit.scss +39 -0
  26. data/app/assets/stylesheets/widgets/graph.scss +58 -0
  27. data/app/assets/stylesheets/widgets/list.scss +61 -0
  28. data/app/assets/stylesheets/widgets/meter.scss +35 -0
  29. data/app/assets/stylesheets/widgets/temperature.scss +52 -0
  30. data/app/assets/stylesheets/widgets/text.scss +32 -0
  31. data/app/views/kiteboard/_clock.html.erb +4 -0
  32. data/app/views/kiteboard/_digit.html.erb +16 -0
  33. data/app/views/kiteboard/_graph.html.erb +11 -0
  34. data/app/views/kiteboard/_list.html.erb +9 -0
  35. data/app/views/kiteboard/_meter.html.erb +15 -0
  36. data/app/views/kiteboard/_temperature.html.erb +7 -0
  37. data/app/views/kiteboard/_text.html.erb +11 -0
  38. data/bin/console +14 -0
  39. data/bin/setup +8 -0
  40. data/kiteboard.gemspec +24 -0
  41. data/lib/kiteboard.rb +5 -0
  42. data/lib/kiteboard/engine.rb +10 -0
  43. data/lib/kiteboard/version.rb +3 -0
  44. data/vendor/assets/javascripts/d3.layout.min.js +1 -0
  45. data/vendor/assets/javascripts/d3.min.js +5 -0
  46. data/vendor/assets/javascripts/jquery.gridster.js +3987 -0
  47. data/vendor/assets/javascripts/jquery.knob.js +646 -0
  48. data/vendor/assets/javascripts/rickshaw.min.js +3 -0
  49. metadata +133 -0
@@ -0,0 +1,13 @@
1
+ $(function () {
2
+ 'use strict';
3
+
4
+ window.Clock = window.Clock || {};
5
+
6
+ Clock.startClock = function (widget) {
7
+ setTimeout(function () {
8
+ widget.find('h1').html(new Date().toDateString());
9
+ widget.find('h2').html(new Date().toLocaleTimeString());
10
+ Clock.startClock(widget);
11
+ }, 500);
12
+ }
13
+ });
@@ -0,0 +1,37 @@
1
+ $(function () {
2
+ 'use strict';
3
+
4
+ window.Digit = window.Digit || {};
5
+
6
+ Digit.setData = function (widget, data) {
7
+ var currentValue = widget.find('.value')[0].getAttribute('data-value');
8
+ widget.find('.value').html(Kiteboard.nFormatter(data));
9
+ widget.find('.value')[0].setAttribute('data-value', data);
10
+
11
+ var changeRateIcon = widget.find('.change-rate').find('.fa');
12
+ changeRateIcon.removeClass('fa-arrow-down');
13
+ changeRateIcon.removeClass('fa-arrow-up');
14
+
15
+ if (data < currentValue) {
16
+ changeRateIcon.addClass('fa-arrow-down');
17
+ if (data == currentValue || currentValue == 0) {
18
+ var changeRate = 0;
19
+ } else {
20
+ var changeRate = Math.round(((currentValue - data) / currentValue) * 100);
21
+ }
22
+
23
+ widget.find('.change-rate').find('span').html(changeRate + '%');
24
+ } else {
25
+ if (data == currentValue || currentValue == 0) {
26
+ var changeRate = 0;
27
+ } else {
28
+ var changeRate = Math.round(((data - currentValue) / currentValue) * 100);
29
+ }
30
+
31
+ changeRateIcon.addClass('fa-arrow-up');
32
+ widget.find('.change-rate').find('span').html(changeRate + '%');
33
+ }
34
+
35
+ widget.find('.updated-at').html('Last updated at ' + new Date().toLocaleTimeString())
36
+ }
37
+ });
@@ -0,0 +1,46 @@
1
+ $(function () {
2
+ 'use strict';
3
+
4
+ window.Graph = window.Graph || {};
5
+
6
+ var graph = {};
7
+ var seriesData = {};
8
+
9
+ Graph.setup = function (widget, data) {
10
+ seriesData[widget.attr('id')] = [[
11
+ {x: 0, y: 0},
12
+ {x: 1, y: 0},
13
+ {x: 2, y: 0},
14
+ {x: 3, y: 0},
15
+ {x: 4, y: 0},
16
+ {x: 5, y: 0}
17
+ ]];
18
+
19
+ var width = widget.width();
20
+ var height = widget.height();
21
+
22
+ graph[widget.attr('id')] = new Rickshaw.Graph({
23
+ element: widget.find("#chart")[0],
24
+ width: width,
25
+ height: height,
26
+ series: [{
27
+ color: 'rgba(0, 0, 0, 0.4)',
28
+ data: seriesData[widget.attr('id')][0]
29
+ }]
30
+ });
31
+
32
+ graph[widget.attr('id')].render();
33
+ };
34
+
35
+ Graph.setData = function (widget, data) {
36
+ graph[widget.attr('id')].series[0].data[5].y = graph[widget.attr('id')].series[0].data[4].y;
37
+ graph[widget.attr('id')].series[0].data[4].y = graph[widget.attr('id')].series[0].data[3].y;
38
+ graph[widget.attr('id')].series[0].data[3].y = graph[widget.attr('id')].series[0].data[2].y;
39
+ graph[widget.attr('id')].series[0].data[2].y = graph[widget.attr('id')].series[0].data[1].y;
40
+ graph[widget.attr('id')].series[0].data[1].y = data;
41
+
42
+ graph[widget.attr('id')].render();
43
+
44
+ widget.find('.updated-at').html('Last updated at ' + new Date().toLocaleTimeString())
45
+ }
46
+ });
@@ -0,0 +1,53 @@
1
+ //= require jquery.knob
2
+ //= require jquery.gridster
3
+ //= require d3.min
4
+ //= require d3.layout.min
5
+ //= require rickshaw.min
6
+ //= require_tree .
7
+
8
+ $(function () {
9
+ 'use strict';
10
+ window.Kiteboard = {
11
+ init: function () {
12
+ var contentWidth = 1240;
13
+ $('.gridster').width(contentWidth);
14
+ $('.gridster ul').gridster({
15
+ widget_margins: [5, 5],
16
+ widget_base_dimensions: [300, 360]
17
+ });
18
+
19
+ var clockWidgets = $(".gridster>ul>li[data-widget='Clock']");
20
+ $(clockWidgets).each(function () {
21
+ Clock.startClock($(this));
22
+ });
23
+
24
+ var graphWidgets = $(".gridster>ul>li[data-widget='Graph']");
25
+ $(graphWidgets).each(function () {
26
+ Graph.setup($(this));
27
+ });
28
+ },
29
+
30
+ updateWidgets: function (data) {
31
+ var widgets = $('.gridster>ul>li');
32
+ $(widgets).each(function () {
33
+ var widget = $(this);
34
+ if (widget.data('widget') != 'Clock') {
35
+ window[widget.data('widget')].setData(widget, data[this.id]);
36
+ }
37
+ });
38
+ },
39
+
40
+ nFormatter: function (num) {
41
+ if (num >= 1000000000) {
42
+ return (num / 1000000000).toFixed(1).replace(/\.0$/, '') + 'g';
43
+ }
44
+ if (num >= 1000000) {
45
+ return (num / 1000000).toFixed(1).replace(/\.0$/, '') + 'm';
46
+ }
47
+ if (num >= 1000) {
48
+ return (num / 1000).toFixed(1).replace(/\.0$/, '') + 'k';
49
+ }
50
+ return num;
51
+ }
52
+ };
53
+ });
@@ -0,0 +1,17 @@
1
+ $(function () {
2
+ 'use strict';
3
+
4
+ window.List = window.List || {};
5
+
6
+ List.setData = function (widget, data) {
7
+ var list = widget.find('.list-nostyle');
8
+ list.empty();
9
+ $.each(data, function (key, value) {
10
+ var li = $('<li/>').appendTo(list);
11
+ $('<span>' + key + '</span><span/>').addClass('label').appendTo(li);
12
+ $('<span>' + value + '<span/>').addClass('value').appendTo(li);
13
+ });
14
+
15
+ widget.find('.updated-at').html('Last updated at ' + new Date().toLocaleTimeString());
16
+ };
17
+ });
@@ -0,0 +1,13 @@
1
+ $(function () {
2
+ 'use strict';
3
+
4
+ window.Meter = window.Meter || {};
5
+
6
+ Meter.setData = function (widget, data) {
7
+ widget.find(".meter").knob();
8
+
9
+ widget.find('.meter').val(data).trigger('change');
10
+
11
+ widget.find('.updated-at').html('Last updated at ' + new Date().toLocaleTimeString())
12
+ };
13
+ });
@@ -0,0 +1,30 @@
1
+ $(function () {
2
+ 'use strict';
3
+
4
+ window.Temperature = window.Temperature || {};
5
+
6
+ Temperature.setData = function (widget, data) {
7
+ widget.find('.widget-hotness').removeClass('hotness0');
8
+ widget.find('.widget-hotness').removeClass('hotness1');
9
+ widget.find('.widget-hotness').removeClass('hotness2');
10
+ widget.find('.widget-hotness').removeClass('hotness3');
11
+ widget.find('.widget-hotness').removeClass('hotness4');
12
+
13
+ var min = widget.find('.widget-hotness')[0].getAttribute('data-min');
14
+ var max = widget.find('.widget-hotness')[0].getAttribute('data-max');
15
+
16
+ if (data <= min) {
17
+ widget.find('.widget-hotness').addClass('hotness0');
18
+ } else if (data >= max) {
19
+ widget.find('.widget-hotness').addClass('hotness4');
20
+ } else {
21
+ var temperatureLevel = Math.ceil((data - min) / ((max - min) / 3));
22
+ var backgroundClass = 'hotness' + temperatureLevel;
23
+ widget.find('.widget-hotness').addClass(backgroundClass);
24
+ }
25
+
26
+ widget.find('.value').html(Kiteboard.nFormatter(data));
27
+
28
+ widget.find('.updated-at').html('Last updated at ' + new Date().toLocaleTimeString())
29
+ }
30
+ });
@@ -0,0 +1,11 @@
1
+ $(function () {
2
+ 'use strict';
3
+
4
+ window.Text = window.Text || {};
5
+
6
+ Text.setData = function (widget, data) {
7
+ widget.find('.text').html(data);
8
+
9
+ widget.find('.updated-at').html('Last updated at ' + new Date().toLocaleTimeString())
10
+ };
11
+ });
@@ -0,0 +1,263 @@
1
+ // ----------------------------------------------------------------------------
2
+ // Sass declarations
3
+ // ----------------------------------------------------------------------------
4
+ $background-color: #222;
5
+ $text-color: #fff;
6
+
7
+ $background-warning-color-1: #e82711;
8
+ $background-warning-color-2: #9b2d23;
9
+ $text-warning-color: #fff;
10
+
11
+ $background-danger-color-1: #eeae32;
12
+ $background-danger-color-2: #ff9618;
13
+ $text-danger-color: #fff;
14
+
15
+ @-webkit-keyframes status-warning-background {
16
+ 0% { background-color: $background-warning-color-1; }
17
+ 50% { background-color: $background-warning-color-2; }
18
+ 100% { background-color: $background-warning-color-1; }
19
+ }
20
+ @-webkit-keyframes status-danger-background {
21
+ 0% { background-color: $background-danger-color-1; }
22
+ 50% { background-color: $background-danger-color-2; }
23
+ 100% { background-color: $background-danger-color-1; }
24
+ }
25
+ @mixin animation($animation-name, $duration, $function, $animation-iteration-count:""){
26
+ -webkit-animation: $animation-name $duration $function #{$animation-iteration-count};
27
+ -moz-animation: $animation-name $duration $function #{$animation-iteration-count};
28
+ -ms-animation: $animation-name $duration $function #{$animation-iteration-count};
29
+ }
30
+
31
+ // ----------------------------------------------------------------------------
32
+ // Base styles
33
+ // ----------------------------------------------------------------------------
34
+ html {
35
+ font-size: 100%;
36
+ -webkit-text-size-adjust: 100%;
37
+ -ms-text-size-adjust: 100%;
38
+ }
39
+
40
+ body {
41
+ margin: 0;
42
+ background-color: $background-color;
43
+ font-size: 20px;
44
+ color: $text-color;
45
+ font-family: 'Open Sans', "Helvetica Neue", Helvetica, Arial, sans-serif;
46
+ }
47
+
48
+ b, strong {
49
+ font-weight: bold;
50
+ }
51
+
52
+ a {
53
+ text-decoration: none;
54
+ color: inherit;
55
+ }
56
+
57
+ img {
58
+ border: 0;
59
+ -ms-interpolation-mode: bicubic;
60
+ vertical-align: middle;
61
+ }
62
+
63
+ img, object {
64
+ max-width: 100%;
65
+ }
66
+
67
+ iframe {
68
+ max-width: 100%;
69
+ }
70
+
71
+ table {
72
+ border-collapse: collapse;
73
+ border-spacing: 0;
74
+ width: 100%;
75
+ }
76
+
77
+ td {
78
+ vertical-align: middle;
79
+ }
80
+
81
+ ul, ol {
82
+ padding: 0;
83
+ margin: 0;
84
+ }
85
+
86
+ h1, h2, h3, h4, h5, p {
87
+ padding: 0;
88
+ margin: 0;
89
+ }
90
+
91
+ .widget {
92
+ a {
93
+ color: rgba(255, 255, 255, 0.7);
94
+ }
95
+ h1 {
96
+ margin-bottom: 12px;
97
+ text-align: center;
98
+ font-size: 30px !important;
99
+ font-weight: 400 !important;
100
+ }
101
+ h2 {
102
+ text-transform: uppercase;
103
+ font-size: 76px !important;
104
+ font-weight: 700 !important;
105
+ color: $text-color !important;
106
+ }
107
+ h3 {
108
+ font-size: 25px !important;
109
+ font-weight: 600 !important;
110
+ color: $text-color !important;
111
+ }
112
+ .list-nostyle {
113
+ li {
114
+ font-size: 22px !important;
115
+ }
116
+ }
117
+ }
118
+ // ----------------------------------------------------------------------------
119
+ // Base widget styles
120
+ // ----------------------------------------------------------------------------
121
+ .gridster {
122
+ margin: 0px auto;
123
+ }
124
+
125
+ .icon-background {
126
+ pointer-events: none;
127
+ width: 100%!important;
128
+ height: 100%;
129
+ position: absolute;
130
+ left: 0;
131
+ top: 0;
132
+ opacity: 0.1;
133
+ font-size: 275px;
134
+ text-align: center;
135
+ margin-top: 82px;
136
+ }
137
+
138
+ .list-nostyle {
139
+ list-style: none;
140
+ }
141
+
142
+ .gridster ul {
143
+ list-style: none;
144
+ }
145
+
146
+ .gs_w {
147
+ width: 100%;
148
+ display: table;
149
+ cursor: pointer;
150
+ }
151
+
152
+ .widget {
153
+ text-align: center;
154
+ width: inherit;
155
+ height: inherit;
156
+ display: table-cell;
157
+ vertical-align: middle;
158
+ }
159
+
160
+ .widget.status-warning {
161
+ background-color: $background-warning-color-1;
162
+ @include animation(status-warning-background, 2s, ease, infinite);
163
+
164
+ .icon-warning-sign {
165
+ display: inline-block;
166
+ }
167
+
168
+ .title, .more-info {
169
+ color: $text-warning-color;
170
+ }
171
+ }
172
+
173
+ .widget.status-danger {
174
+ color: $text-danger-color;
175
+ background-color: $background-danger-color-1;
176
+ @include animation(status-danger-background, 2s, ease, infinite);
177
+
178
+ .icon-warning-sign {
179
+ display: inline-block;
180
+ }
181
+
182
+ .title, .more-info {
183
+ color: $text-danger-color;
184
+ }
185
+ }
186
+
187
+ .more-info {
188
+ font-size: 15px;
189
+ position: absolute;
190
+ bottom: 32px;
191
+ left: 0;
192
+ right: 0;
193
+ }
194
+
195
+ .updated-at {
196
+ font-size: 15px;
197
+ position: absolute;
198
+ bottom: 12px;
199
+ left: 0;
200
+ right: 0;
201
+ }
202
+
203
+ #save-gridster {
204
+ display: none;
205
+ position: fixed;
206
+ top: 0;
207
+ margin: 0px auto;
208
+ left: 50%;
209
+ z-index: 1000;
210
+ background: black;
211
+ width: 190px;
212
+ text-align: center;
213
+ border: 1px solid white;
214
+ border-top: 0px;
215
+ margin-left: -95px;
216
+ padding: 15px;
217
+ }
218
+
219
+ #save-gridster:hover {
220
+ padding-top: 25px;
221
+ }
222
+
223
+ #saving-instructions {
224
+ display: none;
225
+ padding: 10px;
226
+ width: 500px;
227
+ height: 122px;
228
+ z-index: 1000;
229
+ background: white;
230
+ top: 100px;
231
+ color: black;
232
+ font-size: 15px;
233
+ padding-bottom: 4px;
234
+
235
+ textarea {
236
+ white-space: nowrap;
237
+ width: 494px;
238
+ height: 80px;
239
+ }
240
+ }
241
+
242
+ #lean_overlay {
243
+ position: fixed;
244
+ z-index:100;
245
+ top: 0px;
246
+ left: 0px;
247
+ height:100%;
248
+ width:100%;
249
+ background: #000;
250
+ display: none;
251
+ }
252
+
253
+ #container {
254
+ padding-top: 5px;
255
+ }
256
+
257
+
258
+ // ----------------------------------------------------------------------------
259
+ // Clearfix
260
+ // ----------------------------------------------------------------------------
261
+ .clearfix:before, .clearfix:after { content: "\0020"; display: block; height: 0; overflow: hidden; }
262
+ .clearfix:after { clear: both; }
263
+ .clearfix { zoom: 1; }