Skip to content

Commit f40bd8c

Browse files
committed
After review comments
1 parent 970be82 commit f40bd8c

File tree

3 files changed

+17
-23
lines changed

3 files changed

+17
-23
lines changed

folium/folium.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,9 @@ class Map(JSCSSMixin, Evented):
210210
}
211211
</style>
212212
213-
214213
<script>
215-
L_NO_TOUCH = {{ this.no_touch |tojson}};
216-
L_DISABLE_3D = {{ this.disable_3d|tojson }};
214+
L_NO_TOUCH = {{ this.global_switches.no_touch |tojson}};
215+
L_DISABLE_3D = {{ this.global_switches.disable_3d|tojson }};
217216
</script>
218217
219218
{% endmacro %}
@@ -328,8 +327,7 @@ def __init__(
328327
else:
329328
self.zoom_control_position = False
330329

331-
self.no_touch = no_touch
332-
self.disable_3d = disable_3d
330+
self.global_switches = GlobalSwitches(no_touch, disable_3d)
333331

334332
self.options = remove_empty(
335333
max_bounds=max_bounds_array,

tests/test_folium.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ def test_init(self):
9898
assert self.m.width == (900, "px")
9999
assert self.m.left == (0, "%")
100100
assert self.m.top == (0, "%")
101-
assert self.m.no_touch is False
102-
assert self.m.disable_3d is False
101+
assert self.m.global_switches.no_touch is False
102+
assert self.m.global_switches.disable_3d is False
103103
assert self.m.font_size == "1.5rem"
104104
assert self.m.to_dict() == {
105105
"name": "Map",
@@ -465,29 +465,29 @@ def test_global_switches(self):
465465
out = m._parent.render()
466466
out_str = "".join(out.split())
467467
assert '"preferCanvas":true' in out_str
468-
assert not m.no_touch
469-
assert not m.disable_3d
468+
assert not m.global_switches.no_touch
469+
assert not m.global_switches.disable_3d
470470

471471
m = folium.Map(no_touch=True)
472472
out = m._parent.render()
473473
out_str = "".join(out.split())
474474
assert '"preferCanvas":false' in out_str
475-
assert m.no_touch
476-
assert not m.disable_3d
475+
assert m.global_switches.no_touch
476+
assert not m.global_switches.disable_3d
477477

478478
m = folium.Map(disable_3d=True)
479479
out = m._parent.render()
480480
out_str = "".join(out.split())
481481
assert '"preferCanvas":false' in out_str
482-
assert not m.no_touch
483-
assert m.disable_3d
482+
assert not m.global_switches.no_touch
483+
assert m.global_switches.disable_3d
484484

485485
m = folium.Map(prefer_canvas=True, no_touch=True, disable_3d=True)
486486
out = m._parent.render()
487487
out_str = "".join(out.split())
488488
assert '"preferCanvas":true' in out_str
489-
assert m.no_touch
490-
assert m.disable_3d
489+
assert m.global_switches.no_touch
490+
assert m.global_switches.disable_3d
491491

492492
def test_json_request(self):
493493
"""Test requests for remote GeoJSON files."""

tests/test_map.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ def test_popup_unicode():
109109
def test_popup_sticky():
110110
m = Map()
111111
popup = Popup("Some text.", sticky=True).add_to(m)
112-
script = popup._template.module.__dict__.get("script", None)
113-
rendered = script(this=popup, kwargs={})
112+
rendered = popup._template.render(this=popup, kwargs={})
114113
expected = """
115114
var {popup_name} = L.popup({{
116115
"maxWidth": "100%",
@@ -132,8 +131,7 @@ def test_popup_sticky():
132131
def test_popup_show():
133132
m = Map()
134133
popup = Popup("Some text.", show=True).add_to(m)
135-
script = popup._template.module.__dict__.get("script", None)
136-
rendered = script(this=popup, kwargs={})
134+
rendered = popup._template.render(this=popup, kwargs={})
137135
expected = """
138136
var {popup_name} = L.popup({{
139137
"maxWidth": "100%","autoClose": false,
@@ -153,8 +151,7 @@ def test_popup_show():
153151
def test_popup_backticks():
154152
m = Map()
155153
popup = Popup("back`tick`tick").add_to(m)
156-
script = popup._template.module.__dict__.get("script", None)
157-
rendered = script(this=popup, kwargs={})
154+
rendered = popup._template.render(this=popup, kwargs={})
158155
expected = """
159156
var {popup_name} = L.popup({{
160157
"maxWidth": "100%",
@@ -173,8 +170,7 @@ def test_popup_backticks():
173170
def test_popup_backticks_already_escaped():
174171
m = Map()
175172
popup = Popup("back\\`tick").add_to(m)
176-
script = popup._template.module.__dict__.get("script", None)
177-
rendered = script(this=popup, kwargs={})
173+
rendered = popup._template.render(this=popup, kwargs={})
178174
expected = """
179175
var {popup_name} = L.popup({{
180176
"maxWidth": "100%",

0 commit comments

Comments
 (0)