-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
195 lines (157 loc) · 7.14 KB
/
index.html
File metadata and controls
195 lines (157 loc) · 7.14 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Custom Loading States | DriveWorks</title>
<!-- Force loading states (for debugging) -->
<link rel="stylesheet" href="styles/force-loading-states.css" />
<!-- Custom loading state styles -->
<link rel="stylesheet" href="styles/inline-loading-states.css" />
<link rel="stylesheet" href="styles/form-loading-states.css" />
<link rel="stylesheet" href="styles/preview-loading-states.css" />
<!-- Use to structure the example ONLY -->
<link rel="stylesheet" href="_structure.css" />
</head>
<body>
<h1>Custom Loading States</h1>
<label>
<input type="checkbox" id="force-loading-toggle" checked />
Force Loading States
</label>
<h2>Specification Form Loading</h3>
<p class="tip">
💡 <strong>Tip:</strong>
To force display the Form loading state during development, use:
<code>.dw-loadingOverlay { display: block !important; }</code>
</p>
<div class="group">
<!-- Inline Loading Message -->
<div class="example">
<div class="form delay">
<div class="inline-loading-state">Configurator loading...</div>
</div>
<p><strong>Inline</strong> loading message <span class="tag">Shown before Form renders</span></p>
</div>
<!-- Inline Loading State -->
<div class="example">
<div class="form is-loading delay"></div>
<p><strong>Inline</strong> loading CSS class <span class="tag">Shown before Form renders</span></p>
</div>
<!-- Default Form Loading State -->
<div class="example">
<div class="form force-form-loading"></div>
<p><strong>Default</strong> loading image <span class="tag forced">Loading state forced</span></p>
</div>
<!-- Change Form Loading Image -->
<div class="example">
<div class="form change-form-loading-image force-form-loading"></div>
<p><strong>Change</strong> loading image <span class="tag forced">Loading state forced</span></p>
</div>
<!-- Custom Form Loading Image - Hide Text -->
<div class="example">
<div class="form custom-form-loading-image hide-loading-text force-form-loading"></div>
<p><strong>Custom</strong> size image, no text <span class="tag forced">Loading state forced</span></p>
</div>
<!-- Pure CSS Form Loading State (no images) -->
<div class="example">
<div class="form css-form-loading hide-loading-text force-form-loading"></div>
<p><strong>Simple CSS</strong> loading state <span class="tag forced">Loading state forced</span></p>
</div>
</div>
<h2>3D Preview Loading</h3>
<p class="tip">
💡 <strong>Tip:</strong>
To force display the Preview Control loading state during development, use:
<code>.dw-previewLoadingProgress { display: block !important; }</code>
</p>
<div class="group">
<!-- Default Preview Loading State -->
<div class="example">
<div class="form force-preview-loading"></div>
<p>
<strong>Default</strong> loading image
<span class="tag forced">Loading state forced</span>
</p>
</div>
<div class="example">
<div class="form custom-preview-loading-image force-preview-loading"></div>
<p>
<strong>Custom</strong> loading image
<span class="tag forced">Loading state forced</span>
</p>
</div>
<div class="example">
<div class="form css-preview-loading force-preview-loading"></div>
<p>
<strong>Simple CSS</strong> loading state
<span class="tag forced">Loading state forced</span>
</p>
</div>
</div>
<script src="config.js"></script>
<script>
const GROUP_ALIAS = config.groupAlias;
const PROJECT_NAME = config.projectName;
const ARTIFICIAL_LOADING_DELAY_SECONDS = 1;
const forms = document.querySelectorAll(".form");
// Run on client load
async function dwClientLoaded() {
try {
// Create DriveWorks API client
const DW_CLIENT = new window.DriveWorksLiveClient(config.serverUrl);
// Login to Group
await DW_CLIENT.loginGroup(GROUP_ALIAS);
// Render Forms
Promise.all([...forms].map(async (form) => {
let delay = 0;
if (form.classList.contains("delay")) {
delay = ARTIFICIAL_LOADING_DELAY_SECONDS;
}
// Create Specification
const specification = await DW_CLIENT.createSpecification(GROUP_ALIAS, PROJECT_NAME);
// [Debug] Artificially delay initial render to display inline loading state
setTimeout(async () => {
// (Optional) Clear inline container content BEFORE render - see "Inline Loading Message" example
form.innerHTML = "";
// Render Specification Form
await specification.render(form);
// (Optional) Remove loading class on container AFTER render - see "Inline Loading State" example
form.classList.remove("is-loading");
}, delay * 1000);
return form;
}));
} catch (error) {
console.log(error);
}
};
// [DEBUG] Toggle forced loading states
const forceToggle = document.querySelector("#force-loading-toggle");
const forcedForms = document.querySelectorAll(".form.force-form-loading");
const forcedPreviews = document.querySelectorAll(".form.force-preview-loading");
const forcedTags = document.querySelectorAll(".tag.forced");
forceToggle.addEventListener("change", () => {
for (const form of forcedForms) {
form.classList.toggle("force-form-loading");
}
for (const form of forcedPreviews) {
form.classList.toggle("force-preview-loading");
}
for (const tag of forcedTags) {
tag.classList.toggle("hidden");
}
});
</script>
<!-- Option A) Directly load Client Library -->
<!-- <script src="https://YOUR-THEME-SERVER.COM/DriveworksLiveIntegrationClient.min.js" onload="dwClientLoaded()"></script> -->
<!-- Option B) Inject Client Library dynamically from server url in config file -->
<script>
(function(doc, script) {
script = doc.createElement("script");
script.src = config.serverUrl + "/DriveWorksLiveIntegrationClient.min.js";
script.onload = () => dwClientLoaded(); // Custom local function run when client has loaded
doc.body.appendChild(script);
}(document));
</script>
</body>
</html>