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): def img(spec): return HTML.img(src=svg.data_url(svg.icon(spec)), height='20', width='20', style='margin-left: 0.5em;') def desc(text): return HTML.span(text, style='margin-left: 0.5em; margin-right: 0.5em;') values = [desc('Most extensive description is a ...')] for sdt in get_parameter('med').domain: icon = self.de_to_icon['med'][sdt.id.split('-')[1]] values.append( HTML.label( HTML.input( type='checkbox', checked='checked', id='marker-toggle-sdt-' + str(sdt.number), onclick='GLOTTOLOG3.LangdocStatus.toggleMarkers()'), img(icon.shape + 'ffffff' if self.focus == 'ed' else 'c' + icon.color), desc(sdt.name))) values.append(desc('Language is ...')) for ed in get_parameter('aes').domain: icon = self.de_to_icon['aes'][ed.id.split('-')[1]] values.append((HTML.label( HTML.input(type='checkbox', checked='checked', id='marker-toggle-ed-' + str(ed.number), onclick='GLOTTOLOG3.LangdocStatus.toggleMarkers()'), img('c' + icon.color if self.focus == 'ed' else icon.shape + 'ffffff'), desc(ed.name.lower())))) yield Legend(self, 'values', values, label='Legend')
def get_legends(self): def img(spec): return HTML.img( src=self.icon_map[spec], height='20', width='20', style='margin-left: 0.5em;') def desc(text): return HTML.span(text, style='margin-left: 0.5em; margin-right: 0.5em;') values = [desc('Most extensive description is a ...')] for sdt in SIMPLIFIED_DOCTYPES: values.append( HTML.label( HTML.input( type='checkbox', checked='checked', id='marker-toggle-sdt-' + str(sdt.ord), onclick='GLOTTOLOG3.LangdocStatus.toggleMarkers()'), img(sdt.shape + 'ffffff' if self.focus == 'ed' else 'c' + sdt.color), desc(sdt.name))) values.append(desc('Language is ...')) for ed in ENDANGERMENTS: values.append(( HTML.label( HTML.input( type='checkbox', checked='checked', id='marker-toggle-ed-' + str(ed.ord), onclick='GLOTTOLOG3.LangdocStatus.toggleMarkers()'), img('c' + ed.color if self.focus == 'ed' else ed.shape + 'ffffff'), desc(ed.name.lower())))) yield Legend(self, 'values', values, label='Legend')
def get_legends(self): def img(spec): return HTML.img( src=self.icon_map[spec], height='20', width='20', style='margin-left: 0.5em;') def desc(text): return HTML.span(text, style='margin-left: 0.5em; margin-right: 0.5em;') values = [desc('Most extensive description is a ...')] for sdt in SIMPLIFIED_DOCTYPES: values.append( HTML.label( HTML.input( type='checkbox', checked='checked', id='marker-toggle-sdt-' + str(sdt.ord), onclick='GLOTTOLOG3.LangdocStatus.toggleMarkers()'), img(sdt.shape + 'ffffff' if self.focus == 'ed' else 'c' + sdt.color), desc(sdt.name))) values.append(desc('Language is ...')) for ed in ENDANGERMENTS: values.append(( HTML.label( HTML.input( type='checkbox', checked='checked', id='marker-toggle-ed-' + str(ed.ord), onclick='GLOTTOLOG3.LangdocStatus.toggleMarkers()'), img('c' + ed.color if self.focus == 'ed' else ed.shape + 'ffffff'), desc(ed.name.lower())))) yield Legend(self, 'values', values, label='Legend')
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 legend_items(req): for type, label in [('recipient', 'recipient language'), ('donor', 'donor languoid')]: yield HTML.label(HTML.img(src=icon_url(req, type), height='20', width='20'), literal(' ' + label), style='margin-left: 1em; margin-right: 1em;')
def get_legends(self): items = [] for biome in DBSession.query(Biome)\ .filter(Biome.description != 'ffffff')\ .order_by(as_int(Biome.id)): items.append( HTML.label( HTML.span( literal(' '), style='background-color: #%s;' % biome.description, class_='biome-color'), literal(biome.name), style='margin-left: 1em; margin-right: 1em;')) yield Legend(self, 'categories', items)
def get_legends(self): items = [] for biome in DBSession.query(Biome)\ .filter(Biome.description != 'ffffff')\ .order_by(as_int(Biome.id)): items.append( HTML.label( HTML.span( literal(' '), style='background-color: #%s;' % biome.description, class_='biome-color'), literal(biome.name), style='margin-left: 1em; margin-right: 1em;')) yield Legend(self, 'categories', items)
def value_li(l): return ( HTML.img(height="20", width="20", src=self.icon_map[l.pk]), literal(' '), languoid_link(self.req, l), literal(' '), HTML.label(HTML.input( type="checkbox", onclick="GLOTTOLOG3.filterMarkers(this);", class_="checkbox inline", checked="checked", value=str(l.pk)), class_="checkbox inline", title="click to toggle markers"), )
def value_li(l): return ( HTML.img(height="20", width="20", src=self.icon_map[l.pk]), literal(' '), languoid_link(self.req, l), literal(' '), HTML.label( HTML.input( type="checkbox", onclick="GLOTTOLOG3.filterMarkers(this);", class_="checkbox inline", checked="checked", value=str(l.pk)), class_="checkbox inline", title="click to toggle markers"), )
def li(label, label_class, input_class, onclick, type_='checkbox', name='', checked=False): input_attrs = dict( type=type_, class_=input_class + ' inline', name=name, value=label, onclick=onclick) if checked: input_attrs['checked'] = 'checked' return HTML.label( HTML.input(**input_attrs), ' ', label, class_="%s" % label_class, style="margin-left:5px; margin-right:5px;", )
def li(self, col, item, value_getter, checked=False): input_attrs = dict( type='radio', class_='stay-open %s inline' % self.jsname, name=self.jsname, value=item[0] if isinstance(item, (tuple, list)) else item, onclick=helpers.JS("CLLD.mapLegendFilter")( self.map.eid, self.name, self.jsname, helpers.JS(value_getter), col.dt.eid if col else None)) if checked: input_attrs['checked'] = 'checked' return HTML.label( HTML.input(**input_attrs), ' ', self.li_label(item), class_="stay-open", style="margin-left:5px; margin-right:5px;", )
def li(self, col, item, value_getter, checked=False): input_attrs = dict( type='radio', class_='stay-open %s inline' % self.jsname, name=self.jsname, value=item[0] if isinstance(item, (tuple, list)) else item, onclick=helpers.JS("CLLD.mapLegendFilter")( self.map.eid, self.name, self.jsname, helpers.JS(value_getter), col.dt.eid if col else None)) if checked: input_attrs['checked'] = 'checked' return HTML.label( HTML.input(**input_attrs), ' ', self.li_label(item), class_="stay-open", style="margin-left:5px; margin-right:5px;", )
def html_label(marker_spec, text): return HTML.label( marker_img(self.req.static_url(marker_spec)), literal(text), style='margin-left: 1em; margin-right: 1em;')
def value_li(de): return HTML.label( map_marker_img(self.req, de), literal(de.abbr), style='margin-left: 1em; margin-right: 1em;')
def legend_items(req): for type, label in [('recipient', 'recipient language'), ('donor', 'donor languoid')]: yield HTML.label( HTML.img(src=icon_url(req, type), height='20', width='20'), literal(' ' + label), style='margin-left: 1em; margin-right: 1em;')