-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathemh-xml-viewer.html
106 lines (91 loc) · 3.08 KB
/
emh-xml-viewer.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<link rel="import" href="../polymer/polymer.html"/>
<script type="text/javascript" src="XMLDisplay.js"></script>
<!--
`emh-xml-viewer` is a div that displays an interactive XML allowing the user to expand and collapse XML data.
Example:
<emh-xml-viewer url="test.xml"></emh-xml-viewer>
<emh-xml-viewer string="<foo><bar/></foo>"></emh-xml-viewer>
### Styling
The following custom properties and mixins are also available for styling:
Custom property | Description | Default
----------------|-------------|----------
`--emh-xml-viewer-background-color` | The background color of the viewer. | `lightgrey`
`--emh-xml-viewer-utility-color` | The color of the tag < > | `black`
`--emh-xml-viewer-node-name-color` | The color of the name of the node | `#800080`
`--emh-xml-viewer-attribute-name-color` | The color of the name of an attribute | `black`
`--emh-xml-viewer-attribute-value-color` | The color of the value of an attribute | `blue`
`--emh-xml-viewer-node-value-color` | The color of the value of the node | `black`
`--emh-xml-viewer-element-border-color` | The color of the vertical lines from a node's start to end | `#00FF66`
`--emh-xml-viewer-clickable-color` | The color of the '+' and '-' for expanding and collapsing a node | `#800080`
@demo demo/index.html
-->
<dom-module id="emh-xml-viewer">
<template>
<style is="custom-style">
:host {
display: block;
background-color: var(--emh-xml-viewer-background-color, lightgrey);
}
.Utility {
color: var(--emh-xml-viewer-utility-color, black);
}
.NodeName {
font-weight:bold;
color: var(--emh-xml-viewer-node-name-color, #800080);
}
.AttributeName
{
font-weight:bold;
color: var(--emh-xml-viewer-attribute-name-color, black);
}
.AttributeValue
{
color: var(--emh-xml-viewer-attribute-value-color, blue);
}
.NodeValue
{
color: var(--emh-xml-viewer-node-value-color, black);
}
.Element {
border-left-color:var(--emh-xml-viewer-element-border-color, #00FF66);
border-left-width:thin;
border-left-style:solid;
padding-top:0px;
margin-top:10px;
}
.Clickable {
font-weight:900;
font-size:large;
color: var(--emh-xml-viewer-clickable-color, #800080);
cursor:pointer;
vertical-align:middle;
}
</style>
<div id="XMLHolder"></div>
</template>
<script>
Polymer({
is: 'emh-xml-viewer',
properties: {
/* The URL to the XML file for the XML Viewer to load from. */
url: {
type: String,
notify: true,
observer: '_urlChanged'
},
/* The XML file encoded as a string for the XML Viewer to load. */
string: {
type: String,
notify: true,
observer: '_stringChanged'
}
},
_urlChanged: function() {
LoadXML(this.$.XMLHolder, this.url);
},
_stringChanged: function() {
LoadXMLString(this.$.XMLHolder, this.string);
}
});
</script>
</dom-module>