def get_legends(self): if len(self.layers) > 1: items = [] total = 0 repr_attrs = dict(class_='pull-right stay-open', style="padding-right: 10px;") for layer in self.layers: representation = '' if hasattr(layer, 'representation'): total += layer.representation representation = HTML.span(str(layer.representation), **repr_attrs) items.append([ HTML.label( HTML.input( class_="stay-open", type="checkbox", checked="checked", onclick=helpers.JS_CLLD.mapToggleLayer( self.eid, layer.id, helpers.JS("this"))), getattr(layer, 'marker', ''), layer.name, class_="checkbox inline stay-open", style="margin-left: 5px; margin-right: 5px;", ), representation, ]) if total: items.append(HTML.span(HTML.b(str(total)), **repr_attrs)) yield Legend( self, 'layers', items, label='Legend', stay_open=True, item_attrs=dict(style='clear: right')) items = [] for size in [15, 20, 30, 40]: attrs = dict(name="iconsize", value=str(size), type="radio") if size == self.options.get('icon_size', 30): attrs['checked'] = 'checked' items.append(HTML.label( HTML.input(onclick=helpers.JS_CLLD.mapResizeIcons(self.eid), **attrs), HTML.img( height=str(size), width=str(size), src=self.req.registry.getUtility(IIcon, 'cff6600').url(self.req)), class_="radio", style="margin-left: 5px; margin-right: 5px;")) yield Legend( self, 'iconsize', items, label='Icon size') item = lambda layer: HTML.a( layer.name, onclick='return %s;' % helpers.JS_CLLD.mapShowGeojson(self.eid, layer.id), href=layer.data if isinstance(layer.data, basestring) else '#') yield Legend( self, 'geojson', map(item, self.layers), label='GeoJSON', pull_right=True)
def get_legends(self): if len(self.layers) > 1: items = [] total = 0 repr_attrs = dict(class_='pull-right stay-open', style="padding-right: 10px;") for layer in self.layers: representation = '' if hasattr(layer, 'representation'): total += layer.representation representation = HTML.span(str(layer.representation), **repr_attrs) items.append([ HTML.label( HTML.input( class_="stay-open", type="checkbox", checked="checked", onclick=helpers.JS_CLLD.mapToggleLayer( self.eid, layer.id, helpers.JS("this"))), getattr(layer, 'marker', ''), layer.name, class_="checkbox inline stay-open", style="margin-left: 5px; margin-right: 5px;", ), representation, ]) if total: items.append(HTML.span(HTML.b(str(total)), **repr_attrs)) yield Legend( self, 'layers', items, label='Legend', stay_open=True, item_attrs=dict(style='clear: right')) items = [] for size in [15, 20, 30, 40]: attrs = dict(name="iconsize", value=str(size), type="radio") if size == self.options.get('icon_size', 30): attrs['checked'] = 'checked' items.append(HTML.label( HTML.input(onclick=helpers.JS_CLLD.mapResizeIcons(self.eid), **attrs), HTML.img( height=str(size), width=str(size), src=self.req.registry.getUtility(IIcon, 'cff6600').url(self.req)), class_="radio", style="margin-left: 5px; margin-right: 5px;")) yield Legend( self, 'iconsize', items, label='Icon size') item = lambda layer: HTML.a( layer.name, onclick='return %s;' % helpers.JS_CLLD.mapShowGeojson(self.eid, layer.id), href=layer.data if isinstance(layer.data, string_types) else '#') yield Legend( self, 'geojson', map(item, self.layers), label='GeoJSON', pull_right=True)
def render(self): a_attrs = { 'class': 'dropdown-toggle', 'data-toggle': "dropdown", 'href': "#", 'id': self.format_id('opener') } ul_class = 'dropdown-menu' if self.stay_open: ul_class += ' stay-open' return HTML.li( HTML.a(self.label, HTML.b(class_='caret'), **a_attrs), HTML.ul(*map(self.render_item, self.items), **dict(class_=ul_class, id=self.format_id('container'))), class_='dropdown' + (' pull-right' if self.pull_right else ''), id=self.format_id(), )
def render(self): a_attrs = { 'class': 'dropdown-toggle', 'data-toggle': "dropdown", 'href': "#", 'id': self.format_id('opener')} ul_class = 'dropdown-menu' if self.stay_open: ul_class += ' stay-open' return HTML.li( HTML.a(self.label, HTML.b(class_='caret'), **a_attrs), HTML.ul( *map(self.render_item, self.items), **dict(class_=ul_class, id=self.format_id('container'))), class_='dropdown', id=self.format_id(), )