MCPcopy Create free account
hub / github.com/facebook/Rapid / uiTagReference

Function uiTagReference

modules/ui/tag_reference.js:17–210  ·  view source on GitHub ↗
(context, what)

Source from the content-addressed store, hash-verified

15// }
16//
17export function uiTagReference(context, what) {
18 const l10n = context.systems.l10n;
19 const wikibase = context.services[what.qid ? 'wikidata' : 'osmwikibase'];
20 let tagReference = {};
21
22 let _button = d3_select(null);
23 let _body = d3_select(null);
24 let _loaded;
25 let _showing;
26
27
28 function load() {
29 if (!wikibase) return;
30
31 _button
32 .classed('tag-reference-loading', true);
33
34 wikibase.getDocs(what, gotDocs);
35 }
36
37
38 function gotDocs(err, docs) {
39 _body.html('');
40
41 if (!docs || !docs.title) {
42 _body
43 .append('p')
44 .attr('class', 'tag-reference-description')
45 .html(l10n.tHtml('inspector.no_documentation_key'));
46 done();
47 return;
48 }
49
50 if (docs.imageURL) {
51 _body
52 .append('img')
53 .attr('class', 'tag-reference-wiki-image')
54 .attr('src', docs.imageURL)
55 .on('load', () => done())
56 .on('error', function() {
57 d3_select(this).remove();
58 done();
59 });
60 } else {
61 done();
62 }
63
64 let docsHtml;
65 if (docs.description) {
66 docsHtml = utilSanitizeHTML(l10n.htmlForLocalizedText(docs.description, docs.descriptionLocaleCode));
67 } else {
68 docsHtml = l10n.tHtml('inspector.no_documentation_key');
69 }
70
71 _body
72 .append('p')
73 .attr('class', 'tag-reference-description')
74 .html(docsHtml)

Callers 4

constructorMethod · 0.90
renderMethod · 0.90
renderDisclosureContentFunction · 0.90
uiSectionFeatureTypeFunction · 0.90

Calls 12

uiIconFunction · 0.90
doneFunction · 0.85
loadFunction · 0.85
dataMethod · 0.80
hideFunction · 0.70
mergeMethod · 0.45
enterMethod · 0.45
tMethod · 0.45
onMethod · 0.45
removeMethod · 0.45
exitMethod · 0.45
styleMethod · 0.45

Tested by

no test coverage detected