-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.php
376 lines (356 loc) · 11.7 KB
/
index.php
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Notification center - Jquery</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/flat-ui.css" rel="stylesheet">
<link href="css/notifcenter.css" rel="stylesheet">
<link href="css/doc.css" rel="stylesheet">
<style type="text/css">
body { padding-top: 60px; padding-bottom: 40px; }
</style>
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div id="noticationcentermain" class="notificationcentercontainer">
<div class="navbar navbar-inverse">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="#"><i class="icon-beaker" style=""></i> notificationcenter.js</a>
<div class="nav-collapse">
<ul class="nav pull-right">
<li><a data-toggle="modal" href="#aboutmodal">About</a></li>
<li><a href="#" id="notificationcentericon" class="open"><i class="icon-align-justify icon-large"></i></a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container">
<!-- Main hero unit for a primary marketing message or call to action -->
<div class="hero-unit">
<h1>Notification center for jQuery!</h1>
<p>Trying to implement a simple notification center like Facebook or like Apple in the last version of it's OS.</p>
<p><a class="btn btn-primary btn-large" href="https://github.com/mbuonomo/notificationcenter/archive/master.zip"><i class="icon-cloud-download"></i> Download</a> <a class="btn btn-success btn-large" href="https://github.com/mbuonomo/notificationcenter"><i class="icon-github-alt"></i> GitHub</a></p>
</div>
<!-- Example row of columns -->
<div class="row">
<div class="span6">
<h2>Triggers</h2>
<div class="row-fluid">
<div class="span8">
<p>It's really easy to show the center. The plugin create a panel on the right side of your website.</p>
</div>
<div class="span4">
<p><a class="btn slideit" href="#">Display the panel on the right</a></p>
</div>
</div>
</div>
<div class="span6">
<h2>Notifications</h2>
<div class="row-fluid">
<div class="span6">
<p>How to throw a notification with Javascript.</p>
</div>
<div class="span4">
<p><a class="btn notif" href="#" data-type="gift" style="width:100%;">Shoot a notification</a></p>
<p><a class="btn notif" href="#" data-type="calendar" style="width:100%;">Another one</a></p>
</div>
</div>
</div>
</div>
<hr>
<!-- Example row of columns -->
<div class="row">
<div class="span4" style="padding-top:35px">
<img src="img/less.png">
</div>
<div class="span8">
<h2>LESS</h2>
<p>How easy it is to customize your notification center?</p>
<p>
Simply use our LESS files, I try to comment it correctly so normally it's easy :)
</p>
<small>If not or if your find a mistake just shoot a comment on github</small>
</div>
</div>
<hr> <!-- Example row of columns -->
<div class="row">
<div class="span8">
<h2>FAYE & node.js</h2>
<p>Why not adding a little bit of push in it?</p>
<blockquote>
<p>
Faye is a publish-subscribe messaging system based on the <a href="http://svn.cometd.com/trunk/bayeux/bayeux.html" target="_blank">Bayeux</a> protocol. It provides message servers for <a href="http://nodejs.org/" target="_blank">Node.js</a> and <a href="http://www.ruby-lang.org/" target="_blank">Ruby</a>, and clients for use on the server and in all major web browsers.
</p>
</blockquote>
<p>For example purpose we will shoot some notification via php using a curl request on the nodejs server every 15 minutes</p>
<small>For the moment it's a dummy countdown in javascript but it will be updated soon</small>
<div class="row-fluid">
<div class="span4" style="text-align:right">
<img src="img/time.png" width="64" />
</div>
<div class='span4 timer'>
12:42
</div>
</div>
</div>
<div class="span4">
<img src="img/nodejs.png">
<img src="img/faye-logo.gif">
</div>
</div>
<hr>
<div class="row">
<h2>Tips</h2>
<div class="span12">
<p>
Want to display the date for each notification?
</p>
<p>
Include <a href="http://momentjs.com/" target="_blank">Moment.js</a> and <a href="http://mattbradley.github.io/livestampjs/" target="_blank">Livestamp.js</a> and ENJOY :)
</p>
</div>
</div>
<div class="row">
<div class="span12">
<h2>Documentation</h2>
<h3>How to start</h3>
<pre class="prettyprint linenums">
<body>
<div id="noticationcentermain" class="notificationcentercontainer">
[...]all your html[...]
</div>
</body></pre>
<h3>Definition</h3>
<pre class="prettyprint linenums">
<script>
$('body').notificationcenter({
centerElement: "#notificationcenterpanel",
bodyElement: "#noticationcentermain",
toggleButton: "#notificationcentericon",
addPanel : true,
displayTime:5000,
types:[],
counter:true,
default_notifs:[],
faye:false,
alert_hidden:true,
alert_hidden_sound:true
});
</script></pre>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="width: 100px;">Name</th>
<th style="width: 50px;">type</th>
<th style="width: 50px;">default</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>centerElement</td>
<td>string</td>
<td>"#notificationcenterpanel"</td>
<td>Define the id of the element embedding your dom.</td>
</tr>
<tr>
<td>bodyElement</td>
<td>string</td>
<td>"#noticationcentermain"</td>
<td>Closes the modal when escape key is pressed</td>
</tr>
<tr>
<td>toggleButton</td>
<td>string</td>
<td>"#notificationcentericon"</td>
<td>Id of the button to toggle the panel.</td>
</tr>
<tr>
<td>addPanel</td>
<td>boolean</td>
<td>true</td>
<td>If you want the panel on the right.</td>
</tr>
<tr>
<td>displayTime</td>
<td>int</td>
<td>5000</td>
<td>Display time for each notification.</td>
</tr>
<tr>
<td>types</td>
<td>array</td>
<td>[]</td>
<td>
Array of objects to define the types of each notifications.
<pre class="prettyprint linenums">
$('body').notificationcenter({
types:[
{
type:'gift', // define the type
img:'img/gift.png', // icon path
bgcolor:'#EB5D49', // background color for the center header
color:'#FFFFFF' // text color for the center header
},
[...]
]
});</pre>
</td>
</tr>
<tr>
<td>counter</td>
<td>boolean</td>
<td>true</td>
<td>Display a counter.</td>
</tr>
<tr>
<td>default_notifs</td>
<td>array</td>
<td>[]</td>
<td>
Array of objects to define the default notifications.
<pre class="prettyprint linenums">
$('body').notificationcenter({
default_notifs:[
{
type:'gift', // define the type
values:[{text:'This is an example', time:date.getTime()/1000}]
},
[...]
]
});</pre>
</td>
</tr>
<tr>
<td>faye</td>
<td>object</td>
<td>false</td>
<td>
Object to define the faye connection.
<pre class="prettyprint linenums">
$('body').notificationcenter({
faye:
{
server:'http://yourserver:port'
chanel:'your chanel'
}});</pre>
</td>
</tr>
<tr>
<td>alert_hidden</td>
<td>bool</td>
<td>true</td>
<td>
If you want to be alerted even if the page has not the focus.
</td>
</tr>
<tr>
<td>alert_hidden_sound</td>
<td>string</td>
<td>''</td>
<td>
Url of the audio file <strong>without the extension</strong>
You must provide the file in both format MP3/OGG
</td>
</tr>
</tbody>
</table>
<h3>Methods</h3>
<h4>.notificationcenter('slide')</h4>
<pre class="prettyprint linenums">
$('body').notificationcenter('slide');</pre>
<h4>.notificationcenter('newAlert', text, type)</h4>
<div class="bs-docs-example" style="padding-bottom: 24px;">
<a onClick="$('body').notificationcenter('newAlert', 'Sed posuere consectetur est at lobortis. Nullam id dolor id nibh ultricies vehicula ut id elit.', 'gift');" class="btn btn-primary btn-large">Display a new notification</a>
</div>
<pre class="prettyprint linenums">
$('body').notificationcenter('newAlert', 'Sed posuere consectetur est at lobortis. Nullam id dolor id nibh ultricies vehicula ut id elit.', 'gift');</pre>
</div>
</div>
</div>
<footer>
<p>© <a href="http://www.mathieubuonomo.com">Mathieu BUONOMO</a></p>
</footer>
</div> <!-- /container -->
<div class="modal fade" id="aboutmodal">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>About</h3>
</div>
<div class="modal-body">
<p>More about me and my work <a href="http://www.mathieubuonomo.com">here</a></p>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Close</a>
</div>
</div>
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="js/bootstrap-modal.js"></script>
<script src="js/jquery.moment.js"></script>
<script src="js/jquery.livestamp.js"></script>
<script src="js/jquery.notificationcenter.js"></script>
<script src="js/jquery.timer.js"></script>
<script src="js/prettify.js"></script>
<script src="http://176.31.127.193:8000/faye/client.js"></script>
<script>
var client = null;
$(document).ready(function(){
window.prettyPrint && prettyPrint();
var secondes = 900-<?php echo time()-intval(file_get_contents("last.txt"))?>;
var counter=setInterval(displayCountDown, 1000);
function displayCountDown(){
if(secondes == 0){
secondes = 900-<?php echo time()-intval(file_get_contents("last.txt"))?>;
$('body').notificationcenter('newAlert', 'This alert has been pushed from a php file via CuRl', 'system');
} else {
secondes--;
var minutes = Math.floor(secondes/60);
var sec = secondes-(minutes*60);
if(minutes < 10)
minutes = '0'+minutes;
if(sec < 10)
sec = '0'+sec;
$('.timer').html(minutes+':'+sec);
}
}
var date = new Date();
$('body').notificationcenter({
types:[
{type:'gift',img:'img/gift.png', bgcolor:'#EB5D49', color:'#FFFFFF'},
{type:'calendar',img:'img/calendar.png', bgcolor:'#2767A8', color:'#FFFFFF'},
{type:'system',img:'img/settings.png', bgcolor:'#FFFFFF', color:'#2C3E50'}
],
default_notifs:[
{type:'gift', values:[{text:'This is an example', time:date.getTime()/1000}]}
],
faye : {
server : 'http://176.31.127.193:8000/faye',
chanel : '/messages'
},
alert_hidden_sound: 'sounds/alert'
});
$('.notif').on('click', function(){
$('body').notificationcenter('newAlert', 'Donec id elit non mi porta gravida at eget metus. Maecenas faucibus mollis interdum.', $(this).attr('data-type'));
});
$('.slideit').on('click', function(){
$('body').notificationcenter('slide');
});
});
</script>
</div>
</div>
</body>
</html>