def __init__(self, html=None, parse_html=False, max_width='100%', show=False, sticky=False): super(Popup, self).__init__() self._name = 'Popup' self.header = Element() self.html = Element() self.script = Element() self.header._parent = self self.html._parent = self self.script._parent = self script = not parse_html if isinstance(html, Element): self.html.add_child(html) elif isinstance(html, text_type) or isinstance(html, binary_type): self.html.add_child(Html(text_type(html), script=script)) self.max_width = max_width self.show = show self.sticky = sticky
def __init__(self, html=None, parse_html=False, max_width=300): super(Popup, self).__init__() self._name = 'Popup' self.header = Element() self.html = Element() self.script = Element() self.header._parent = self self.html._parent = self self.script._parent = self script = not parse_html if isinstance(html, Element): self.html.add_child(html) elif isinstance(html, text_type) or isinstance(html, binary_type): self.html.add_child(Html(text_type(html), script=script)) self.max_width = max_width self._template = Template(u""" var {{this.get_name()}} = L.popup({maxWidth: '{{this.max_width}}'}); {% for name, element in this.html._children.items() %} var {{name}} = $('{{element.render(**kwargs).replace('\\n',' ')}}')[0]; {{this.get_name()}}.setContent({{name}}); {% endfor %} {{this._parent.get_name()}}.bindPopup({{this.get_name()}}); {% for name, element in this.script._children.items() %} {{element.render()}} {% endfor %} """) # noqa
def __init__(self, html=None, parse_html=False, max_width='100%', show=False, sticky=False, **kwargs): super(Popup, self).__init__() self._name = 'Popup' self.header = Element() self.html = Element() self.script = Element() self.header._parent = self self.html._parent = self self.script._parent = self script = not parse_html if isinstance(html, Element): self.html.add_child(html) elif isinstance(html, str): self.html.add_child(Html(html, script=script)) self.show = show self.options = parse_options( max_width=max_width, autoClose=False if show or sticky else None, closeOnClick=False if sticky else None, **kwargs)