forked from tameraydin/ngToast
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
249 lines (218 loc) · 7.33 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>ngToast Test</title>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css"/>
<link rel="stylesheet" href="dist/ngToast.css"/>
<link rel="stylesheet" href="dist/ngToast-animations.css"/>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-animate/angular-animate.js"></script>
<script src="bower_components/Faker/build/build/faker.js"></script>
<script src="dist/ngToast.js"></script>
</head>
<body ng-app="ToastApp" ng-controller="ToastController as ctrl">
<toast></toast>
<div class="jumbotron">
<div class="container">
<h1>ngToast</h1>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-6">
<form class="form">
<div class="form-group">
<legend>Create</legend>
</div>
<pre>
ngToastProvider.configure({
animation: 'slide',
horizontalPosition: 'right',
verticalPosition: 'top',
maxNumber: 0,
combineDuplications: true
});
</pre>
<div class="form-group">
<label class="control-label">
Content:
</label>
<input class="form-control" type="text" ng-model="ctrl.options.content" placeholder="Content"/>
</div>
<div class="form-group">
<label class="control-label">
Dismiss Button HTML:
</label>
<input type="text" class="form-control" ng-model="ctrl.options.dismissButtonHtml">
</div>
<div class="form-group">
<label class="control-label">
Other Classes:
</label>
<input type="text" class="form-control" ng-model="ctrl.options.classes">
</div>
<div class="form-group">
<label>Alert Class:</label>
<div class="radio">
<label>
<input type="radio" value="info" ng-model="ctrl.options.className">
Info
</label>
</div>
<div class="radio">
<label>
<input type="radio" value="success" ng-model="ctrl.options.className">
Success
</label>
</div>
<div class="radio">
<label>
<input type="radio" value="warning" ng-model="ctrl.options.className">
Warning
</label>
</div>
<div class="radio">
<label>
<input type="radio" value="danger" ng-model="ctrl.options.className">
Danger
</label>
</div>
</div>
<div class="form-group">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="ctrl.options.compileContent">
compileContent
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="ctrl.options.dismissButton">
dismissButton
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="ctrl.options.dismissOnClick">
dismissOnClick
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="ctrl.options.dismissOnTimeout">
dismissOnTimeout
</label>
</div>
</div>
<div class="form-group">
<label class="control-label">
Timeout {{ ctrl.options.timeout }}ms
<input type="range" min="250" max="10000" step="250" ng-model="ctrl.options.timeout"/>
</label>
</div>
<div class="form-group">
<button class="btn btn-lg btn-primary" ng-click="ctrl.createToast()">Create Toast</button>
</div>
</form>
</div>
<div class="col-sm-6">
<form>
<legend>Random</legend>
<div class="form-group">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="ctrl.generateRandom">
Generate Random
</label>
</div>
</div>
<div class="form-group">
<label class="control-label">
Interval {{ ctrl.randomIntervalValue }}ms
<input type="range" min="500" max="10000" step="500" ng-model="ctrl.randomIntervalValue"/>
</label>
</div>
<pre ng-show="ctrl.randomOptions">{{ ctrl.randomOptions | json }}</pre>
</form>
</div>
</div>
</div>
<!-- Angular App -->
<script>
var ToastConfig = ['ngToastProvider',
function ToastConfigFn(ngToastProvider) {
ngToastProvider.configure({
animation: 'slide',
horizontalPosition: 'right',
verticalPosition: 'top',
maxNumber: 0,
combineDuplications: true
});
}];
var ToastController = ['$scope', '$interval', 'ngToast', '$timeout',
function ToastControllerFn($scope, $interval, ngToast, $timeout) {
var vm = this;
$scope.$watch('ctrl.randomIntervalValue', function(value) {
vm.randomIntervalValue = parseInt(value);
vm.startRandomInterval();
});
vm.init = function() {
vm.generateRandom = true;
vm.randomIntervalValue = 1500;
vm.options = {
content: 'Just the way we like it, ngToasted to perfection.',
className: 'success',
classes: 'foo',
dismissOnTimeout: true,
timeout: 4000,
dismissButton: false,
dismissButtonHtml: '×',
dismissOnClick: true,
compileContent: false
};
// put first toast on callback stack (waits for animations to load)
$timeout(function() {
vm.createToast(vm.getRandomOptions());
}, 0);
vm.startRandomInterval();
};
vm.getRandomOptions = function() {
return {
content: faker.hacker.phrase(),
className: faker.random.array_element(['success', 'info', 'warning', 'danger']),
classes: faker.hacker.verb(),
dismissOnTimeout: true,
timeout: 4000,
dismissButton: !!faker.random.number(),
dismissButtonHtml: '×',
dismissOnClick: true,
compileContent: true
};
};
vm.createToast = function(options) {
options = options || vm.options;
vm.randomOptions = angular.copy(options);
ngToast.create(options);
};
vm.startRandomInterval = function() {
$interval.cancel(vm.randomInterval);
vm.randomInterval = $interval(function() {
if (vm.generateRandom) {
vm.createToast(vm.getRandomOptions());
}
}, vm.randomIntervalValue);
};
vm.init();
}
];
angular.module('ToastApp', [
'ngAnimate',
'ngToast',
])
.controller('ToastController', ToastController)
.config(ToastConfig);
</script>
</body>
</html>