Warning: Can't use blame annotator:
svn blame failed on branches/EInotebook/scripts/Properties.js: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator/branches/EInotebook/scripts/Properties.js @ 350

Revision 350, 3.1 KB checked in by jdalbey, 7 years ago (diff)

Add a branch EInotebook for Electronic Instructor Notebook prototype

  • Property svn:executable set to *
RevLine 
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 */
5function 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 "<button class='propertiesExpandButton' id='" + 
37                                this.expandOptionID + "' onclick='events.getProperties(" 
38                                + this.id + ").expandAction();'>" + this.expandOptionSymbol() +
39                                "</button>";
40        }
41       
42        /**
43         * If the list of properties are expanded, then collapses the list of properties.
44         * If the list of properties are collapsed, then expands the list of properties.
45         */
46        function expandAction() 
47        { 
48                this.expanded = !this.expanded; this.refresh(); 
49        }
50       
51        /**
52         * @return Returns the "+" or "-" symbol for the expand/collapse button.
53         */
54        function expandOptionSymbol() 
55        { 
56                return this.expanded == true ? "&ndash;" : "+"; 
57        }
58       
59        /**
60         * Displays the correct symbol for the expand/collapse button.
61         * Displays or hides the list of properties depending on the expand/collapse state.
62         */
63        function refresh() 
64        {
65                // IF the expandOption element exists THEN
66                if (events.doc.getElementById(this.expandOptionID))
67                {
68                        events.doc.getElementById(this.expandOptionID).innerHTML = this.expandOptionSymbol();
69                }
70               
71                // IF the properties element exists THEN
72                if (events.doc.getElementById(this.propertiesID))
73                {
74                        events.doc.getElementById(this.propertiesID).innerHTML = this.expanded ? this.propertiesHTML() : "";
75                }
76        }
77       
78        /**
79         * @return The html for the list of properties.
80         */
81        function propertiesHTML()
82        {
83                var html = "<table>";
84               
85                for (var i = 0; i < this.properties.length; i++)
86                {
87                        html += "<tr>" +
88                                        "<td>" + this.properties[i].html() + "</td>" +
89                                        "</tr>";
90                }
91               
92                html += "</table>";
93               
94                return html;
95        };
96       
97        /**
98         * @return The html representation of this class.
99         */
100        function html()
101        {
102                var text = "";
103               
104                if (this.properties.length > 0)
105                {
106                        text = "<table>";
107                       
108                        text += "<tr>" +
109                                        "<td class='propertiesExpandOption'>" + this.expandOption() + 
110                                        " Properties</td>" +
111                                        "</tr>";
112
113                                text += "<tr>" +
114                                                "<td class='properties' id='" + this.propertiesID + "'>" + 
115                                            (this.expanded ? this.propertiesHTML() : "") + "</td>" +
116                                                "</tr>";
117                       
118                        text +="</table>";
119                }
120               
121                return text;
122        }
123       
124}
Note: See TracBrowser for help on using the repository browser.