-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataForm.js
More file actions
68 lines (55 loc) · 2.18 KB
/
Copy pathDataForm.js
File metadata and controls
68 lines (55 loc) · 2.18 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
/// <reference path="../Scripts/jspack-vsdoc.js" />
var ui = MindFusion.Common.UI;
function showForm()
{
// Create a new Window.
// If the element parameter of the Window constructor is not provided, the DOM element of the control will be created internally.
var window1 = new ui.Window();
// Set the window title
window1.title = "Data form";
// Set the window theme
window1.theme = "standard";
// Set the window visibility to false to avoid flickering during content loading.
window1.visible = false;
// Disable interactions.
window1.allowResize = false;
window1.allowPin = false;
window1.allowMaximize = false;
window1.allowMinimize = false;
window1.allowClose = false;
// Set the window templateUrl.
// The HTML of the specified page will be set as the innerHTML of a scrollable div inside the Window's content element.
window1.templateUrl = "form.html";
// Add event handlers.
window1.contentLoad.addEventListener(contentLoad);
// Draw the window and append it to the page DOM.
document.getElementById("content").appendChild(window1.draw());
// Prepare the window for user interaction.
window1.attach();
}
// This is the handler function of the window1.contentLoad event.
// The event is raised when the internal content of the window has finished loading.
// The sender argument is the Window control.
// Set the window visibility to true and let it calculate its size based on the size of its content.
function contentLoad(sender, args)
{
sender.visible = true;
sender.autoSize();
sender.center();
// Attach a handler to the form submit event.
sender.element.querySelector("#form").addEventListener("submit", postData.bind(sender));
}
function postData(e)
{
// Prevent form submission.
e.preventDefault();
// Get a reference to the form element and collect the data.
var form = this.element.querySelector("form");
var data = "";
for (var i = 0; i < form.elements.length - 1; i++)
{
data += form.elements[i].name + " = " + form.elements[i].value + "\n";
}
// Show an information box with the submitted data and dispose the window.
ui.Dialogs.showInfoDialog("Submitted data", data, function () { this.dispose(); }.bind(this), document.getElementById("content"), "standard");
}