forked from TurnWheel/jReject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.html
681 lines (590 loc) · 17.9 KB
/
doc.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>jReject - jQuery Plugin for Simple Browser Rejection</title>
<meta name="description" content="jReject: jQuery Browser Rejection Plugin" />
<link href="css/jquery.reject.css" rel="stylesheet" type="text/css" />
<style type="text/css">
* {
margin: 0;
padding: 0;
}
body {
background: #f7f7f7;
font-size: 14px;
font-family: 'Arial', sans-serif;
}
a {
text-decoration: none;
color: #025167;
}
a:hover {
text-decoration: underline;
}
a:visited {
color: #025167;
}
a[rel="external"] {
font-weight: bold;
}
strong {
color: #262626;
text-decoration: underline;
}
h1 {
color: #5DB0E6;
margin-bottom: 20px;
}
h2 {
color: #a61700;
margin: 20px 0;
}
h3 {
color: #0082a9;
text-decoration: underline;
}
hr {
outline: 0;
border: 0;
width: 50%;
height: 1px;
margin: 20px auto;
background: #CCC;
}
p {
margin: 10px 0;
}
pre {
width: 100%;
font-family: monospace;
}
acronym {
border-bottom: 1px dashed #000;
cursor: help;
}
#wrapper {
margin: 0 auto;
width: 960px;
border: 1px solid #088de0;
border-top: 0;
border-bottom: 0;
}
#content {
width: 940px;
padding: 10px;
background: #f5f5f5;
}
.box, pre.javascript {
width: 90%;
border: 1px dashed #0082a9;
background: #cecccc;
padding: 10px;
}
.box {
width: 80%;
}
.example {
margin: 30px 0;
}
.example h3 {
display: inline;
}
a.demo {
font-weight: bold;
display: inline;
margin-left: 10px;
}
a.demo:active {
color: red;
}
</style>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="js/jquery.reject.js"></script>
<script>
$(function() {
// Handle external links
$('a[rel="external"]').click(function() {
var href = $(this).attr('href');
// Send external link event to Google Analytics
try {
_gaq.push(['_trackEvent','External Links', href.split(/\/+/g)[1], href]);
} catch (e) {};
window.open(href,'jr_'+Math.round(Math.random()*11));
return false;
});
// Handle displaying of option links
$('em.option').css({
cursor: 'pointer',
fontSize: '1.1em',
color: '#333',
letterSpacing: '1px',
borderBottom: '1px dashed #BBB'
}).click(function() {
var self = $(this);
var opt = $.trim(self.text());
$('ol.dp-c:first').children('li').children('span').each(function() {
var self = $(this);
var text = self.text();
var srch = opt+':';
// If found, highlight and jump window to position on page
if (text.search(srch) !== -1) {
self.css('color','red');
window.location.hash = '#c-'+opt;
window.scrollTo(0,self[0].offsetTop);
}
});
});
/* Demo Codes */
$('#demo1').click(function() {
$.reject(); // Default Settings
return false;
});
$('#demo2').click(function() {
$.reject({
reject: {
safari: true, // Apple Safari
chrome: true, // Google Chrome
firefox: true, // Mozilla Firefox
msie: true, // Microsoft Internet Explorer
opera: true, // Opera
konqueror: true, // Konqueror (Linux)
unknown: true // Everything else
}
}); // Customized Browsers
return false;
});
$('#demo3').click(function() {
$.reject({
reject: { all: true }, // Reject all renderers for demo
header: 'Your browser is not supported here', // Header Text
paragraph1: 'You are currently using an unsupported browser', // Paragraph 1
paragraph2: 'Please install one of the many optional browsers below to proceed',
closeMessage: 'Close this window at your own demise!' // Message below close window link
}); // Customized Text
return false;
});
$('#demo4').click(function() {
$.reject({
reject: { all: true }, // Reject all renderers for demo
display: ['firefox','chrome','opera'] // Displays only firefox, chrome, and opera
});
return false;
});
$('#demo5').click(function() {
$.reject({
reject: { all: true }, // Reject all renderers for demo
// Displays only custom "Konqueror" browser, firefox and opera.
display: ['konqueror','firefox','opera'],
browserInfo: {
konqueror: { // Specifies browser name and image name (browser_konqueror.gif)
text: 'Konqueror', // Text Link
url: 'http://konqueror.kde.org/' // URL To link to
}
}
});
return false;
});
$('#demo6').click(function() {
$.reject({
reject: { all: true }, // Reject all renderers for demo
closeCookie: true // Set cookie to remmember close for this session
});
return false;
});
$('#demo7').click(function() {
$.reject({
reject: { all: true }, // Reject all renderers for demo
close: false, // Prevent closing of window
paragraph1: 'You will not be able to close this window', // Warning about closing
paragraph2: 'To exit, you must '+
'<a href="javascript:window.location=window.location.pathname;">refresh the page</a>'
});
return false;
});
$('#demo8').click(function() {
$.reject({
reject: { all: true }, // Reject all renderers for demo
beforeReject: function() {
if ($.browser.name === 'chrome') {
this.display = ['firefox','opera'];
}
if ($.os.name === 'iphone' || $.os.name === 'ipad') {
this.browserShow = false;
this.paragraph2 = '';
}
}
});
return false;
});
});
</script>
</head>
<body>
<div id="wrapper">
<section id="content">
<h1>jReject: jQuery Browser Rejection</h1>
<p class="box">
jReject is a simple, light-weight library designed to
display a popup based on the browser, specific browser version,
specific platforms, or rendering engine. Provides full customization
of the popup, and uses a small CSS file. Can easily be used on page load
or during a specific page event. Also provides a flexible way to beautifully
and cleanly display custom browser alternatives in the popup.
</p>
<h2>Requirements</h2>
<p><a href="http://jquery.com/" rel="external">jQuery 1.7+</a></p>
<h2>Makes Use Of</h2>
<strong>jQuery Browser Plugin</strong> - Updated version included in default package.
<a href="http://jquery.thewikies.com/browser" rel="external">(View Original)</a>
<h2>Download jReject</h2>
<p>
<a href="https://github.com/TurnWheel/jReject" rel="external">Get Latest At GitHub</a>
</p>
<p>
If you are a developer familiar with using jQuery, continue with the documentation below.
</p>
<hr />
<h2>Documentation</h2>
<section id="documentation">
<p>
The object is called "reject", and can be invoked once the document
is ready ($.reject() or jQuery.reject()). The first parameter
contains all the options and configurations for the plugin.
</p>
<h3>Default Options</h3>
<p>
Here are the default options for the first parameter of the reject
object. You only need to specify those which you wish to override.
</p>
<pre name="code" class="javascript" id="options">
options = {
// Specifies which browsers/versions will be blocked
reject : {
all: false, // Covers Everything (Nothing blocked)
msie: 6 // Covers MSIE <= 6 (Blocked by default)
/*
* Many possible combinations.
* You can specify browser (msie, chrome, firefox)
* You can specify rendering engine (geko, trident)
* You can specify OS (Win, Mac, Linux, Solaris, iPhone, iPad)
*
* You can specify versions of each.
* Examples: msie9: true, firefox8: true,
*
* You can specify the highest number to reject.
* Example: msie: 9 (9 and lower are rejected.
*
* There is also "unknown" that covers what isn't detected
* Example: unknown: true
*/
},
display: [], // What browsers to display and their order (default set below)
browserShow: true, // Should the browser options be shown?
browserInfo: { // Settings for which browsers to display
chrome: {
// Text below the icon
text: 'Google Chrome',
// URL For icon/text link
url: 'http://www.google.com/chrome/',
// (Optional) Use "allow" to customized when to show this option
// Example: to show chrome only for IE users
// allow: { all: false, msie: true }
},
firefox: {
text: 'Mozilla Firefox',
url: 'http://www.mozilla.com/firefox/'
},
safari: {
text: 'Safari',
url: 'http://www.apple.com/safari/download/'
},
opera: {
text: 'Opera',
url: 'http://www.opera.com/download/'
},
msie: {
text: 'Internet Explorer',
url: 'http://www.microsoft.com/windows/Internet-explorer/'
}
},
// Pop-up Window Text
header: 'Did you know that your Internet Browser is out of date?',
paragraph1: 'Your browser is out of date, and may not be compatible with '+
'our website. A list of the most popular web browsers can be '+
'found below.',
paragraph2: 'Just click on the icons to get to the download page',
// Allow closing of window
close: true,
// Message displayed below closing link
closeMessage: 'By closing this window you acknowledge that your experience '+
'on this website may be degraded',
closeLink: 'Close This Window',
closeURL: '#',
// Allows closing of window with esc key
closeESC: true,
// Use cookies to remmember if window was closed previously?
closeCookie: false,
// Cookie settings are only used if closeCookie is true
cookieSettings: {
// Path for the cookie to be saved on
// Should be root domain in most cases
path: '/',
// Expiration Date (in seconds)
// 0 (default) means it ends with the current session
expires: 0
},
// Path where images are located
imagePath: './images/',
// Background color for overlay
overlayBgColor: '#000',
// Background transparency (0-1)
overlayOpacity: 0.8,
// Fade in time on open ('slow','medium','fast' or integer in ms)
fadeInTime: 'fast',
// Fade out time on close ('slow','medium','fast' or integer in ms)
fadeOutTime: 'fast',
// Google Analytics Link Tracking (Optional)
// Set to true to enable
// Note: Analytics tracking code must be added separately
analytics: false
};
</pre>
</section><br />
<h3>Optional Event Methods</h3>
<strong>options.beforeReject()</strong><br />
<p>Called before rejection is determined.</p><br />
<strong>options.afterReject()</strong><br />
<p>Called after rejection window has been created, for browsers that matched the rejection settings.</p><br />
<strong>options.onFail()</strong><br />
<p>Called if the browser does NOT meet the rejection requirements</p><br />
<strong>options.beforeClose()</strong><br />
<p>Called after close button is clicked, but before popup is actually closed.</p><br />
<strong>options.afterClose()</strong><br />
<p>Called after rejection popup is closed</p><br />
<p>
<strong>Note:</strong> All callbacks can access and edit options by using <em>this</em><br />
View <a href="#demo8">Demo #8</a> as an example
</p>
<h2>Browser Plugin Options</h2>
<script>
$(function() {
$('#b_className').text($.browser.className);
$('#b_name').text($.browser.name);
$('#b_version').text($.browser.version);
$('#b_versionX').text($.browser.versionX);
$('#b_osname').text($.os.name);
});
</script>
$.browser.className = <strong id="b_className"></strong><br />
$.browser.name = <strong id="b_name"></strong><br />
$,browser.version = <strong id="b_version"></strong><br />
$.browser.versionX = <strong id="b_versionX"></strong><br />
$.os.name = <strong id="b_osname"></strong><br />
<hr />
<h2>Example Usage</h2>
<div class="example">
<h3>Demo #1: Default Settings</h3>
<a href="#" id="demo1" class="demo">Run Demo</a><br />
<p>
If nothing happened when you ran this demo, that is because you are not using IE6!<br />
By default (no settings specified) the reject function only rejects IE5 and IE6.
</p>
<pre name="code" class="javascript">
$('#demo1').click(function() {
$.reject(); // Default Settings
return false;
});
</pre>
</div>
<hr />
<div class="example">
<h3>Demo #2: Customize Browsers To Reject</h3>
<a href="#" id="demo2" class="demo">Run Demo</a><br />
<p>
In this example pretty much every browser should be rejected.
</p>
<pre name="code" class="javascript">
$('#demo2').click(function() {
$.reject({
reject: {
safari: true, // Apple Safari
chrome: true, // Google Chrome
firefox: true, // Mozilla Firefox
msie: true, // Microsoft Internet Explorer
opera: true, // Opera
konqueror: true, // Konqueror (Linux)
unknown: true // Everything else
}
}); // Customized Browsers
return false;
});
</pre>
</div>
<hr />
<div class="example">
<h3>Demo #3: Customize Popup Text</h3>
<a href="#" id="demo3" class="demo">Run Demo</a><br />
<p>
In this demo we use customized text in the popup window.
This demo uses the following properties:<br />
<em class="option">header</em>,
<em class="option">paragraph1</em>,
<em class="option">paragraph2</em>,
<em class="option">closeMessage</em><br />
<strong>See Also</strong> <em class="option">closeLink</em>
</p>
<pre name="code" class="javascript">
$('#demo3').click(function() {
$.reject({
reject: { all: true }, // Reject all renderers for demo
header: 'Your browser is not supported here', // Header Text
paragraph1: 'You are currently using an unsupported browser', // Paragraph 1
paragraph2: 'Please install one of the many optional browsers below to proceed',
closeMessage: 'Close this window at your own demise!' // Message below close window link
}); // Customized Text
return false;
});
</pre>
</div>
<hr />
<div class="example">
<h3>Demo #4: Customize Browsers To Suggest</h3>
<a href="#" id="demo4" class="demo">Run Demo</a><br />
<p>
Using the <em class="option">display</em> option, you can define
which browsers to suggest, and the order in which to suggest them.
</p>
<p>
<strong>Default:</strong> ['firefox','chrome','msie','safari','opera']
</p>
<pre name="code" class="javascript">
$('#demo4').click(function() {
$.reject({
reject: { all: true }, // Reject all renderers for demo
display: ['firefox','chrome','opera'] // Displays only firefox, chrome, and opera
});
return false;
});
</pre>
</div>
<hr />
<div class="example">
<h3>Demo #5: Customize Your Own Browser Suggestion</h3>
<a href="#" id="demo5" class="demo">Run Demo</a><br />
<p>
You can even add a customized browser to the list, and display it in any order you want.
</p>
<p>
<strong>Note:</strong> To add your own icon, you need to create a 'browser_{browserName}.gif'<br />
file and place it in your <em class="option">imagePath</em> directory with the other images.<br />
<strong>Image Dimensions:</strong> 100x100<br />
</p>
<pre name="code" class="javascript">
$('#demo5').click(function() {
$.reject({
reject: { all: true }, // Reject all renderers for demo
// Displays only custom "Konqueror" browser, firefox and opera.
display: ['konqueror','firefox','opera'],
browserInfo: {
konqueror: { // Specifies browser name and image name (browser_konqueror.gif)
text: 'Konqueror 4', // Text Link
url: 'http://konqueror.kde.org/' // URL To link to
}
}
});
return false;
});
</pre>
</div>
<hr />
<div class="example">
<h3>Demo #6: Display Once Per Session</h3>
<a href="#" id="demo6" class="demo">Run Demo</a><br />
<p>
By using the <em class="option">closeCookie</em> option, you
can make the window only appear once per session.<br />
After it pops up the first time, this demo will not popup again
until next browser session.
</p>
<p>
<strong>Note:</strong> This requires the ability to close the window.
If <em class="option">close</em> is false the cookie will never be set.
</p>
<pre name="code" class="javascript">
$('#demo6').click(function() {
$.reject({
reject: { all: true }, // Reject all renderers for demo
closeCookie: true // Set cookie to remmember close for this session
});
return false;
});
</pre>
</div>
<hr />
<div class="example">
<h3>Demo #7: Disable ability to close window</h3>
<a href="#" id="demo7" class="demo">Run Demo</a><br />
<p>
The <em class="option">close</em> option allows
you to hide the <em class="option">closeLink</em>
or <em class="option">closeMessage</em> elements from displaying.<br />
This prevents the user from closing the window. If you
use this on a onLoad event, the user will never be able to use your site.
</p>
<p>
<strong>Note:</strong> Testing this demo will require you to
refresh the page to close out the popup window.
</p>
<pre name="code" class="javascript">
$('#demo7').click(function() {
$.reject({
reject: { all: true }, // Reject all renderers for demo
close: false, // Prevent closing of window
paragraph1: 'You will not be able to close this window', // Warning about closing
paragraph2: 'To exit, you must '+
'<a href="javascript:window.location=window.location.pathname;">refresh the page</a>'
});
return false;
});
</pre>
</div>
<hr />
<div class="example">
<h3>Demo #8: Customize by Browser</h3>
<a href="#" id="demo8" class="demo">Run Demo</a><br />
<p>
This example uses the <em>beforeReject</em> callback to change options by browser.<br />
In chrome, only FireFox and Opera options will be displayed. iPhone/iPad displays no browser options
</p>
<pre name="code" class="javascript">
$('#demo8').click(function() {
$.reject({
reject: { all: true }, // Reject all renderers for demo
beforeReject: function() {
if ($.browser.name === 'chrome') {
this.display = ['firefox','opera'];
}
if ($.os.name === 'iphone' || $.os.name === 'ipad') {
this.browserShow = false;
this.paragraph2 = '';
}
}
});
return false;
});
</pre>
</div>
<footer>
<div id="copyright">
Concept based on <a href="http://code.google.com/p/ie6-upgrade-warning/" rel="external">"IE6 Upgrade Warning"</a><br />
Coded and Implemented by Steven Bower<br />
© 2009-2012 <a href="http://turnwheel.com/" rel="external">TurnWheel Designs</a>
</div>
</footer>
</section>
<!-- End #content -->
</div>
<!-- End #wrapper -->
</body>
</html>