forked from jupyter-widgets/ipyleaflet
-
Notifications
You must be signed in to change notification settings - Fork 7
/
utils.js
31 lines (27 loc) · 936 Bytes
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var widgets = require('@jupyter-widgets/base');
var _ = require('underscore');
function camel_case(input) {
// Convert from foo_bar to fooBar
return input.toLowerCase().replace(/_(.)/g, function(match, group1) {
return group1.toUpperCase();
});
}
var leaflet_views_common_methods = {
get_options: function () {
var o = this.model.get('options');
var options = {};
var key;
for (var i=0; i<o.length; i++) {
key = o[i];
// Convert from foo_bar to fooBar that Leaflet.js uses
options[camel_case(key)] = this.model.get(key);
}
return options;
}
}
var LeafletWidgetView = widgets.WidgetView.extend(leaflet_views_common_methods);
var LeafletDOMWidgetView = widgets.DOMWidgetView.extend(leaflet_views_common_methods);
module.exports = {
LeafletWidgetView : LeafletWidgetView,
LeafletDOMWidgetView : LeafletDOMWidgetView,
}