-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.html
175 lines (143 loc) · 3.55 KB
/
demo.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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>dialog.js - Demo</title>
<style>
body {
margin: 1em 13px 3em;
font-family: Arial, sans-serif;
font-size: 0.9em;
color: black;
background-color: #EEE;
}
h1 {
color: #C00;
text-align: center;
font-size: 2em;
font-weight: bold;
}
h2 {
margin-left: 0.5em;
font-size: 1.8em;
font-weight: bold;
color: #333;
}
p {
margin: 0.8em 5px;
}
pre {
border: 2px dashed #FA0;
border-radius: 5px;
padding: 1em 0.8em;
background-color: #EEC;
font-family: monospace;
white-space: pre-wrap;
tab-size: 4;
margin: 1em 0px;
font-size: 1em;
color: #232;
}
code {
font-family: monospace;
font-size: 1em;
color: #225;
}
</style>
<link rel="stylesheet" href="dialog_default.css" type="text/css">
<script type="text/javascript" src="dialog.js"></script>
</head>
<body>
<h1>dialog.js - Live Demo</h1>
<b>Note:</b>
<p>To see the full documentation, please refer to the <a href="https://github.com/mttbernardini/dialog/wiki">wiki</a>.</p>
<p>A shorter and essential reference is also available at the beginning of the <i>dialog.js</i> file.</p>
<hr>
<h2>First example</h2>
<p>Basic alert message.</p>
<pre>
<script type="text/javascript">
dialogSettings = {
defType: "confirm",
defTitle: "Conferma",
defContent: "Contenuto non impostato",
okText: "Accetta",
continueText: "Continua",
cancelText: "Annulla"
};
</script>
<button onclick="dialog()">Try it</button>
</pre>
<div>In action:</div>
<button onclick="dialogSettings = {defType: 'confirm', defTitle: 'Conferma', defContent: 'Contenuto non impostato', okText: 'Accetta', continueText: 'Continua', cancelText: 'Annulla'}; dialog();">Try it</button>
<h2>Second example</h2>
<p>Use of arguments.</p>
<pre>
<script type="text/javascript">
var parameters = {
type: "prompt",
title: "Example",
content: "What's your name?",
}
</script>
<button onclick="dialog(parameters)">Try it</button>
</pre>
<div>In action:</div>
<button onclick="dialogSettings=undefined; dialog({type: 'prompt', title: 'Example', content: 'What\'s your name?'})">Try it</button>
<h2>Third example</h2>
<p>Advanced use: using chaining and data carrying.</p>
<pre>
<script type="text/javascript">
function check(box1) {
if (box1.action) {
box1.data.name = box1.value != "" ? box1.value : "Unnamed";
dialog({
type: "confirm",
content: "Do you want your name printed on a message?",
data: box1.data,
})
.then(function(box2) {
if (box2.action) {
dialog({
//NB: default type is alert, so we don't need to specify it
title: "Print out",
content: "Hello "+box2.data.name+"\nFoo: "+box2.data.foo
});
}
});
}
}
var parameters = {
type: "prompt",
title: "Example",
content: "What's your name?"",
data: {foo: "bar"}
};
</script>
<button onclick="dialog(parameters).then(check)">Try it</button>
</pre>
<script type="text/javascript">
function check(box1) {
if (box1.action) {
box1.data.name = box1.value != "" ? box1.value : "Unnamed";
dialog({
type: "confirm",
content: "Do you want your name printed on a message?",
data: box1.data,
})
.then(function(box2) {
if (box2.action) {
dialog({
//NB: default type is alert, so we don't need to specify it
title: "Print out",
content: "Hello "+box2.data.name+"\nFoo: "+box2.data.foo
});
}
});
}
}
</script>
<div>In action:</div>
<button onclick="dialogSettings=undefined; dialog({type: 'prompt', title: 'Example', content: 'What\'s your name?', data: {foo: 'bar'}}).then(check);">Try it</button>
</body>
</html>