| 1 | /** |
|---|
| 2 | * Represents a collection of properties that belong to a single event. |
|---|
| 3 | * @param properties {Array of Property} The list of Property to be grouped together. |
|---|
| 4 | */ |
|---|
| 5 | function Properties(properties) |
|---|
| 6 | { |
|---|
| 7 | //========== private static members ==========// |
|---|
| 8 | Properties.id = (typeof Properties.id == 'undefined') ? 0 : ++Properties.id; |
|---|
| 9 | |
|---|
| 10 | //=========== public constants ==========// |
|---|
| 11 | this.properties = properties; |
|---|
| 12 | this.id = Properties.id; |
|---|
| 13 | this.expandOptionID = "propertiesExpandOption" + this.id; |
|---|
| 14 | this.propertiesID = "properties" + this.id; |
|---|
| 15 | |
|---|
| 16 | //========== public read-only members ==========// |
|---|
| 17 | this.expanded = true; |
|---|
| 18 | |
|---|
| 19 | //========== public methods ==========// |
|---|
| 20 | this.html = html; |
|---|
| 21 | this.expandAction = expandAction; |
|---|
| 22 | |
|---|
| 23 | //========== private methods ==========// |
|---|
| 24 | this.expandOption = expandOption; |
|---|
| 25 | this.expandOptionSymbol = expandOptionSymbol; |
|---|
| 26 | this.refresh = refresh; |
|---|
| 27 | this.propertiesHTML = propertiesHTML; |
|---|
| 28 | |
|---|
| 29 | //========== method definitions ==========// |
|---|
| 30 | |
|---|
| 31 | /** |
|---|
| 32 | * @return The html for the "+" or "-" button that expands/collapses the properties. |
|---|
| 33 | */ |
|---|
| 34 | function expandOption() |
|---|
| 35 | { |
|---|
| 36 | return " " |
|---|
| 37 | /* In 2019 we don't think we want expand option any longer |
|---|
| 38 | return "<button class='propertiesExpandButton' id='" + |
|---|
| 39 | this.expandOptionID + "' onclick='events.getProperties(" |
|---|
| 40 | + this.id + ").expandAction();'>" + this.expandOptionSymbol() + |
|---|
| 41 | "</button>"; |
|---|
| 42 | */ |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | /** |
|---|
| 46 | * If the list of properties are expanded, then collapses the list of properties. |
|---|
| 47 | * If the list of properties are collapsed, then expands the list of properties. |
|---|
| 48 | */ |
|---|
| 49 | function expandAction() |
|---|
| 50 | { |
|---|
| 51 | this.expanded = !this.expanded; this.refresh(); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | /** |
|---|
| 55 | * @return Returns the "+" or "-" symbol for the expand/collapse button. |
|---|
| 56 | */ |
|---|
| 57 | function expandOptionSymbol() |
|---|
| 58 | { |
|---|
| 59 | return this.expanded == true ? "–" : "+"; |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | /** |
|---|
| 63 | * Displays the correct symbol for the expand/collapse button. |
|---|
| 64 | * Displays or hides the list of properties depending on the expand/collapse state. |
|---|
| 65 | */ |
|---|
| 66 | function refresh() |
|---|
| 67 | { |
|---|
| 68 | // IF the expandOption element exists THEN |
|---|
| 69 | if (events.doc.getElementById(this.expandOptionID)) |
|---|
| 70 | { |
|---|
| 71 | events.doc.getElementById(this.expandOptionID).innerHTML = this.expandOptionSymbol(); |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | // IF the properties element exists THEN |
|---|
| 75 | if (events.doc.getElementById(this.propertiesID)) |
|---|
| 76 | { |
|---|
| 77 | events.doc.getElementById(this.propertiesID).innerHTML = this.expanded ? this.propertiesHTML() : ""; |
|---|
| 78 | } |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | /** |
|---|
| 82 | * @return The html for the list of properties. |
|---|
| 83 | */ |
|---|
| 84 | function propertiesHTML() |
|---|
| 85 | { |
|---|
| 86 | var html = "<table>"; |
|---|
| 87 | |
|---|
| 88 | for (var i = 0; i < this.properties.length; i++) |
|---|
| 89 | { |
|---|
| 90 | html += "<tr>" + |
|---|
| 91 | "<td>" + this.properties[i].html() + "</td>" + |
|---|
| 92 | "</tr>"; |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | html += "</table>"; |
|---|
| 96 | |
|---|
| 97 | return html; |
|---|
| 98 | }; |
|---|
| 99 | |
|---|
| 100 | /** |
|---|
| 101 | * @return The html representation of this class. |
|---|
| 102 | */ |
|---|
| 103 | function html() |
|---|
| 104 | { |
|---|
| 105 | var text = ""; |
|---|
| 106 | |
|---|
| 107 | if (this.properties.length > 0) |
|---|
| 108 | { |
|---|
| 109 | text = "<table>"; |
|---|
| 110 | /* In 2019 we no longer care to expand "Properties" or "Evaluations" */ |
|---|
| 111 | /* text += "<tr>" + |
|---|
| 112 | "<td class='propertiesExpandOption'>" + this.expandOption() + |
|---|
| 113 | " Properties</td>" + |
|---|
| 114 | "</tr>"; |
|---|
| 115 | */ |
|---|
| 116 | text += "<tr>" + |
|---|
| 117 | "<td class='properties' id='" + this.propertiesID + "'>" + |
|---|
| 118 | (this.expanded ? this.propertiesHTML() : "") + "</td>" + |
|---|
| 119 | "</tr>"; |
|---|
| 120 | |
|---|
| 121 | text +="</table>"; |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | return text; |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | } |
|---|