forked from ewebdev/backbone.notifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
848 lines (739 loc) · 28.8 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
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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8/>
<title>Backbone.Notifier | Powerful UI Notifications Framework</title>
<!-- Used by example page -->
<link rel="stylesheet" type="text/css" href="example-css/bootstrap.css?_0.2.5">
<link rel="stylesheet" type="text/css" href="example-css/example.css?_0.2.5">
<link rel="stylesheet" type="text/css" href="example-css/prettify.css?_0.2.5">
<!-- Used /by example page -->
<!-- Backbone.Notifier LESS CSS -->
<!--<link rel="stylesheet/less" type="text/css" href="less/notifier-base.less??_0.2.5">-->
<!--<link rel="stylesheet/less" type="text/css" href="less/notifier-theme-clean.less??_0.2.5">-->
<!--<link rel="stylesheet/less" type="text/css" href="less/notifier-theme-plastic.less??_0.2.5">-->
<!--<script type="text/javascript" src="example-js/less-1.3.0.min.js"></script>-->
<!-- /Backbone.Notifier LESS CSS -->
<link rel="stylesheet" type="text/css" href="css/notifier-base.css?_0.2.5">
<link rel="stylesheet" type="text/css" href="css/notifier-theme-clean.css?_0.2.5">
<link rel="stylesheet" type="text/css" href="css/notifier-theme-plastic.css?_0.2.5">
<script type="text/javascript" src="example-js/modernizr.custom.97472.js"></script>
</head>
<body>
<div class="navbar" id="topBar">
<div class="navbar-inner">
<div class="container wrapper-940">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="social-btns">
<iframe src="http://backbone-notifier.e-w.co.il/github-buttons/github-btn.html?user=ewebdev&repo=backbone.notifier&type=watch&count=true"
allowtransparency="true" frameborder="0" scrolling="0" width="90px" height="20px"></iframe>
<iframe src="http://backbone-notifier.e-w.co.il/github-buttons/github-btn.html?user=ewebdev&repo=backbone.notifier&type=fork&count=true"
allowtransparency="true" frameborder="0" scrolling="0" width="84px" height="20px"></iframe>
<iframe src="http://backbone-notifier.e-w.co.il/github-buttons/github-btn.html?user=ewebdev&repo=backbone.notifier&type=follow"
allowtransparency="true" frameborder="0" scrolling="0" width="140px" height="20px"></iframe>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="Eyal_Weiss">Tweet</a>
<script>!function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = "//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
}
}(document, "script", "twitter-wjs");</script>
<a href="https://twitter.com/Eyal_Weiss" class="twitter-follow-button" data-show-count="false">Follow
@Eyal_Weiss</a>
<script>!function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = "//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
}
}(document, "script", "twitter-wjs");</script>
</div>
</div>
</div>
</div>
<div id="githubBadge"><a href="https://github.com/ewebdev/backbone.notifier/"></a></div>
<section id="intro">
<div class="intro-ph">
<h1>Backbone.Notifier
<small>version 0.2.5</small>
</h1>
<button id="btnTour" class="after-tour btn-primary btn btn-large">Quick Tour</button>
<button id="btnTheme" class="after-tour btn btn-large">Switch Theme</button>
</div>
</section>
<div class="container" id="main">
<section id="changelog" class="well well-small">
<h3>What's New?
<small>Recent Commits (<a href="https://github.com/ewebdev/backbone.notifier/commits/master" rel="nofollow">see all</a>)</small>
</h3>
<div class="log-content"></div>
</section>
<div class="instructions">
<section id="dependencies">
<div class="page-header">
<h1>1. Dependencies
<small></small>
</h1>
</div>
<div class="row">
<div class="span12">
<ol>
<li><code><a href="http://jquery.com" rel="nofollow">jQuery</a></code></li>
<li><code><a href="http://underscorejs.org/" rel="nofollow">underscore.js</a></code></li>
<li><code><a href="http://backbonejs.org" rel="nofollow">backbone.js</a></code></li>
</ol>
</div>
</div>
</section>
<section id="installation">
<div class="page-header">
<h1>2. Installation
<small></small>
</h1>
</div>
<div class="row">
<div class="span12 btns-wrapper">
<a class="btn btn-primary btn-large" href="https://github.com/ewebdev/backbone.notifier/zipball/master">Download</a>
<a class="btn btn-large" href="https://github.com/ewebdev/backbone.notifier/">project on github</a>
</div>
</div>
<div class="row">
<div class="span12">
<strong>Javascript Core</strong>
<ul>
<li><code class="file"><script type="text/javascript" src="<strong><a
href="js/Backbone.Notifier.js">js/Backbone.Notifier.js</a></strong>"></script>
</code> <span>Place this tag <strong>after</strong> <em>backbone.js</em> <strong>(Required)</strong></span></li>
</ul>
<p class="res-section"><strong>Styles (Themes)</strong> <span class="alert"><em>notifier-base.css</em> is <strong>mandatory</strong>, and you can choose to include both themes or just one of them.</span></p>
<ul>
<li><code class="file"><link rel="stylesheet" type="text/css" href="<strong><a
href="css/notifier-base.css">css/notifier-base.css</a></strong>"></code> <span>Add this to the head section. Feel free to modify. <strong>(Required)</strong></span>
(<a href="https://github.com/ewebdev/backbone.notifier/blob/master/less/notifier-base.less">source LESS file</a>)
</li>
<li>
<div class="theme-item">
<strong>'Clean' Theme</strong> (<a class="theme-demo" data-theme="clean" href="#demo-clean">see demo</a>)
<ul>
<li><code class="file"><link rel="stylesheet" type="text/css" href="<strong><a
href="css/notifier-theme-clean.css">css/notifier-theme-clean.css</a></strong>"></code> <span>Add this to the head section. Feel free to modify.</span> (<a href="https://github.com/ewebdev/backbone.notifier/blob/master/less/notifier-theme-clean.less">source LESS file</a>)</li>
<li><code class="file"><strong><a
href="imgs/notifier-loader-clean.gif">imgs/notifier-loader-clean.gif</a></strong></code> <span>You can use your own loader animation (referenced by css file)</span>
</li>
</ul>
</div>
</li>
<li>
<div class="theme-item">
<strong>'Plastic' Theme</strong> (<a class="theme-demo" data-theme="plastic" href="#demo-plastic">see demo</a>)
<ul>
<li><code class="file"><link rel="stylesheet" type="text/css" href="<strong><a
href="css/notifier-theme-plastic.css">css/notifier-theme-plastic.css</a></strong>"></code> <span>Add this to the head section. Feel free to modify.</span> (<a href="https://github.com/ewebdev/backbone.notifier/blob/master/less/notifier-theme-plastic.less">source LESS file</a>)</li>
<li><code class="file"><strong><a
href="imgs/notifier-loader-plastic.gif">imgs/notifier-loader-plastic.gif</a></strong></code> <span>You can use your own loader animation (referenced by css file)</span>
</li>
</ul>
</div>
</li>
<li>Or <strong>make your own themes!</strong> making new themes is straightforward and relatively easy. Start by taking a look at the <a rel="nofollow" href="https://github.com/ewebdev/backbone.notifier/tree/master/less">LESS files</a>.
I would really appreciate it if you send themes you've made and I would consider adding them here if you like.
</li>
</ul>
</div>
</div>
</section>
<section id="initialization">
<div class="page-header">
<h1>3. Initialization
<small></small>
</h1>
</div>
<div class="row">
<div class="span12">
<div class="code-wrapper">
<div class="title">
<h3>1. Create notifier with default config
<small>The config is <strong>optional</strong>!</small>
</h3>
</div>
<div class="code"><pre class="prettyprint">
var notifier = new Backbone.Notifier({ // defaults
el: 'body', // container for notification (default: 'body')
baseCls: 'notifier', // css classes prefix, should match css file and can be changed to avoid conflicts.
theme: 'plastic', // default theme for notifications (currently available: 'plastic' / 'clean').
types: ['warning', 'error', 'info', 'success'], // available notification styles
type: null, // default notification style (null / 'warning' / 'error' / 'info' / 'success')
dialog: false, // whether display the notification with a title bar and a dialog style.
// - sets 'hideOnClick' to false, unless defined otherwise
// - sets 'position' to 'center', unless defined otherwise
// - sets 'ms' to null, unless defined otherwise
modal: false, // whether to dark and block the UI behind the notification (default: false)
message: '', // default message content
title: undefined, // default notification title, if defined, causes the notification
// to be 'dialog' (unless dialog is 'false')
closeBtn: false, // whether to display an enabled close button on notification
ms: 5000, // milliseconds before hiding, (null || false => no timeout) (default: 10000)
'class': null, // additional css class
hideOnClick: true, // whether to hide the notifications on mouse click (default: true)
loader: false, // whether to display loader animation in notifications (default: false)
destroy: false, // notification or selector of notifications to hide on show (default: false)
opacity: 1, // notification's opacity (default: 1)
offsetY: -500, // distance between the notifications and the top/bottom edge (default: 0)
fadeInMs: 500, // duration (milliseconds) of notification's fade-in effect (default: 500)
fadeOutMs: 500, // duration (milliseconds) of notification's fade-out effect (default: 500)
position: 'top', // default notifications position ('top' / 'center' / 'bottom')
zIndex: 10000, // minimal z-index for notifications
screenOpacity: 0.5, // opacity of dark screen background that goes behind for modals (between 0 to 1)
width: undefined, // notification's width ('auto' if not set)
modules: {...} // modules to register immediately
});</pre>
</div>
</div>
</div>
</div>
</section>
</div>
<section id="examples">
<div class="page-header">
<h1>Usage - Examples<small></small></h1>
</div>
<div class="row">
<div class="span12">
<h2>Basic Examples</h2>
<div class="bar-spacer">
<div class="ex-bar-ph" id="floatBarPh">
<div class="navbar float-navbar" id="floatBar">
<div class="btns-block wrapper-940">
<span class="lbl">Examples</span>
<button class="btn btn-inverse runnable">notifier.notify("Hi!");</button>
<button class="btn btn-info runnable">notifier.info("Hi!");</button>
<button class="btn btn-warning runnable">notifier.warning("Hi!");</button>
<button class="btn btn-danger runnable">notifier.error("Hi!");</button>
<button class="btn btn-success runnable">notifier.success("Hi!");</button>
<a href="#examples" class="more">more »</a>
</div>
</div>
</div>
</div>
<div class="row">
<div class="span12">
<div class="code-wrapper">
<div class="title">
<h3>Default notification</h3>
<button class="run btn btn-primary"></button>
</div>
<div class="code">
<div class="row">
<div class="span5">
<pre class="runnable"> notifier.notify("Hello World!");</pre>
</div>
<div class="span5">
<pre class="side prettyprint lang-js"> // Is equivalent to:
// notifier.notify({
// message: "Hello World!"
// });</pre>
</div>
</div>
</div>
</div>
</div>
</div><!-- row -->
<div class="row">
<div class="span12">
<div class="code-wrapper">
<div class="title">
<h3>Warning notification</h3>
<button class="run btn btn-primary"></button>
</div>
<div class="code">
<div class="row">
<div class="span5">
<pre class="runnable"> notifier.warning("Hello World!");</pre>
</div>
<div class="span5">
<pre class="side prettyprint lang-js"> // Is equivalent to:
// notifier.notify({
// message: "Hello World!"
// type: 'warning'
// });</pre>
</div>
</div>
</div>
</div>
</div>
</div><!-- row -->
<h2>Advanced Examples</h2>
<div class="row">
<div class="span12">
<div class="code-wrapper">
<div class="title">
<h3>Dialogs</h3>
<button class="run btn btn-primary"></button>
</div>
<div class="code">
<pre class="runnable"><strong>notifier.notify({
title: "Default Dialog Notification",
message: "This is a default styled dialog notification.<br />Wanna see other styles?",
buttons: [
{'data-role': 'myOk', text: 'Sure', 'class': 'default', css: {width: 120}},
{'data-role': 'myOk', text: 'Yes'},
// 'data-role' - an identifier for binding event using notification.on('click:myOk', function(){...});
{'data-handler': 'destroy', text: 'No', 'class': 'link'}
// 'data-handler' - calls a function of notification object,
// i.g.: 'data-handler': 'destroy' => calls notification.destroy() upon clicking the button
],
modal: true,
ms: null,
modal: true,
destroy: false
})
.on('click:myOk', function(){
this.destroy();
notifier.notify({
'type': 'info',
title: "Information",
message: "This is an 'info' styled dialog notification.",
buttons: [
{'data-role': 'ok', text: 'Show More', 'class': 'default'},
{'data-handler': 'destroy', text: 'Cancel', 'class': 'link'}
],
closeBtn: true,
modal: false,
ms: null,
destroy: false
})
.on('click:ok', function(){
notifier.warning({
destroy: true, // will hide all existing notification
title: "Warning!",
message: "This is a warning!",
buttons: [{'data-handler': 'destroy', text: 'Errrr'}]
})
.on('destroy', function(){
notifier.error({
title: "Error Dialog",
message: "That's our error dialog notification",
buttons: [{'data-handler': 'destroy', 'class': 'default', text: 'Ok'}]
})
.on('destroy', function(){
notifier.success({
title: "Success!",
message: "You have successfully completed this example. Well done!",
buttons: [{'data-handler': 'destroy', 'class': 'default', text: 'Finish'}]
});
});
});
});
});</strong></pre></div>
</div>
</div>
</div><!-- row -->
<div class="row">
<div class="span12">
<div class="code-wrapper">
<div class="title">
<h3>"Warning" Modal + Buttons + Events</h3>
<button class="run btn btn-primary"></button>
</div>
<div class="code">
<pre class="runnable"><strong> var confirmMsg = notifier.notify({
message: "Unsaved changes will be lost. Continue anyway?",
'type': "warning",
buttons: [
{'data-role': 'ok', text: 'Continue'},
{'data-role': 'cancel', text: 'Cancel', 'class': 'default'}
],
modal: true,
ms: null,
destroy: false
})
.on('click:ok', function(){
this.destroy();
notifier.success('You have clicked "Continue".');
})
.on('click:cancel', 'destroy');</strong></pre></div>
</div>
</div>
</div><!-- row -->
<div class="row">
<div class="span12">
<div class="code-wrapper">
<div class="title">
<h3>"Info" Centered Modal + Buttons + Events</h3>
<button class="run btn btn-primary"></button>
</div>
<div class="code"><pre class="runnable">
<strong> var confirmMsg = notifier.notify({
message: "Unsaved changes will be lost. Continue anyway?",
'type': "info",
buttons: [
{'data-role': 'ok', text: 'Continue'},
{'data-role': 'cancel', text: 'Cancel', 'class': 'default'}
],
modal: true,
position: 'center',
ms: null,
destroy: false
})
.on('click:ok', function(){
this.destroy();
notifier.success('You have clicked "Continue".');
})
.on('click:cancel', 'destroy');</strong></pre></div>
</div>
</div>
</div><!-- row -->
<div class="row">
<div class="span12">
<div class="code-wrapper">
<div class="title">
<h3>Transparent "Info" + (3 sec.) Loader</h3>
<button class="run btn btn-primary"></button>
</div>
<div class="code"><pre class="runnable">
<strong>notifier.info({
message: "Loading...",
destroy: true, // hides all existing notification
opacity: .5,
ms: 3000,
loader: true
});</strong></pre></div>
</div>
</div>
</div><!-- row -->
<div class="row">
<div class="span12">
<div class="code-wrapper">
<div class="title">
<h3>No Animation Centered Modal + (3 sec.) Loader</h3>
<button class="run btn btn-primary"></button>
</div>
<div class="code"><pre class="runnable">
<strong>notifier.notify({
message: "Loading...",
position: 'center',
fadeInMs: 0,
fadeOutMs: 0,
ms: 3000,
modal: true,
loader: true
});</strong></pre></div>
</div>
</div>
</div><!-- row -->
<div class="row">
<div class="span12">
<div class="code-wrapper">
<div class="title">
<h3>Error + Slow Fading + Stays Until Click</h3>
<button class="run btn btn-primary"></button>
</div>
<div class="code"><pre class="runnable">
<strong>notifier.error({
message: "<em>Error</em>: An error has occurred",
ms: false,
fadeInMs: 2500,
fadeOutMs: 2500
});</strong></pre></div>
</div>
</div>
</div><!-- row -->
<div class="row">
<div class="span12">
<div class="code-wrapper">
<div class="title">
<h3>Success + Modal + Long Text</h3>
<button class="run btn btn-primary"></button>
</div>
<div class="code"><pre class="runnable">
<strong>notifier.notify({
'type': 'success',
fadeInMs: 1000,
fadeOutMs: 1000,
modal: true,
hideOnClick: true,
message: "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>"
});</strong></pre></div>
</div>
</div>
</div>
<h2>Ultimate Destruction</h2>
<div class="row">
<div class="span12">
<div class="code-wrapper">
<div class="title">
<h3>Destruction by Reference</h3>
<button class="run btn btn-primary"></button>
</div>
<div class="code"><pre class="runnable">
<strong> var loader = notifier.notify({
'type': 'info',
modal: true,
loader: true,
myAttr: 'ajaxLoader',
ms: false,
position: 'center',
message: "Loading..."
});
notifier.warning({
ms: false,
message: "This is another message, unrelated to the ajax request."
});
$.ajax({
url: 'http://www.google.com/dummy-url/?callback=?',
timeout: 2000,
dataType: 'jsonp',
complete: function(){
loader.destroy(); // reference
}
});</strong></pre></div>
</div>
</div>
</div><!-- row -->
<div class="row">
<div class="span12">
<div class="code-wrapper">
<div class="title">
<h3>Notifier.destroyAll()</h3>
<button class="run btn btn-primary"></button>
</div>
<div class="code"><pre class="runnable">
<strong> notifier.info({
modal: true,
loader: true,
message: "Loading..."
});
$.ajax({
url: 'http://www.google.com/dummy-url/?callback=?',
timeout: 2000,
dataType: 'jsonp',
complete: function(){
notifier.destroyAll(); // hide all instances
}
});</strong></pre></div>
</div>
</div>
</div><!-- row -->
<div class="row">
<div class="span12">
<div class="code-wrapper">
<div class="title">
<h3>Notifier.destroyAll(attributeSelectorKey, attributeSelectorValue)</h3>
<button class="run btn btn-primary"></button>
</div>
<div class="code"><pre class="runnable">
<strong> notifier.notify({
'type': 'info',
modal: true,
loader: true,
myAttr: 'ajaxLoader',
ms: false,
position: 'center',
message: "Loading..."
});
notifier.notify({
'type': 'warning',
ms: 8000,
message: "This is another message, unrelated to the ajax request."
});
$.ajax({
url: 'http://www.google.com/dummy-url/?callback=?',
timeout: 2000,
dataType: 'jsonp',
complete: function(){
notifier.destroyAll('myAttr', 'ajaxLoader'); // attribute selector or no arguments to hide all instances
}
});</strong></pre></div>
</div>
</div>
</div><!-- row -->
<div class="row">
<div class="span12">
<div class="code-wrapper">
<div class="title">
<h3>Destroy Previous Notifications</h3>
<button class="run btn btn-primary"></button>
</div>
<div class="code"><pre class="runnable">
<strong> notifier.notify({
'type': 'info',
modal: true,
loader: true,
message: "Loading..."
});
$.ajax({
url: 'http://www.google.com/dummy-url/?callback=?',
timeout: 2000,
dataType: 'jsonp',
complete: function(){
notifier.notify({
'type': 'success',
ms: 10000,
destroy: true, // destroy any existing notifications.
// can also pass attribute selector (e.g. ['loader', true] )
message: "Request completed.<br /> <strong>Notice how this notification caused " +
"previous notifications to disappear.</strong>"
});
}
});</strong></pre></div>
</div>
</div>
</div><!-- row -->
</div>
</div><!-- row -->
</section>
<section id="modules">
<div class="page-header">
<h1>Modules</h1>
</div>
<div class="row">
<div class="span12">
<h4>Backbone.Notifier also features light and simple extendability abilities using unique modules architecture.</h4>
<p><strong>Load a module</strong>: add a script tag with 'src' to its path, <strong>after</strong> <code><script type="text/javascript" src="<strong><a href="js/Backbone.Notifier.js">js/Backbone.Notifier.js</a></strong>"></script></code>.
<br>The module should call <code>Notifier.regModule()</code> (as described below).
</p>
<p><strong>Enable a module</strong> (after it has been loaded): call <code>Backbone.Notifier.enableModule(<em>moduleName</em>)</code>.</p>
<p><strong>Disable a module</strong> (after it has been loaded): call <code>Backbone.Notifier.disableModule(<em>moduleName</em>)</code>.</p>
<p class="alert alert-warning">Please note, modules are shared by all instances of Backbone.Notifier!</p>
<div class="module-toggle-block well" data-module="logger" data-msg-enable="<br />See log in developer console (F12).">
<p><strong>Demo: <a href="js/modules/logger.js">Logger module</a></strong> - logs notification info using console.log (hit <code>F12</code> to check it out)</p>
<div class="module-state-controls">
<button class="btn-module btn btn-primary" data-text-0="Enable" data-text-1="Disable"></button>
<label class="lbl-module-state">Current state: <span data-text-0="Disabled" data-text-1="Enabled"></span></label>
<div class="clearfix"></div>
</div>
</div>
<div class="module-toggle-block well" data-module="3d">
<p><strong>Demo: <a href="js/modules/3d.js">3D module</a></strong> (requires modern browser)</p>
<div id="notSupported3d" class="alert alert-error" style="display: none;">Your browser doesn't support this feature (CSS3 required)</div>
<div class="module-state-controls">
<button id="btn3d" class="btn-module btn btn-primary" data-text-0="Enable" data-text-1="Disable"></button>
<label class="lbl-module-state">Current state: <span data-text-0="Disabled" data-text-1="Enabled"></span></label>
<div class="clearfix"></div>
</div>
</div>
<div id="moduleDesign" class="well well-block">
<h4>Module Design - Logger Module (Example)</h4>
<pre class="prettyprint lang-js">(function(Notifier, $){
Notifier.regModule({
name: 'logger', // Required.
enabled: true, // Optional. Whether you like the module to be auto-enabled upon registration (default: false).
extend: { // Optional. Data/functions to extend Backbone.Notifier.prototype
defaults: {
'showInLog': true
},
// Overriding existing function of Backbone.Notifier.prototype
// "this" refers to:
// {
// supr: function(){/* the function we override */},
// module: {/* this module */}},
// scope: {/* this context of the function we override (an *instance* of Backbone.Notifier) */}}
// }
// 'initialize' is called when instantiating a new Backbone.Notifier
initialize: function(){
this.scope._loggerNotifierId = ++this.module._notifiers;
this.module._log('initializing notifier #' + this.scope._loggerNotifierId);
return this.supr.apply(this.scope, arguments);
}
},
// Optional. Unique events accessible for modules, dynamic binding/unbinding is not supported (at the moment).
// In all event handlers, "this" refers to:
// {
// module: {/* this module */}},
// scope: {/* this context of the function we override (an *instance* of Backbone.Notifier) */}}
// }
events: {
'beforeAppendMsgEl': function(settings, msgEl, msgInner){
settings._loggerNotificationId = ++this.module._notifications;
settings.showInLog && this.module._log('beforeAppendMsgEl #' + settings._loggerNotificationId, settings);
},
'beforeAnimateInMsgEl': function(settings, msgEl, msgInner, msgView){
settings.showInLog && this.module._log('beforeAnimateInMsgEl #' + settings._loggerNotificationId, msgView);
},
'afterAnimateInMsgEl': function(settings, msgEl, msgInner, msgView){
settings.showInLog && this.module._log('afterAnimateInMsgEl #' + settings._loggerNotificationId, msgView);
},
'beforeHideMsgEl': function(settings, msgEl, msgInner, msgView){
settings.showInLog && this.module._log('beforeHideMsgEl #' + settings._loggerNotificationId, msgView);
},
'afterDestroyMsgEl': function(settings, msgEl, msgInner, msgView){
settings.showInLog && this.module._log('afterDestroyMsgEl #' + settings._loggerNotificationId, msgView);
}
},
// Helper function defined for this module.
_log: function(a, b){
a = 'logger: ' + a;
arguments.length >= 2 ? console.log(a, b) : console.log(a);
},
// Optional. Triggers immediately when Backbone.Notifier finishes the 'regModule' action
register: function(){
this._notifications = 0;
this._notifiers = 0;
this._log(this.name + ' module was registered');
},
// Optional. Called after module is enabled by Backbone.Notifier.enableModule(moduleName)
// or after registration when 'enabled' property is set to true.
enable: function(){
this._log(this.name + ' module was enabled');
},
// Optional. Called after module is disabled by Backbone.Notifier.disableModule(moduleName)
disable: function(){
this._log(this.name + ' module was disabled');
}
});
})(Backbone.Notifier, jQuery);</pre>
</div>
</div>
</div>
</section>
<div id="footer"></div>
</div>
<!-- Dependencies -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min.js"></script>
<script>
window.jQuery || document.write('<script type="text/javascript" src="dependencies/jquery-1.9.1.min.js"><\/script>');
window._ || document.write('<script type="text/javascript" src="dependencies/underscore-1.3.3.min.js"><\/script>');
window.JSON || document.write('<script type="text/javascript" src="dependencies/json2.js"><\/script>');
window.Backbone || document.write('<script type="text/javascript" src="dependencies/backbone-1.0.0.js"><\/script>');
</script>
<!-- /Dependencies -->
<!-- Backbone.Notifier -->
<script type="text/javascript" src="js/Backbone.Notifier.js?_0.2.5"></script>
<!-- Optional modules -->
<script type="text/javascript" src="js/modules/3d.js?_0.2.5"></script>
<script type="text/javascript" src="js/modules/logger.js?_0.2.5"></script>
<script type="text/javascript" src="js/modules/template.js?_0.2.5"></script>
<!-- Optional modules -->
<!-- /Backbone.Notifier -->
<!-- Used by example page -->
<script type="text/javascript" src="example-js/prettify.js"></script>
<script type="text/javascript" src="example-js/example.js?_0.2.5"></script>
<!-- /Used by example page -->
<!--Google Analytics-->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-11361452-2']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>