omf_web 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/bin/omf_web_server +18 -0
  2. data/example/bridge/README.md +7 -0
  3. data/example/bridge/data_sources/sensor-sqlite.rb +15 -15
  4. data/example/bridge/htdocs/graph/js/bridge.js +35 -45
  5. data/example/bridge/htdocs/graph/js/event_line_chart.js +20 -18
  6. data/example/bridge/htdocs/graph/js/event_table.js +26 -28
  7. data/example/bridge/viz_server.rb +5 -9
  8. data/example/demo/demo_viz_server.rb +2 -2
  9. data/example/demo/widgets/linked_graphs_tab.yaml +9 -32
  10. data/example/openflow-gec15/code_tab.yaml +7 -12
  11. data/example/openflow-gec15/dashboard_tab.yaml +11 -12
  12. data/example/openflow-gec15/exp_source.rb +26 -26
  13. data/example/openflow-gec15/of_viz_server.rb +7 -7
  14. data/example/simple/simple.yaml +2 -1
  15. data/example/simple/simple_dynamic.yaml +1 -1
  16. data/example/web_rtc/web_rtc.yaml +54 -0
  17. data/example/web_rtc/webrtc-exp_1381786573.sq3 +0 -0
  18. data/lib/omf-web/config.ru +1 -1
  19. data/lib/omf-web/content/content_proxy.rb +2 -2
  20. data/lib/omf-web/content/file_repository.rb +11 -53
  21. data/lib/omf-web/content/git_repository.rb +1 -1
  22. data/lib/omf-web/content/irods_repository.rb +1 -1
  23. data/lib/omf-web/content/repository.rb +5 -3
  24. data/lib/omf-web/content/static_repository.rb +25 -11
  25. data/lib/omf-web/data_source_proxy.rb +3 -3
  26. data/lib/omf-web/rack/content_handler.rb +2 -2
  27. data/lib/omf-web/rack/session_authenticator.rb +3 -3
  28. data/lib/omf-web/rack/tab_mapper.rb +2 -2
  29. data/lib/omf-web/rack/update_handler.rb +2 -2
  30. data/lib/omf-web/rack/websocket_handler.rb +3 -3
  31. data/lib/omf-web/rack/widget_mapper.rb +2 -2
  32. data/lib/omf-web/session_store.rb +2 -2
  33. data/lib/omf-web/theme/abstract_page.rb +15 -24
  34. data/lib/omf-web/theme/bright/code_renderer.rb +24 -30
  35. data/lib/omf-web/theme/bright/data_renderer.rb +7 -5
  36. data/lib/omf-web/theme/bright/page.rb +2 -1
  37. data/lib/omf-web/theme/bright/widget_chrome.rb +16 -14
  38. data/lib/omf-web/theme.rb +1 -1
  39. data/lib/omf-web/thin/logging.rb +18 -13
  40. data/lib/omf-web/thin/runner.rb +2 -2
  41. data/lib/omf-web/thin/server.rb +105 -27
  42. data/lib/omf-web/version.rb +1 -1
  43. data/lib/omf-web/widget/abstract_widget.rb +3 -3
  44. data/lib/omf-web/widget/data_widget.rb +1 -0
  45. data/lib/omf-web/widget/text/maruku.rb +1 -1
  46. data/lib/omf-web/widget.rb +22 -22
  47. data/lib/omf_web.rb +1 -1
  48. data/omf_web.gemspec +18 -15
  49. data/share/htdocs/graph/js/abstract_chart.js +69 -68
  50. data/share/htdocs/graph/js/abstract_nv_chart.js +35 -33
  51. data/share/htdocs/graph/js/abstract_widget.js +61 -62
  52. data/share/htdocs/graph/js/axis.js +30 -25
  53. data/share/htdocs/graph/js/barchart_brush.js +23 -21
  54. data/share/htdocs/graph/js/code_mirror.js +35 -33
  55. data/share/htdocs/graph/js/discrete_bar_chart.js +27 -30
  56. data/share/htdocs/graph/js/histogram2.js +37 -47
  57. data/share/htdocs/graph/js/line_chart3.js +36 -30
  58. data/share/htdocs/graph/js/line_chart_with_focus.js +10 -9
  59. data/share/htdocs/graph/js/multi_barchart.js +33 -30
  60. data/share/htdocs/graph/js/network2.js +98 -97
  61. data/share/htdocs/graph/js/pie_chart2.js +25 -23
  62. data/share/htdocs/graph/js/scatter_plot.js +38 -36
  63. data/share/htdocs/graph/js/table2.js +60 -54
  64. data/share/htdocs/js/app.js +43 -0
  65. data/share/htdocs/js/{data_source2.js → data_source3.js} +44 -73
  66. data/share/htdocs/js/data_source_repo.js +42 -0
  67. data/share/htdocs/require/nv_d3.js +2 -0
  68. data/share/htdocs/theme/abstract/abstract.js +4 -4
  69. data/share/htdocs/vendor/VERSION_MAP.yaml +2 -0
  70. data/share/htdocs/vendor/require-2.1.8/require.js +2053 -0
  71. data/share/htdocs/vendor/require-2.1.8/require.min.js +36 -0
  72. data/share/htdocs/vendor/require-css-0.0.7/.gitignore +1 -0
  73. data/share/htdocs/vendor/require-css-0.0.7/LICENSE +10 -0
  74. data/share/htdocs/vendor/require-css-0.0.7/README.md +231 -0
  75. data/share/htdocs/vendor/require-css-0.0.7/bower.json +5 -0
  76. data/share/htdocs/vendor/require-css-0.0.7/css-builder.js +251 -0
  77. data/share/htdocs/vendor/require-css-0.0.7/css.js +436 -0
  78. data/share/htdocs/vendor/require-css-0.0.7/normalize.js +138 -0
  79. data/share/htdocs/vendor/require-css-0.0.7/package.json +5 -0
  80. data/share/htdocs/vendor/spin/jquery.spin.js +6 -4
  81. metadata +100 -74
  82. checksums.yaml +0 -7
  83. data/bin/omf_web_demo +0 -3
  84. data/bin/omf_web_demo.sh +0 -7
  85. data/bin/omf_web_server.rb +0 -157
  86. data/lib/omf_common/lobject.rb +0 -187
  87. data/lib/omf_common/log4r_outputter.rb +0 -69
  88. data/sample.sq3 +0 -0
  89. data/share/htdocs/js/data_source.js +0 -173
  90. data/share/htdocs/js/require3.js +0 -292
@@ -1,7 +1,4 @@
1
-
2
- L.provide('OML.abstract_widget', ["vendor/d3/d3.js"], function () {
3
-
4
- if (typeof(OML) == "undefined") OML = {};
1
+ define(['omf/data_source_repo', 'vendor/d3/d3'], function(ds_repo) {
5
2
 
6
3
  if (typeof(d3.each) == 'undefined') {
7
4
  d3.each = function(array, f) {
@@ -15,10 +12,10 @@ L.provide('OML.abstract_widget', ["vendor/d3/d3.js"], function () {
15
12
  return a;
16
13
  };
17
14
  };
18
-
19
-
20
- OML['abstract_widget'] = Backbone.Model.extend({
21
-
15
+
16
+
17
+ var abstract_widget = Backbone.Model.extend({
18
+
22
19
  defaults: function() {
23
20
  return {
24
21
  base_el: "body",
@@ -34,44 +31,44 @@ L.provide('OML.abstract_widget', ["vendor/d3/d3.js"], function () {
34
31
  x: 0,
35
32
  y: 0
36
33
  },
37
- }
34
+ }
38
35
  },
39
-
36
+
40
37
  //base_css_class: 'oml-chart',
41
-
38
+
42
39
  initialize: function(opts) {
43
40
  var o = this.opts = this.deep_defaults(opts, this.defaults());
44
-
41
+
45
42
  var base_el = o.base_el;
46
43
  if (typeof(base_el) == "string") base_el = d3.select(base_el);
47
44
  this.base_el = base_el;
48
-
45
+
49
46
  this.init_data_source();
50
47
  this.process_schema();
51
48
  this.resize();
52
-
49
+
53
50
  var self = this;
54
51
  OHUB.bind('layout.resize', function(e) {
55
52
  self.resize();
56
53
  self.update();
57
- });
54
+ });
58
55
  },
59
-
56
+
60
57
  update: function() {
61
58
  if ($(this.opts.base_el).is(':hidden')) {
62
59
  return;
63
60
  }
64
-
61
+
65
62
  var data;
66
63
  if ((data = this.data_source.rows()) == null) {
67
64
  throw "Missing rows in data source"
68
65
  }
69
66
  if (data.length == 0) return;
70
-
67
+
71
68
  this.redraw(data);
72
-
69
+
73
70
  },
74
-
71
+
75
72
  resize: function() {
76
73
  var o = this.opts;
77
74
  var w = o.width;
@@ -87,9 +84,9 @@ L.provide('OML.abstract_widget', ["vendor/d3/d3.js"], function () {
87
84
  var elw = bel.width();
88
85
  w = w * elw;
89
86
  //w = w * this.base_el[0][0].clientWidth;
90
- if (isNaN(w)) w = 800;
87
+ if (isNaN(w)) w = 800;
91
88
  }
92
-
89
+
93
90
  var h = o.height;
94
91
  if (h <= 1.0) {
95
92
  h = h * w;
@@ -98,30 +95,30 @@ L.provide('OML.abstract_widget', ["vendor/d3/d3.js"], function () {
98
95
 
99
96
  return this;
100
97
  },
101
-
102
-
103
- _resize_base_el: function(w, h) {
98
+
99
+
100
+ _resize_base_el: function(w, h) {
104
101
  var m = this.opts.margin;
105
102
  this.w = w - m.left - m.right; // take away the margins
106
103
  this.h = h - m.top - m.bottom;
107
104
  this.base_el
108
105
  .style('height', this.h + 'px')
109
- .style('width', this.w + 'px')
106
+ .style('width', this.w + 'px')
110
107
  .style('margin-left', m.left + 'px')
111
- .style('margin-right', m.right + 'px')
112
- .style('margin-top', m.top + 'px')
113
- .style('margin-bottom', m.bottom + 'px')
108
+ .style('margin-right', m.right + 'px')
109
+ .style('margin-top', m.top + 'px')
110
+ .style('margin-bottom', m.bottom + 'px')
114
111
  ;
115
112
  },
116
-
117
-
113
+
114
+
118
115
  // Find the appropriate data source and bind to it
119
116
  //
120
117
  init_data_source: function() {
121
118
  var o = this.opts;
122
119
  var sources = o.data_sources;
123
120
  var self = this;
124
-
121
+
125
122
  if (! (sources instanceof Array)) {
126
123
  throw "Expected an array"
127
124
  }
@@ -130,27 +127,27 @@ L.provide('OML.abstract_widget', ["vendor/d3/d3.js"], function () {
130
127
  }
131
128
  this.data_source = this.init_single_data_source(sources[0]);
132
129
  },
133
-
134
-
130
+
131
+
135
132
  // Find the appropriate data source and bind to it
136
133
  //
137
134
  init_single_data_source: function(ds_descr) {
138
- var ds = OML.data_sources.lookup(ds_descr.stream);
135
+ var ds = ds_repo.lookup(ds_descr.stream);
139
136
  var self = this;
140
137
  OHUB.bind(ds.event_name, function() {
141
138
  self.update();;
142
139
  })
143
140
  return ds;
144
141
  },
145
-
146
-
142
+
143
+
147
144
  process_schema: function() {
148
145
  this.schema = this.process_single_schema(this.data_source);
149
146
  if (typeof(this.decl_properties) != "undefined") {
150
147
  this.mapping = this.process_single_mapping(null, this.opts.mapping, this.decl_properties);
151
148
  }
152
149
  },
153
-
150
+
154
151
  process_single_schema: function(data_source) {
155
152
  var self = this;
156
153
  var o = this.opts;
@@ -161,11 +158,11 @@ L.provide('OML.abstract_widget', ["vendor/d3/d3.js"], function () {
161
158
  });
162
159
  return schema;
163
160
  },
164
-
161
+
165
162
  process_single_mapping: function(source_name, mapping_decl, properties_decl) {
166
163
  var self = this;
167
164
  var m = {};
168
- var om = mapping_decl || {};
165
+ var om = mapping_decl || {};
169
166
  _.map(properties_decl, function(a) {
170
167
  var pname = a[0]; var type = a[1]; var def = a[2];
171
168
  var descr = om[pname];
@@ -182,8 +179,8 @@ L.provide('OML.abstract_widget', ["vendor/d3/d3.js"], function () {
182
179
  throw "Can't provide named stream '" + stream + "'.";
183
180
  }
184
181
  return this.schema;
185
- },
186
-
182
+ },
183
+
187
184
  /*
188
185
  * Return data_source named 'name'.
189
186
  */
@@ -192,7 +189,7 @@ L.provide('OML.abstract_widget', ["vendor/d3/d3.js"], function () {
192
189
  throw "Can't provide named stream '" + name + "'.";
193
190
  }
194
191
  return this.data_source;
195
- },
192
+ },
196
193
 
197
194
  create_mapping: function(mname, descr, stream, type, def) {
198
195
  var self = this;
@@ -223,7 +220,7 @@ L.provide('OML.abstract_widget', ["vendor/d3/d3.js"], function () {
223
220
  if (schema == undefined) {
224
221
  throw "Can't find schema for stream '" + stream + "'.";
225
222
  }
226
-
223
+
227
224
  if (type == 'index') {
228
225
  var key = descr.key;
229
226
  if (key == undefined || stream == undefined) {
@@ -234,7 +231,7 @@ L.provide('OML.abstract_widget', ["vendor/d3/d3.js"], function () {
234
231
  throw "Unknown stream element '" + key + "'.";
235
232
  }
236
233
  var vindex = col_schema.index;
237
-
234
+
238
235
  var jstream_name = descr.join_stream;
239
236
  if (jstream_name == undefined) {
240
237
  throw "Missing join stream declaration in '" + mname + "'.";
@@ -244,15 +241,15 @@ L.provide('OML.abstract_widget', ["vendor/d3/d3.js"], function () {
244
241
  throw "Can't find schema for stream '" + jstream_name + "'.";
245
242
  }
246
243
  var jstream = this.data_source_for_stream(jstream_name);
247
-
244
+
248
245
  var jkey = descr.join_key;
249
246
  if (jkey == undefined) jkey = 'id';
250
- var jcol_schema = jschema[jkey];
247
+ var jcol_schema = jschema[jkey];
251
248
  if (jcol_schema == undefined) {
252
249
  throw "Unknown stream element '" + jkey + "' in '" + jstream + "'.";
253
250
  }
254
251
  var index_f = jstream.index_for_column(jcol_schema);
255
-
252
+
256
253
  return function(d) {
257
254
  var join = d[vindex];
258
255
  //var t = jstream.get_indexed_row(jindex, join); //self.get_indexed_table(jstream, jindex);
@@ -282,35 +279,35 @@ L.provide('OML.abstract_widget', ["vendor/d3/d3.js"], function () {
282
279
  }
283
280
  var index = col_schema.index;
284
281
  switch (type) {
285
- case 'int':
286
- case 'float':
282
+ case 'int':
283
+ case 'float':
287
284
  case 'key' :
288
285
  var scale = descr.scale;
289
286
  var min_value = descr.min;
290
287
  var max_value = descr.max;
291
288
  return function(d) {
292
289
  var v = d[index];
293
- if (scale != undefined) v = v * scale;
294
- if (min_value != undefined && v < min_value) v = min_value;
295
- if (max_value != undefined && v > max_value) v = max_value;
290
+ if (scale != undefined) v = v * scale;
291
+ if (min_value != undefined && v < min_value) v = min_value;
292
+ if (max_value != undefined && v > max_value) v = max_value;
296
293
  return v;
297
294
  };
298
- case 'color':
295
+ case 'color':
299
296
  var color_fname = descr.color;
300
297
  if (color_fname == undefined) {
301
298
  throw "Missing color function for '" + mname + "'.";
302
- }
299
+ }
303
300
  var color_fp = self.decl_color_func[color_fname];
304
301
  if (color_fp == undefined) {
305
302
  throw "Unknown color function '" + color_fname + "'.";
306
- }
303
+ }
307
304
  var color_f = color_fp();
308
305
  var scale = descr.scale;
309
306
  var min_value = descr.min;
310
307
  return function(d) {
311
308
  var v = d[index];
312
- if (scale != undefined) v = v * scale;
313
- if (min_value != undefined && v < min_value) v = min_value;
309
+ if (scale != undefined) v = v * scale;
310
+ if (min_value != undefined && v < min_value) v = min_value;
314
311
  var color = color_f(v);
315
312
  return color;
316
313
  };
@@ -318,14 +315,14 @@ L.provide('OML.abstract_widget', ["vendor/d3/d3.js"], function () {
318
315
  // return function(d) {
319
316
  // return d[index];
320
317
  // }
321
- default:
318
+ default:
322
319
  throw "Unknown mapping type '" + type + "'";
323
320
  }
324
321
  }
325
322
  var i = 0;
326
323
  },
327
324
 
328
-
325
+
329
326
  // Fill in a given object (and any objects it contains) with default properties.
330
327
  // ... borrowed from unerscore.js
331
328
  //
@@ -339,7 +336,9 @@ L.provide('OML.abstract_widget', ["vendor/d3/d3.js"], function () {
339
336
  }
340
337
  return source;
341
338
  },
342
-
343
-
339
+
340
+
344
341
  });
342
+
343
+ return abstract_widget;
345
344
  })
@@ -1,34 +1,35 @@
1
1
  //L.provide('OML.axis', ["graph.css", ["/resource/vendor/d3/d3.js", "/resource/vendor/d3/d3.time.js"]], function () {
2
- L.provide('OML.axis', ["graph/css/graph.css", "vendor/d3/d3.js"], function () {
2
+ //L.provide('OML.axis', ["graph/css/graph.css", "vendor/d3/d3.js"], function () {
3
+ define(["vendor/d3/d3"], function () {
3
4
 
4
- OML.line_chart2_axis = function(options) {
5
+ var axis = function(options) {
5
6
  if (!options) options = {};
6
-
7
+
7
8
  var d3_axis = d3.svg.axis();
8
9
 
9
10
  var defaults = {
10
11
  legend: {
11
12
  text: 'DESCRIBE ME',
12
- offset: 40
13
+ offset: 40
13
14
  },
14
15
  ticks: {
15
16
  // type: 'date',
16
17
  // format: '%I:%M', // hour:minutes
17
18
  // format: ",.0f" // integers with comma-grouping for thousands.
18
19
  transition: 500 // smoothly transition the ticks when they change
19
- }
20
+ }
20
21
  };
21
22
 
22
23
  var orient = 'bottom';
23
24
  var scale;
24
25
  var range = [0, 100]; // default range, should be set specifically
25
26
  var opts = _.defaults((options || {}), defaults);
26
-
27
+
27
28
  // LEGEND
28
29
  var ol = options.legend;
29
30
  ol = ol ? (typeof(ol) === "string" ? {text: ol} : ol) : {};
30
- options.legend = _.defaults(ol, defaults.legend);
31
-
31
+ options.legend = _.defaults(ol, defaults.legend);
32
+
32
33
  // TICKS
33
34
  var ot = options.ticks = _.defaults(options.ticks, defaults.ticks);
34
35
  // Check if we need a special formatter for the tick labels
@@ -36,7 +37,7 @@ L.provide('OML.axis', ["graph/css/graph.css", "vendor/d3/d3.js"], function () {
36
37
  var d_f = d3.time.format(ot.format || "%X");
37
38
  d3_axis.tickFormat(function(d) {
38
39
  var date = new Date(1000 * d); // TODO: Implicitly assuming that value is in seconds is most likely NOT a good idea
39
- var fs = d_f(date);
40
+ var fs = d_f(date);
40
41
  return fs;
41
42
  });
42
43
  } else if (ot.type == 'key') {
@@ -45,14 +46,14 @@ L.provide('OML.axis', ["graph/css/graph.css", "vendor/d3/d3.js"], function () {
45
46
  var l = lm[d] || ('??-' + d);
46
47
  return l;
47
48
  });
48
-
49
+
49
50
  } else if (ot.format) {
50
51
  d3_axis.tickFormat(d3.format(ot.format));
51
52
  }
52
-
53
+
53
54
  if (count = ot.count) d3_axis.ticks(count);
54
-
55
-
55
+
56
+
56
57
  function axis(selection) {
57
58
  selection.each(function(data) {
58
59
  var o = opts;
@@ -71,7 +72,7 @@ L.provide('OML.axis', ["graph/css/graph.css", "vendor/d3/d3.js"], function () {
71
72
  case 'left':
72
73
  axisLabel.enter().append('text').attr('class', 'axis_legend')
73
74
  .attr('transform', 'rotate(-90)')
74
- .attr('y', -1 * ol.offset);
75
+ .attr('y', -1 * ol.offset);
75
76
  axisLabel
76
77
  .attr('x', -1 * (range[1] - range[0]) / 2);
77
78
  break;
@@ -80,52 +81,56 @@ L.provide('OML.axis', ["graph/css/graph.css", "vendor/d3/d3.js"], function () {
80
81
  axisLabel
81
82
  .text(function(d) { return d });
82
83
 
83
- // TICKS
84
+ // TICKS
84
85
  var ot = opts.ticks;
85
86
  var tl = ot.transition ? layer.transition().duration(ot.transition) : layer;
86
87
  tl.call(d3_axis);
87
-
88
+
88
89
  // d3.select(this).selectAll('line.tick')
89
90
  // //.filter(function(d) { return !parseFloat(d) })
90
91
  // .filter(function(d) {
91
- // //this is because sometimes the 0 tick is a very small fraction, TODO: think of cleaner technique
92
+ // //this is because sometimes the 0 tick is a very small fraction, TODO: think of cleaner technique
92
93
  // var v = !parseFloat(Math.round(d*100000)/1000000);
93
- // return v;
94
- // })
94
+ // return v;
95
+ // })
95
96
  // .classed('zero', true);
96
97
  });
97
98
  return axis;
98
- }
99
-
99
+ }
100
+
100
101
  axis.orient = function(_) {
101
102
  if (!arguments.length) return orient;
102
103
  orient = _;
103
104
  d3_axis.orient(orient);
104
105
  return axis;
105
106
  };
106
-
107
+
107
108
  axis.range = function(_) {
108
109
  if (!arguments.length) return range;
109
110
  range = _;
110
111
  return axis;
111
112
  };
112
-
113
+
113
114
  axis.scale = function(_) {
114
115
  if (!arguments.length) return scale;
115
116
  scale = _;
116
117
  d3_axis.scale(scale);
117
118
  return axis;
118
119
  };
119
-
120
+
120
121
  axis.tick_values = function(_) {
121
122
  if (!arguments.length) return scale;
122
123
  values = _;
123
124
  d3_axis.tickValues(values);
124
125
  return axis;
125
126
  };
126
-
127
+
127
128
  return axis;
128
129
  }
130
+
131
+ return function(opts) {
132
+ return axis(opts);
133
+ }
129
134
  })
130
135
 
131
136
  /*
@@ -1,58 +1,58 @@
1
1
  /*
2
- * Draws a simple barchart wiht a slection brush.
3
- *
2
+ * Draws a simple barchart with a selection brush.
3
+ *
4
4
  * Most code was copied from http://square.github.com/crossfilter/ and all that
5
5
  * credit goes to Mike Bostok.
6
6
  */
7
7
 
8
8
 
9
- L.provide('OML.barchart_brush', ["graph/js/abstract_chart", "#OML.abstract_chart"], function () {
9
+ define("graph/js/abstract_chart"], function (abstract_chart) {
10
10
 
11
- OML.barchart_brush = OML.abstract_chart.extend({
11
+ var barchart_brush = abstract_chart.extend({
12
12
  decl_properties: [
13
- ['key', 'int', {property: 'key'}],
14
- ['value', 'float', {property: 'value'}],
15
- // ['x_axis', 'key', {property: 'x'}],
16
- // ['y_axis', 'key', {property: 'y'}],
17
- // ['group_by', 'key', {property: 'id', optional: true}],
18
- ['stroke_width', 'int', 2],
13
+ ['key', 'int', {property: 'key'}],
14
+ ['value', 'float', {property: 'value'}],
15
+ // ['x_axis', 'key', {property: 'x'}],
16
+ // ['y_axis', 'key', {property: 'y'}],
17
+ // ['group_by', 'key', {property: 'id', optional: true}],
18
+ ['stroke_width', 'int', 2],
19
19
  ['stroke_color', 'color', 'white'],
20
20
  ['fill_color', 'color', 'blue']
21
21
  ],
22
-
22
+
23
23
  defaults: function() {
24
24
  return this.deep_defaults({
25
25
  relative: false, // If true, report percentage
26
26
  axis: {
27
27
  orientation: 'horizontal'
28
28
  }
29
- }, OML.barchart_brush.__super__.defaults.call(this));
29
+ }, barchart_brush.__super__.defaults.call(this));
30
30
  },
31
-
31
+
32
32
  configure_base_layer: function(vis) {
33
33
  var base = this.base_layer = vis.append("svg:g")
34
34
  .attr("class", "barchart")
35
35
  ;
36
- var ca = this.chart_area;
36
+ var ca = this.chart_area;
37
37
  this.legend_layer = base.append("svg:g");
38
38
  this.chart_layer = base.append("svg:g");
39
39
  this.axis_layer = base.append('g');
40
40
  },
41
-
41
+
42
42
  redraw: function(data) {
43
-
44
- }
45
- }) // end of barchart_brush
43
+
44
+ }
45
+ }) // end of barchart_brush
46
46
 
47
47
 
48
48
 
49
- OML._barchart_brush = function barChart() {
50
- if (!OML._barchart_brush.id) OML._barchart_brush.id = 0;
49
+ var _barchart_brush = function barChart() {
50
+ if (!_barchart_brush.id) _barchart_brush.id = 0;
51
51
 
52
52
  var margin = {top: 10, right: 10, bottom: 20, left: 10},
53
53
  x,
54
54
  y = d3.scale.linear().range([100, 0]),
55
- id = OML._barchart_brush.id++,
55
+ id = _barchart_brush.id++,
56
56
  axis = d3.svg.axis().orient("bottom"),
57
57
  brush = d3.svg.brush(),
58
58
  brushDirty,
@@ -237,4 +237,6 @@ L.provide('OML.barchart_brush', ["graph/js/abstract_chart", "#OML.abstract_chart
237
237
 
238
238
  return d3.rebind(chart, brush, "on");
239
239
  }
240
+
241
+ return barchart_brush;
240
242
  });
@@ -1,7 +1,7 @@
1
- L.provide('OML.code_mirror', ["graph/js/abstract_widget", "#OML.abstract_widget"], function () {
1
+ define(["graph/abstract_widget"], function (abstract_widget) {
2
+
3
+ var code_mirror = abstract_widget.extend({
2
4
 
3
- OML.code_mirror = OML.abstract_widget.extend({
4
-
5
5
  defaults: function() {
6
6
  return this.deep_defaults({
7
7
  height: 1.0,
@@ -11,33 +11,33 @@ L.provide('OML.code_mirror', ["graph/js/abstract_widget", "#OML.abstract_widget"
11
11
  right: 20,
12
12
  bottom: 10
13
13
  },
14
- }, OML.code_mirror.__super__.defaults.call(this));
15
- },
16
-
17
-
14
+ }, code_mirror.__super__.defaults.call(this));
15
+ },
16
+
17
+
18
18
  initialize: function(opts) {
19
- OML.code_mirror.__super__.initialize.call(this, opts);
19
+ code_mirror.__super__.initialize.call(this, opts);
20
20
  this.code_mirror = null;
21
21
  this.update();
22
22
  },
23
-
23
+
24
24
  update: function() {
25
25
  var o = this.opts;
26
-
26
+
27
27
  if ($(o.base_el).is(':hidden')) {
28
28
  this.code_mirror = null;
29
29
  return;
30
30
  }
31
31
 
32
- // TODO: When we create a code mirror object and then make the
33
- // encompassing element invisible and visible again, things seem
34
- // go astray. Brute force solution is to recreate the editor on every
32
+ // TODO: When we create a code mirror object and then make the
33
+ // encompassing element invisible and visible again, things seem
34
+ // go astray. Brute force solution is to recreate the editor on every
35
35
  // update.
36
-
36
+
37
37
  if (!this.code_mirror) {
38
38
  var edit_el = $(o.edit_el);
39
39
  edit_el.empty(); // remove old instances if any
40
-
40
+
41
41
  CodeMirror.modeURL = "/resource/vendor/codemirror/mode/%N/%N.js";
42
42
 
43
43
  var self = this;
@@ -60,22 +60,22 @@ L.provide('OML.code_mirror', ["graph/js/abstract_widget", "#OML.abstract_widget"
60
60
  CodeMirror.autoLoadMode(cm, o.mode);
61
61
 
62
62
  var hlLine = cm.setLineClass(0, "activeline");
63
-
63
+
64
64
  this.on_changed(this.code_mirror, null);
65
65
  this.code_mirror.focus();
66
66
  }
67
67
  this._update_widget_height(o);
68
68
  this.code_mirror.refresh();
69
69
  },
70
-
70
+
71
71
  _update_widget_height: function(opts) {
72
72
  var s_el = $(opts.base_el + " .CodeMirror-scroll");
73
- s_el.css('height', this.h);
73
+ s_el.css('height', this.h);
74
74
  },
75
-
75
+
76
76
  on_changed: function(editor, change) {
77
77
  if (editor == undefined) return;
78
-
78
+
79
79
  var o = this.opts;
80
80
  var h = editor.historySize();
81
81
 
@@ -84,41 +84,43 @@ L.provide('OML.code_mirror', ["graph/js/abstract_widget", "#OML.abstract_widget"
84
84
  var redo = h.redo > 0;
85
85
  $(o.base_el + '_save_a').fadeTo('fast', save ? 1.0 : 0.3);
86
86
  $(o.base_el + '_undo_a').fadeTo('fast', undo ? 1.0 : 0.3);
87
- $(o.base_el + '_redo_a').fadeTo('fast', redo ? 1.0 : 0.3);
87
+ $(o.base_el + '_redo_a').fadeTo('fast', redo ? 1.0 : 0.3);
88
88
  },
89
-
89
+
90
90
  on_save_pressed: function() {
91
91
  var o = this.opts;
92
92
  var self = this;
93
93
  var cm = this.code_mirror;
94
-
94
+
95
95
  $.ajax({
96
96
  url: o.save_url,
97
97
  data: {content: cm.getValue()},
98
98
  type: 'POST'
99
- }).done(function() {
99
+ }).done(function() {
100
100
  cm.clearHistory();
101
101
  self.on_changed(cm, null);
102
102
  OHUB.trigger('content.changed.' + o.content_id, {});
103
103
  });
104
104
  },
105
-
105
+
106
106
  on_undo_pressed: function() {
107
107
  this.code_mirror.undo();
108
108
  },
109
-
109
+
110
110
  on_redo_pressed: function() {
111
111
  this.code_mirror.redo();
112
112
  },
113
113
 
114
114
  resize: function() {
115
- OML.code_mirror.__super__.resize.call(this);
116
- var i = 0;
115
+ code_mirror.__super__.resize.call(this);
116
+ var i = 0;
117
117
  },
118
-
118
+
119
119
  init_data_source: function() {},
120
120
  process_schema: function() {},
121
-
122
- }) /* end of OML.code_mirror */
123
-
124
- }) /* end of L.provide */
121
+
122
+ }); /* end of code_mirror */
123
+
124
+ return code_mirror;
125
+
126
+ });