jreject-rails 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +48 -0
- data/Rakefile +2 -0
- data/jreject-rails.gemspec +19 -0
- data/lib/jreject-rails/engine.rb +5 -0
- data/lib/jreject-rails/version.rb +3 -0
- data/lib/jreject-rails.rb +2 -0
- data/vendor/assets/images/jreject/background_browser.gif +0 -0
- data/vendor/assets/images/jreject/browser_chrome.gif +0 -0
- data/vendor/assets/images/jreject/browser_firefox.gif +0 -0
- data/vendor/assets/images/jreject/browser_konqueror.gif +0 -0
- data/vendor/assets/images/jreject/browser_msie.gif +0 -0
- data/vendor/assets/images/jreject/browser_opera.gif +0 -0
- data/vendor/assets/images/jreject/browser_safari.gif +0 -0
- data/vendor/assets/javascripts/jquery.reject.js.erb +595 -0
- data/vendor/assets/stylesheets/jquery.reject.css +114 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9961e100cd7a0b3ce15c9c09464e64b58dadf849
|
4
|
+
data.tar.gz: ffd9f1ef0cf7d23287a9377705e09f5f0c3096b8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 48644f7acf24d23d7721ce19d77a360701147bb3e87274100de8141df30fdf2d48f895f9a9b931fd02f219d63b6dca2263d68a9adc1f5dd93001c8a2f4319d42
|
7
|
+
data.tar.gz: b2c0c695f7b18222e252bf4f48dcc277e146d13c347dd03da450f0a28edea939b110fe44fe12fb633c2ae5118992d14a435e91690053a36526a99239f6838a64
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Rustam Sharshenov
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# JReject RubyOnRails integration gem
|
2
|
+
|
3
|
+
Use [JReject](http://jreject.turnwheel.com/) with Rails 3.1+
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'jreject-rails'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install jreject-rails
|
18
|
+
|
19
|
+
Now you need to edit your app/assets/javascripts/application.js file and add the following line:
|
20
|
+
``` javascript
|
21
|
+
//= require jquery
|
22
|
+
//= require jquery.reject
|
23
|
+
```
|
24
|
+
|
25
|
+
And then edit your `app/assets/stylesheets/application.css` file to look something like:
|
26
|
+
``` css
|
27
|
+
/*
|
28
|
+
*= require_self
|
29
|
+
*= require jquery.reject
|
30
|
+
*= require_tree .
|
31
|
+
*/
|
32
|
+
```
|
33
|
+
|
34
|
+
## Usage
|
35
|
+
|
36
|
+
With the gem installed and included in your asset manifests, you can now use JReject as you normally would.
|
37
|
+
|
38
|
+
``` javascript
|
39
|
+
$.reject();
|
40
|
+
```
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
1. Fork it ( https://github.com/[my-github-username]/JReject-rails/fork )
|
45
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
46
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
47
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
48
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jreject-rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jreject-rails"
|
8
|
+
spec.version = JReject::VERSION
|
9
|
+
spec.authors = ["Rustam Sharshenov"]
|
10
|
+
spec.email = ["rustam@sharshenov.com"]
|
11
|
+
spec.summary = "Use JReject with Rails"
|
12
|
+
spec.description = "This gem provides JReject for your Rails application."
|
13
|
+
spec.homepage = "https://github.com/sharshenov/jreject-rails"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
|
18
|
+
spec.add_dependency "railties", ">= 3.1.0"
|
19
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,595 @@
|
|
1
|
+
/*!
|
2
|
+
* jReject (jQuery Browser Rejection Plugin)
|
3
|
+
* Version 1.1.x
|
4
|
+
* URL: http://jreject.turnwheel.com/
|
5
|
+
* Description: jReject is a easy method of rejecting specific browsers on your site
|
6
|
+
* Author: Steven Bower (TurnWheel Designs) http://turnwheel.com/
|
7
|
+
* Copyright: Copyright (c) 2009-2014 Steven Bower under dual MIT/GPLv2 license.
|
8
|
+
*/
|
9
|
+
|
10
|
+
(function($) {
|
11
|
+
$.reject = function(options) {
|
12
|
+
var opts = $.extend(true, {
|
13
|
+
// Specifies which browsers/versions will be blocked
|
14
|
+
reject : {
|
15
|
+
all: false, // Covers Everything (Nothing blocked)
|
16
|
+
msie: 6 // Covers MSIE <= 6 (Blocked by default)
|
17
|
+
/*
|
18
|
+
* Many possible combinations.
|
19
|
+
* You can specify browser (msie, chrome, firefox)
|
20
|
+
* You can specify rendering engine (geko, trident)
|
21
|
+
* You can specify OS (Win, Mac, Linux, Solaris, iPhone, iPad)
|
22
|
+
*
|
23
|
+
* You can specify versions of each.
|
24
|
+
* Examples: msie9: true, firefox8: true,
|
25
|
+
*
|
26
|
+
* You can specify the highest number to reject.
|
27
|
+
* Example: msie: 9 (9 and lower are rejected.
|
28
|
+
*
|
29
|
+
* There is also "unknown" that covers what isn't detected
|
30
|
+
* Example: unknown: true
|
31
|
+
*/
|
32
|
+
},
|
33
|
+
display: [], // What browsers to display and their order (default set below)
|
34
|
+
browserShow: true, // Should the browser options be shown?
|
35
|
+
browserInfo: { // Settings for which browsers to display
|
36
|
+
chrome: {
|
37
|
+
// Text below the icon
|
38
|
+
text: 'Google Chrome',
|
39
|
+
// URL For icon/text link
|
40
|
+
url: 'http://www.google.com/chrome/'
|
41
|
+
// (Optional) Use "allow" to customized when to show this option
|
42
|
+
// Example: to show chrome only for IE users
|
43
|
+
// allow: { all: false, msie: true }
|
44
|
+
},
|
45
|
+
firefox: {
|
46
|
+
text: 'Mozilla Firefox',
|
47
|
+
url: 'http://www.mozilla.com/firefox/'
|
48
|
+
},
|
49
|
+
safari: {
|
50
|
+
text: 'Safari',
|
51
|
+
url: 'http://www.apple.com/safari/download/'
|
52
|
+
},
|
53
|
+
opera: {
|
54
|
+
text: 'Opera',
|
55
|
+
url: 'http://www.opera.com/download/'
|
56
|
+
},
|
57
|
+
msie: {
|
58
|
+
text: 'Internet Explorer',
|
59
|
+
url: 'http://www.microsoft.com/windows/Internet-explorer/'
|
60
|
+
}
|
61
|
+
},
|
62
|
+
|
63
|
+
// Pop-up Window Text
|
64
|
+
header: 'Did you know that your Internet Browser is out of date?',
|
65
|
+
|
66
|
+
paragraph1: 'Your browser is out of date, and may not be compatible with '+
|
67
|
+
'our website. A list of the most popular web browsers can be '+
|
68
|
+
'found below.',
|
69
|
+
|
70
|
+
paragraph2: 'Just click on the icons to get to the download page',
|
71
|
+
|
72
|
+
// Allow closing of window
|
73
|
+
close: true,
|
74
|
+
|
75
|
+
// Message displayed below closing link
|
76
|
+
closeMessage: 'By closing this window you acknowledge that your experience '+
|
77
|
+
'on this website may be degraded',
|
78
|
+
closeLink: 'Close This Window',
|
79
|
+
closeURL: '#',
|
80
|
+
|
81
|
+
// Allows closing of window with esc key
|
82
|
+
closeESC: true,
|
83
|
+
|
84
|
+
// Use cookies to remmember if window was closed previously?
|
85
|
+
closeCookie: false,
|
86
|
+
// Cookie settings are only used if closeCookie is true
|
87
|
+
cookieSettings: {
|
88
|
+
// Path for the cookie to be saved on
|
89
|
+
// Should be root domain in most cases
|
90
|
+
path: '/',
|
91
|
+
// Expiration Date (in seconds)
|
92
|
+
// 0 (default) means it ends with the current session
|
93
|
+
expires: 0
|
94
|
+
},
|
95
|
+
|
96
|
+
// Path where images are located
|
97
|
+
imagePath: "<%= image_path('jreject/background_browser.gif').gsub /background_browser\.gif.*/, '' %>",
|
98
|
+
// Background color for overlay
|
99
|
+
overlayBgColor: '#000',
|
100
|
+
// Background transparency (0-1)
|
101
|
+
overlayOpacity: 0.8,
|
102
|
+
|
103
|
+
// Fade in time on open ('slow','medium','fast' or integer in ms)
|
104
|
+
fadeInTime: 'fast',
|
105
|
+
// Fade out time on close ('slow','medium','fast' or integer in ms)
|
106
|
+
fadeOutTime: 'fast',
|
107
|
+
|
108
|
+
// Google Analytics Link Tracking (Optional)
|
109
|
+
// Set to true to enable
|
110
|
+
// Note: Analytics tracking code must be added separately
|
111
|
+
analytics: false
|
112
|
+
}, options);
|
113
|
+
|
114
|
+
// Set default browsers to display if not already defined
|
115
|
+
if (opts.display.length < 1) {
|
116
|
+
opts.display = [ 'chrome','firefox','safari','opera','msie' ];
|
117
|
+
}
|
118
|
+
|
119
|
+
// beforeRject: Customized Function
|
120
|
+
if ($.isFunction(opts.beforeReject)) {
|
121
|
+
opts.beforeReject();
|
122
|
+
}
|
123
|
+
|
124
|
+
// Disable 'closeESC' if closing is disabled (mutually exclusive)
|
125
|
+
if (!opts.close) {
|
126
|
+
opts.closeESC = false;
|
127
|
+
}
|
128
|
+
|
129
|
+
// This function parses the advanced browser options
|
130
|
+
var browserCheck = function(settings) {
|
131
|
+
// Check 1: Look for 'all' forced setting
|
132
|
+
// Check 2: Browser+major version (optional) (eg. 'firefox','msie','{msie: 6}')
|
133
|
+
// Check 3: Browser+major version (eg. 'firefox3','msie7','chrome4')
|
134
|
+
// Check 4: Rendering engine+version (eg. 'webkit', 'gecko', '{webkit: 537.36}')
|
135
|
+
// Check 5: Operating System (eg. 'win','mac','linux','solaris','iphone')
|
136
|
+
var layout = settings[$.layout.name],
|
137
|
+
browser = settings[$.browser.name];
|
138
|
+
return !!(settings['all']
|
139
|
+
|| (browser && (browser === true || $.browser.versionNumber <= browser))
|
140
|
+
|| settings[$.browser.className]
|
141
|
+
|| (layout && (layout === true || $.layout.versionNumber <= layout))
|
142
|
+
|| settings[$.os.name]);
|
143
|
+
};
|
144
|
+
|
145
|
+
// Determine if we need to display rejection for this browser, or exit
|
146
|
+
if (!browserCheck(opts.reject)) {
|
147
|
+
// onFail: Optional Callback
|
148
|
+
if ($.isFunction(opts.onFail)) {
|
149
|
+
opts.onFail();
|
150
|
+
}
|
151
|
+
|
152
|
+
return false;
|
153
|
+
}
|
154
|
+
|
155
|
+
// If user can close and set to remmember close, initiate cookie functions
|
156
|
+
if (opts.close && opts.closeCookie) {
|
157
|
+
// Local global setting for the name of the cookie used
|
158
|
+
var COOKIE_NAME = 'jreject-close';
|
159
|
+
|
160
|
+
// Cookies Function: Handles creating/retrieving/deleting cookies
|
161
|
+
// Cookies are only used for opts.closeCookie parameter functionality
|
162
|
+
var _cookie = function(name, value) {
|
163
|
+
// Save cookie
|
164
|
+
if (typeof value != 'undefined') {
|
165
|
+
var expires = '';
|
166
|
+
|
167
|
+
// Check if we need to set an expiration date
|
168
|
+
if (opts.cookieSettings.expires !== 0) {
|
169
|
+
var date = new Date();
|
170
|
+
date.setTime(date.getTime()+(opts.cookieSettings.expires*1000));
|
171
|
+
expires = "; expires="+date.toGMTString();
|
172
|
+
}
|
173
|
+
|
174
|
+
// Get path from settings
|
175
|
+
var path = opts.cookieSettings.path || '/';
|
176
|
+
|
177
|
+
// Set Cookie with parameters
|
178
|
+
document.cookie = name+'='+
|
179
|
+
encodeURIComponent((!value) ? '' : value)+expires+
|
180
|
+
'; path='+path;
|
181
|
+
|
182
|
+
return true;
|
183
|
+
}
|
184
|
+
// Get cookie
|
185
|
+
else {
|
186
|
+
var cookie,val = null;
|
187
|
+
|
188
|
+
if (document.cookie && document.cookie !== '') {
|
189
|
+
var cookies = document.cookie.split(';');
|
190
|
+
|
191
|
+
// Loop through all cookie values
|
192
|
+
var clen = cookies.length;
|
193
|
+
for (var i = 0; i < clen; ++i) {
|
194
|
+
cookie = $.trim(cookies[i]);
|
195
|
+
|
196
|
+
// Does this cookie string begin with the name we want?
|
197
|
+
if (cookie.substring(0,name.length+1) == (name+'=')) {
|
198
|
+
var len = name.length;
|
199
|
+
val = decodeURIComponent(cookie.substring(len+1));
|
200
|
+
break;
|
201
|
+
}
|
202
|
+
}
|
203
|
+
}
|
204
|
+
|
205
|
+
// Returns cookie value
|
206
|
+
return val;
|
207
|
+
}
|
208
|
+
};
|
209
|
+
|
210
|
+
// If cookie is set, return false and don't display rejection
|
211
|
+
if (_cookie(COOKIE_NAME)) {
|
212
|
+
return false;
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
// Load background overlay (jr_overlay) + Main wrapper (jr_wrap) +
|
217
|
+
// Inner Wrapper (jr_inner) w/ opts.header (jr_header) +
|
218
|
+
// opts.paragraph1/opts.paragraph2 if set
|
219
|
+
var html = '<div id="jr_overlay"></div><div id="jr_wrap"><div id="jr_inner">'+
|
220
|
+
'<h1 id="jr_header">'+opts.header+'</h1>'+
|
221
|
+
(opts.paragraph1 === '' ? '' : '<p>'+opts.paragraph1+'</p>')+
|
222
|
+
(opts.paragraph2 === '' ? '' : '<p>'+opts.paragraph2+'</p>');
|
223
|
+
|
224
|
+
var displayNum = 0;
|
225
|
+
if (opts.browserShow) {
|
226
|
+
html += '<ul>';
|
227
|
+
|
228
|
+
// Generate the browsers to display
|
229
|
+
for (var x in opts.display) {
|
230
|
+
var browser = opts.display[x]; // Current Browser
|
231
|
+
var info = opts.browserInfo[browser] || false; // Browser Information
|
232
|
+
|
233
|
+
// If no info exists for this browser
|
234
|
+
// or if this browser is not suppose to display to this user
|
235
|
+
// based on "allow" flag
|
236
|
+
if (!info || (info['allow'] != undefined && !browserCheck(info['allow']))) {
|
237
|
+
continue;
|
238
|
+
}
|
239
|
+
|
240
|
+
var url = info.url || '#'; // URL to link text/icon to
|
241
|
+
|
242
|
+
// Generate HTML for this browser option
|
243
|
+
html += '<li id="jr_'+browser+'"><div class="jr_icon"></div>'+
|
244
|
+
'<div><a href="'+url+'">'+(info.text || 'Unknown')+'</a>'+
|
245
|
+
'</div></li>';
|
246
|
+
|
247
|
+
++displayNum;
|
248
|
+
}
|
249
|
+
|
250
|
+
html += '</ul>';
|
251
|
+
}
|
252
|
+
|
253
|
+
// Close list and #jr_list
|
254
|
+
html += '<div id="jr_close">'+
|
255
|
+
// Display close links/message if set
|
256
|
+
(opts.close ? '<a href="'+opts.closeURL+'">'+opts.closeLink+'</a>'+
|
257
|
+
'<p>'+opts.closeMessage+'</p>' : '')+'</div>'+
|
258
|
+
// Close #jr_inner and #jr_wrap
|
259
|
+
'</div></div>';
|
260
|
+
|
261
|
+
var element = $('<div>'+html+'</div>'); // Create element
|
262
|
+
var size = _pageSize(); // Get page size
|
263
|
+
var scroll = _scrollSize(); // Get page scroll
|
264
|
+
|
265
|
+
// This function handles closing this reject window
|
266
|
+
// When clicked, fadeOut and remove all elements
|
267
|
+
element.bind('closejr', function() {
|
268
|
+
// Make sure the permission to close is granted
|
269
|
+
if (!opts.close) {
|
270
|
+
return false;
|
271
|
+
}
|
272
|
+
|
273
|
+
// Customized Function
|
274
|
+
if ($.isFunction(opts.beforeClose)) {
|
275
|
+
opts.beforeClose();
|
276
|
+
}
|
277
|
+
|
278
|
+
// Remove binding function so it
|
279
|
+
// doesn't get called more than once
|
280
|
+
$(this).unbind('closejr');
|
281
|
+
|
282
|
+
// Fade out background and modal wrapper
|
283
|
+
$('#jr_overlay,#jr_wrap').fadeOut(opts.fadeOutTime,function() {
|
284
|
+
$(this).remove(); // Remove element from DOM
|
285
|
+
|
286
|
+
// afterClose: Customized Function
|
287
|
+
if ($.isFunction(opts.afterClose)) {
|
288
|
+
opts.afterClose();
|
289
|
+
}
|
290
|
+
});
|
291
|
+
|
292
|
+
// Show elements that were hidden for layering issues
|
293
|
+
var elmhide = 'embed.jr_hidden, object.jr_hidden, select.jr_hidden, applet.jr_hidden';
|
294
|
+
$(elmhide).show().removeClass('jr_hidden');
|
295
|
+
|
296
|
+
// Set close cookie for next run
|
297
|
+
if (opts.closeCookie) {
|
298
|
+
_cookie(COOKIE_NAME, 'true');
|
299
|
+
}
|
300
|
+
|
301
|
+
return true;
|
302
|
+
});
|
303
|
+
|
304
|
+
// Tracks clicks in Google Analytics (category 'External Links')
|
305
|
+
// only if opts.analytics is enabled
|
306
|
+
var analytics = function(url) {
|
307
|
+
if (!opts.analytics) {
|
308
|
+
return false;
|
309
|
+
}
|
310
|
+
|
311
|
+
// Get just the hostname
|
312
|
+
var host = url.split(/\/+/g)[1];
|
313
|
+
|
314
|
+
// Send external link event to Google Analaytics
|
315
|
+
// Attempts both versions of analytics code. (Newest first)
|
316
|
+
try {
|
317
|
+
// Newest analytics code
|
318
|
+
ga('send', 'event', 'External', 'Click', host, url);
|
319
|
+
} catch (e) {
|
320
|
+
try {
|
321
|
+
_gaq.push([ '_trackEvent', 'External Links', host, url ]);
|
322
|
+
} catch (e) { }
|
323
|
+
}
|
324
|
+
};
|
325
|
+
|
326
|
+
// Called onClick for browser links (and icons)
|
327
|
+
// Opens link in new window
|
328
|
+
var openBrowserLinks = function(url) {
|
329
|
+
// Send link to analytics if enabled
|
330
|
+
analytics(url);
|
331
|
+
|
332
|
+
// Open window, generate random id value
|
333
|
+
window.open(url, 'jr_'+ Math.round(Math.random()*11));
|
334
|
+
|
335
|
+
return false;
|
336
|
+
};
|
337
|
+
|
338
|
+
/*
|
339
|
+
* Trverse through element DOM and apply JS variables
|
340
|
+
* All CSS elements that do not require JS will be in
|
341
|
+
* css/jquery.jreject.css
|
342
|
+
*/
|
343
|
+
|
344
|
+
// Creates 'background' (div)
|
345
|
+
element.find('#jr_overlay').css({
|
346
|
+
width: size[0],
|
347
|
+
height: size[1],
|
348
|
+
background: opts.overlayBgColor,
|
349
|
+
opacity: opts.overlayOpacity
|
350
|
+
});
|
351
|
+
|
352
|
+
// Wrapper for our pop-up (div)
|
353
|
+
element.find('#jr_wrap').css({
|
354
|
+
top: scroll[1]+(size[3]/4),
|
355
|
+
left: scroll[0]
|
356
|
+
});
|
357
|
+
|
358
|
+
// Wrapper for inner centered content (div)
|
359
|
+
element.find('#jr_inner').css({
|
360
|
+
minWidth: displayNum*100,
|
361
|
+
maxWidth: displayNum*140,
|
362
|
+
// min/maxWidth not supported by IE
|
363
|
+
width: $.layout.name == 'trident' ? displayNum*155 : 'auto'
|
364
|
+
});
|
365
|
+
|
366
|
+
element.find('#jr_inner li').css({ // Browser list items (li)
|
367
|
+
background: 'transparent url("'+opts.imagePath+'background_browser.gif") '+
|
368
|
+
'no-repeat scroll left top'
|
369
|
+
});
|
370
|
+
|
371
|
+
element.find('#jr_inner li .jr_icon').each(function() {
|
372
|
+
// Dynamically sets the icon background image
|
373
|
+
var self = $(this);
|
374
|
+
self.css('background','transparent url('+opts.imagePath+'browser_'+
|
375
|
+
(self.parent('li').attr('id').replace(/jr_/,''))+'.gif)'+
|
376
|
+
' no-repeat scroll left top');
|
377
|
+
|
378
|
+
// Send link clicks to openBrowserLinks
|
379
|
+
self.click(function () {
|
380
|
+
var url = $(this).next('div').children('a').attr('href');
|
381
|
+
openBrowserLinks(url);
|
382
|
+
});
|
383
|
+
});
|
384
|
+
|
385
|
+
element.find('#jr_inner li a').click(function() {
|
386
|
+
openBrowserLinks($(this).attr('href'));
|
387
|
+
return false;
|
388
|
+
});
|
389
|
+
|
390
|
+
// Bind closing event to trigger closejr
|
391
|
+
// to be consistant with ESC key close function
|
392
|
+
element.find('#jr_close a').click(function() {
|
393
|
+
$(this).trigger('closejr');
|
394
|
+
|
395
|
+
// If plain anchor is set, return false so there is no page jump
|
396
|
+
if (opts.closeURL === '#') {
|
397
|
+
return false;
|
398
|
+
}
|
399
|
+
});
|
400
|
+
|
401
|
+
// Set focus (fixes ESC key issues with forms and other focus bugs)
|
402
|
+
$('#jr_overlay').focus();
|
403
|
+
|
404
|
+
// Hide elements that won't display properly
|
405
|
+
$('embed, object, select, applet').each(function() {
|
406
|
+
if ($(this).is(':visible')) {
|
407
|
+
$(this).hide().addClass('jr_hidden');
|
408
|
+
}
|
409
|
+
});
|
410
|
+
|
411
|
+
// Append element to body of document to display
|
412
|
+
$('body').append(element.hide().fadeIn(opts.fadeInTime));
|
413
|
+
|
414
|
+
// Handle window resize/scroll events and update overlay dimensions
|
415
|
+
$(window).bind('resize scroll',function() {
|
416
|
+
var size = _pageSize(); // Get size
|
417
|
+
|
418
|
+
// Update overlay dimensions based on page size
|
419
|
+
$('#jr_overlay').css({
|
420
|
+
width: size[0],
|
421
|
+
height: size[1]
|
422
|
+
});
|
423
|
+
|
424
|
+
var scroll = _scrollSize(); // Get page scroll
|
425
|
+
|
426
|
+
// Update modal position based on scroll
|
427
|
+
$('#jr_wrap').css({
|
428
|
+
top: scroll[1] + (size[3]/4),
|
429
|
+
left: scroll[0]
|
430
|
+
});
|
431
|
+
});
|
432
|
+
|
433
|
+
// Add optional ESC Key functionality
|
434
|
+
if (opts.closeESC) {
|
435
|
+
$(document).bind('keydown',function(event) {
|
436
|
+
// ESC = Keycode 27
|
437
|
+
if (event.keyCode == 27) {
|
438
|
+
element.trigger('closejr');
|
439
|
+
}
|
440
|
+
});
|
441
|
+
}
|
442
|
+
|
443
|
+
// afterReject: Customized Function
|
444
|
+
if ($.isFunction(opts.afterReject)) {
|
445
|
+
opts.afterReject();
|
446
|
+
}
|
447
|
+
|
448
|
+
return true;
|
449
|
+
};
|
450
|
+
|
451
|
+
// Based on compatibility data from quirksmode.com
|
452
|
+
// This is used to help calculate exact center of the page
|
453
|
+
var _pageSize = function() {
|
454
|
+
var xScroll = window.innerWidth && window.scrollMaxX ?
|
455
|
+
window.innerWidth + window.scrollMaxX :
|
456
|
+
(document.body.scrollWidth > document.body.offsetWidth ?
|
457
|
+
document.body.scrollWidth : document.body.offsetWidth);
|
458
|
+
|
459
|
+
var yScroll = window.innerHeight && window.scrollMaxY ?
|
460
|
+
window.innerHeight + window.scrollMaxY :
|
461
|
+
(document.body.scrollHeight > document.body.offsetHeight ?
|
462
|
+
document.body.scrollHeight : document.body.offsetHeight);
|
463
|
+
|
464
|
+
var windowWidth = window.innerWidth ? window.innerWidth :
|
465
|
+
(document.documentElement && document.documentElement.clientWidth ?
|
466
|
+
document.documentElement.clientWidth : document.body.clientWidth);
|
467
|
+
|
468
|
+
var windowHeight = window.innerHeight ? window.innerHeight :
|
469
|
+
(document.documentElement && document.documentElement.clientHeight ?
|
470
|
+
document.documentElement.clientHeight : document.body.clientHeight);
|
471
|
+
|
472
|
+
return [
|
473
|
+
xScroll < windowWidth ? xScroll : windowWidth, // Page Width
|
474
|
+
yScroll < windowHeight ? windowHeight : yScroll, // Page Height
|
475
|
+
windowWidth,windowHeight
|
476
|
+
];
|
477
|
+
};
|
478
|
+
|
479
|
+
|
480
|
+
// Based on compatibility data from quirksmode.com
|
481
|
+
var _scrollSize = function() {
|
482
|
+
return [
|
483
|
+
// scrollSize X
|
484
|
+
window.pageXOffset ? window.pageXOffset : (document.documentElement &&
|
485
|
+
document.documentElement.scrollTop ?
|
486
|
+
document.documentElement.scrollLeft : document.body.scrollLeft),
|
487
|
+
|
488
|
+
// scrollSize Y
|
489
|
+
window.pageYOffset ? window.pageYOffset : (document.documentElement &&
|
490
|
+
document.documentElement.scrollTop ?
|
491
|
+
document.documentElement.scrollTop : document.body.scrollTop)
|
492
|
+
];
|
493
|
+
};
|
494
|
+
})(jQuery);
|
495
|
+
|
496
|
+
/*
|
497
|
+
* jQuery Browser Plugin
|
498
|
+
* Version 2.4 / jReject 1.0.x
|
499
|
+
* URL: http://jquery.thewikies.com/browser
|
500
|
+
* Description: jQuery Browser Plugin extends browser detection capabilities and
|
501
|
+
* can assign browser selectors to CSS classes.
|
502
|
+
* Author: Nate Cavanaugh, Minhchau Dang, Jonathan Neal, & Gregory Waxman
|
503
|
+
* Updated By: Steven Bower for use with jReject plugin
|
504
|
+
* Copyright: Copyright (c) 2008 Jonathan Neal under dual MIT/GPL license.
|
505
|
+
*/
|
506
|
+
|
507
|
+
(function ($) {
|
508
|
+
$.browserTest = function (a, z) {
|
509
|
+
var u = 'unknown',
|
510
|
+
x = 'X',
|
511
|
+
m = function (r, h) {
|
512
|
+
for (var i = 0; i < h.length; i = i + 1) {
|
513
|
+
r = r.replace(h[i][0], h[i][1]);
|
514
|
+
}
|
515
|
+
|
516
|
+
return r;
|
517
|
+
}, c = function (i, a, b, c) {
|
518
|
+
var r = {
|
519
|
+
name: m((a.exec(i) || [u, u])[1], b)
|
520
|
+
};
|
521
|
+
|
522
|
+
r[r.name] = true;
|
523
|
+
|
524
|
+
if (!r.opera) {
|
525
|
+
r.version = (c.exec(i) || [x, x, x, x])[3];
|
526
|
+
}
|
527
|
+
else {
|
528
|
+
r.version = window.opera.version();
|
529
|
+
}
|
530
|
+
|
531
|
+
if (/safari/.test(r.name)) {
|
532
|
+
var safariversion = /(safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/;
|
533
|
+
var res = safariversion.exec(i);
|
534
|
+
if (res && res[3] && res[3] < 400) {
|
535
|
+
r.version = '2.0';
|
536
|
+
}
|
537
|
+
}
|
538
|
+
|
539
|
+
else if (r.name === 'presto') {
|
540
|
+
r.version = ($.browser.version > 9.27) ? 'futhark' : 'linear_b';
|
541
|
+
}
|
542
|
+
|
543
|
+
if (/msie/.test(r.name) && r.version === x) {
|
544
|
+
var ieVersion = /rv:(\d+\.\d+)/.exec(i);
|
545
|
+
r.version = ieVersion[1];
|
546
|
+
}
|
547
|
+
|
548
|
+
r.versionNumber = parseFloat(r.version, 10) || 0;
|
549
|
+
var minorStart = 1;
|
550
|
+
|
551
|
+
if (r.versionNumber < 100 && r.versionNumber > 9) {
|
552
|
+
minorStart = 2;
|
553
|
+
}
|
554
|
+
|
555
|
+
r.versionX = (r.version !== x) ? r.version.substr(0, minorStart) : x;
|
556
|
+
r.className = r.name + r.versionX;
|
557
|
+
|
558
|
+
return r;
|
559
|
+
};
|
560
|
+
|
561
|
+
a = (/Opera|Navigator|Minefield|KHTML|Chrome|CriOS/.test(a) ? m(a, [
|
562
|
+
[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/, ''],
|
563
|
+
['Chrome Safari', 'Chrome'],
|
564
|
+
['CriOS', 'Chrome'],
|
565
|
+
['KHTML', 'Konqueror'],
|
566
|
+
['Minefield', 'Firefox'],
|
567
|
+
['Navigator', 'Netscape']
|
568
|
+
]) : a).toLowerCase();
|
569
|
+
|
570
|
+
$.browser = $.extend((!z) ? $.browser : {}, c(a,
|
571
|
+
/(camino|chrome|crios|firefox|netscape|konqueror|lynx|msie|trident|opera|safari)/,
|
572
|
+
[
|
573
|
+
['trident', 'msie']
|
574
|
+
],
|
575
|
+
/(camino|chrome|crios|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|rv|safari)(:|\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/));
|
576
|
+
|
577
|
+
$.layout = c(a, /(gecko|konqueror|msie|trident|opera|webkit)/, [
|
578
|
+
['konqueror', 'khtml'],
|
579
|
+
['msie', 'trident'],
|
580
|
+
['opera', 'presto']
|
581
|
+
], /(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/);
|
582
|
+
|
583
|
+
$.os = {
|
584
|
+
name: (/(win|mac|linux|sunos|solaris|iphone|ipad)/.
|
585
|
+
exec(navigator.platform.toLowerCase()) || [u])[0].replace('sunos', 'solaris')
|
586
|
+
};
|
587
|
+
|
588
|
+
if (!z) {
|
589
|
+
$('html').addClass([$.os.name, $.browser.name, $.browser.className,
|
590
|
+
$.layout.name, $.layout.className].join(' '));
|
591
|
+
}
|
592
|
+
};
|
593
|
+
|
594
|
+
$.browserTest(navigator.userAgent);
|
595
|
+
}(jQuery));
|
@@ -0,0 +1,114 @@
|
|
1
|
+
/*!
|
2
|
+
* jReject (jQuery Browser Rejection Plugin)
|
3
|
+
* Version 1.1.x
|
4
|
+
* URL: http://jreject.turnwheel.com/
|
5
|
+
* Description: jReject is a easy method of rejecting specific browsers on your site
|
6
|
+
* Author: Steven Bower (TurnWheel Designs) http://turnwheel.com/
|
7
|
+
* Copyright: Copyright (c) 2009-2014 Steven Bower under dual MIT/GPL license.
|
8
|
+
*/
|
9
|
+
|
10
|
+
#jr_overlay {
|
11
|
+
top: 0;
|
12
|
+
left: 0;
|
13
|
+
padding: 0;
|
14
|
+
margin: 0;
|
15
|
+
z-index: 2147483646;
|
16
|
+
position: absolute;
|
17
|
+
}
|
18
|
+
|
19
|
+
#jr_wrap {
|
20
|
+
position: absolute;
|
21
|
+
width: 100%;
|
22
|
+
z-index: 2147483647;
|
23
|
+
padding: 0;
|
24
|
+
margin: 0;
|
25
|
+
}
|
26
|
+
|
27
|
+
#jr_inner {
|
28
|
+
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Verdana, sans-serif;
|
29
|
+
font-size: 12px;
|
30
|
+
background: #FFF;
|
31
|
+
border: 1px solid #CCC;
|
32
|
+
color: #4F4F4F;
|
33
|
+
margin: 0 auto;
|
34
|
+
height: auto;
|
35
|
+
padding: 20px;
|
36
|
+
position: relative;
|
37
|
+
box-sizing: content-box;
|
38
|
+
}
|
39
|
+
|
40
|
+
#jr_header {
|
41
|
+
display: block;
|
42
|
+
color: #333;
|
43
|
+
padding: 5px;
|
44
|
+
padding-bottom: 0;
|
45
|
+
margin: 0;
|
46
|
+
font-family: Helvetica, Arial, sans-serif;
|
47
|
+
font-weight: bold;
|
48
|
+
font-size: 1.3em;
|
49
|
+
margin-bottom: 0.5em;
|
50
|
+
}
|
51
|
+
|
52
|
+
#jr_inner p {
|
53
|
+
padding: 5px;
|
54
|
+
margin: 0;
|
55
|
+
}
|
56
|
+
|
57
|
+
#jr_inner ul {
|
58
|
+
list-style-image: none;
|
59
|
+
list-style-position: outside;
|
60
|
+
list-style-type: none;
|
61
|
+
margin: 0;
|
62
|
+
padding: 0;
|
63
|
+
}
|
64
|
+
|
65
|
+
#jr_inner ul li {
|
66
|
+
cursor: pointer;
|
67
|
+
float: left;
|
68
|
+
width: 120px;
|
69
|
+
height: 122px;
|
70
|
+
margin: 0 10px 10px 10px;
|
71
|
+
padding: 0;
|
72
|
+
text-align: center;
|
73
|
+
}
|
74
|
+
|
75
|
+
#jr_inner li a {
|
76
|
+
color: #333;
|
77
|
+
font-size: 0.8em;
|
78
|
+
text-decoration: none;
|
79
|
+
padding: 0;
|
80
|
+
margin: 0;
|
81
|
+
}
|
82
|
+
|
83
|
+
#jr_inner li a:hover {
|
84
|
+
text-decoration: underline;
|
85
|
+
}
|
86
|
+
|
87
|
+
#jr_inner .jr_icon {
|
88
|
+
width: 100px;
|
89
|
+
height: 100px;
|
90
|
+
margin: 1px auto;
|
91
|
+
padding: 0;
|
92
|
+
background: transparent no-repeat scroll left top;
|
93
|
+
cursor: pointer;
|
94
|
+
}
|
95
|
+
|
96
|
+
#jr_close {
|
97
|
+
clear: both;
|
98
|
+
padding: 0;
|
99
|
+
margin: 0;
|
100
|
+
}
|
101
|
+
|
102
|
+
#jr_close a {
|
103
|
+
color: #000;
|
104
|
+
display: block;
|
105
|
+
width: auto;
|
106
|
+
margin: 0;
|
107
|
+
padding: 0;
|
108
|
+
text-decoration: underline;
|
109
|
+
}
|
110
|
+
|
111
|
+
#jr_close p {
|
112
|
+
padding: 10px 0 0 0;
|
113
|
+
margin: 0;
|
114
|
+
}
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jreject-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rustam Sharshenov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.1.0
|
27
|
+
description: This gem provides JReject for your Rails application.
|
28
|
+
email:
|
29
|
+
- rustam@sharshenov.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- Gemfile
|
36
|
+
- LICENSE.txt
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- jreject-rails.gemspec
|
40
|
+
- lib/jreject-rails.rb
|
41
|
+
- lib/jreject-rails/engine.rb
|
42
|
+
- lib/jreject-rails/version.rb
|
43
|
+
- vendor/assets/images/jreject/background_browser.gif
|
44
|
+
- vendor/assets/images/jreject/browser_chrome.gif
|
45
|
+
- vendor/assets/images/jreject/browser_firefox.gif
|
46
|
+
- vendor/assets/images/jreject/browser_konqueror.gif
|
47
|
+
- vendor/assets/images/jreject/browser_msie.gif
|
48
|
+
- vendor/assets/images/jreject/browser_opera.gif
|
49
|
+
- vendor/assets/images/jreject/browser_safari.gif
|
50
|
+
- vendor/assets/javascripts/jquery.reject.js.erb
|
51
|
+
- vendor/assets/stylesheets/jquery.reject.css
|
52
|
+
homepage: https://github.com/sharshenov/jreject-rails
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 2.2.2
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: Use JReject with Rails
|
76
|
+
test_files: []
|