forked from CodeSeven/toastr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
177 lines (154 loc) · 6.42 KB
/
index.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
176
177
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>toastr examples</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet"/>
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet"/>
<link href="toastr.css" rel="stylesheet" type="text/css" />
<link href="toastr-responsive.css" rel="stylesheet" type="text/css" />
<style>
.row {
margin-left: 0;
}
</style>
</head>
<body style="padding: 30px" class="container">
<section class="row">
<h1>toastr</h1>
<div class="well row">
<div class="row span11">
<div class="span4">
<div class="control-group">
<div class="controls">
<label class="control-label" for="title">Title</label>
<input id="title" type="text" class="input-large" placeholder="Enter a title ..."/>
<label class="control-label" for="message">Message</label>
<textarea class="input-large" id="message" rows="3" placeholder="Enter a message ..."></textarea>
</div>
</div>
</div>
<div class="span2">
<div class="control-group" id="toastTypeGroup">
<div class="controls">
<label >Toast Type</label>
<label class="radio"><input type="radio" name="toasts" value="success" checked/>Success</label>
<label class="radio"><input type="radio" name="toasts" value="info"/>Info</label>
<label class="radio"><input type="radio" name="toasts" value="warning"/>Warning</label>
<label class="radio"><input type="radio" name="toasts" value="error"/>Error</label>
</div>
</div>
<div class="control-group" id="positionGroup">
<div class="controls">
<label>Position</label>
<label class="radio"><input type="radio" name="positions" value="toast-top-right" checked/>Top Right</label>
<label class="radio"><input type="radio" name="positions" value="toast-bottom-right"/>Bottom Right</label>
<label class="radio"><input type="radio" name="positions" value="toast-bottom-left"/>Bottom Left</label>
<label class="radio"><input type="radio" name="positions" value="toast-top-left"/>Top Left</label>
</div>
</div>
</div>
<div class="span2" >
<div class="control-group">
<div class="controls">
<label class="control-label" for="">Fade in</label>
<input id="fadeIn" type="text" placeholder="ms" class="input-mini" value="300"/>
<label class="control-label" for="fadeOut">Fade out</label>
<input id="fadeOut" type="text" placeholder="ms" class="input-mini" value="1000"/>
<label class="control-label" for="timeOut">Time out</label>
<input id="timeOut" type="text" placeholder="ms" class="input-mini" value="5000"/>
</div>
</div>
</div>
<div class="span2">
<div class="control-group">
<div class="controls">
<label class="checkbox" for="debugInfo">
<input id="debugInfo" type="checkbox" checked="checked" class="input-mini"/>Debug
</label>
</div>
<div class="controls">
<label class="checkbox" for="tapToDismiss">
<input id="tapToDismiss" type="checkbox" checked="checked" class="input-mini"/>Tap to dismiss toast
</label>
</div>
</div>
</div>
</div>
<div class="row span11">
<button type="button" class="btn btn-primary" id="showtoast">Show Toast</button>
</div>
</div>
</section>
<footer class="row">
<h2>Links</h2>
<ul>
<li><a href="https://github.com/CodeSeven/toastr/downloads">Download</a></li>
<li><a href="https://github.com/CodeSeven/toastr">GitHub</a></li>
</ul>
</footer>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="toastr.js"></script>
<script type="text/javascript">
$(function() {
var
i = -1,
toastCount = 0,
getMessage = function() {
var msgs = ['My name is Inigo Montoya. You killed my father. Prepare to die!',
'<div><input class="input-small" value="textbox"/> <a href="http://johnpapa.net" target="_blank">This is a hyperlink</a></div><div><button type="button" id="okBtn" class="btn btn-primary">Close me</button><button type="button" id="surpriseBtn" class="btn" style="margin: 0 8px 0 8px">Surprise me</button></div>',
'Are you the six fingered man?',
'Inconceivable!',
'I do not think that means what you think it means.',
'Have fun storming the castle!'
]
i++
if (i === msgs.length) {
i = 0
}
return msgs[i]
}
$('#showtoast').click(function() {
var shortCutFunction = $("#toastTypeGroup input:radio:checked").val(),
msg = $('#message').val(),
title = $('#title').val() || '',
$fadeIn = $('#fadeIn'),
$fadeOut = $('#fadeOut'),
$timeOut = $('#timeOut'),
toastIndex = toastCount++
toastr.options = {
debug: $('#debugInfo').prop('checked'),
tapToDismiss: $('#tapToDismiss').prop('checked'),
positionClass: $('#positionGroup input:radio:checked').val() || 'toast-top-right'
}
if ($fadeIn.val().length) {
toastr.options.fadeIn = +$fadeIn.val()
}
if ($fadeOut.val().length) {
toastr.options.fadeOut = +$fadeOut.val()
}
if ($timeOut.val().length) {
toastr.options.timeOut = +$timeOut.val()
}
if (!msg) {
msg = getMessage()
}
var $toast = toastr[shortCutFunction](msg, title)
// Wire up an event handler to a button in the toast, if it exists
if ($toast.find('#okBtn').length) {
$toast.on('click', '#okBtn', function () {
alert('you clicked me. i was toast #' + toastIndex + '. goodbye!')
$toast.remove()
})
}
if ($toast.find('#surpriseBtn').length) {
$toast.on('click', '#surpriseBtn', function () {
alert('Surprise! you clicked me. i was toast #' + toastIndex + '. You could perform an action here.')
})
}
})
})
</script>
</body>
</html>