bad_browser 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bad_browser.gemspec
4
+ gemspec
5
+
6
+ gem "jquery-rails"
7
+ gem "rspec"
8
+ gem "rspec-rails"
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Trey Dockendorf
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,45 @@
1
+ # BadBrowser
2
+
3
+ 'Unsupported browser' warning to IE users with [Chrome Frame](https://developers.google.com/chrome/chrome-frame/) install link.
4
+
5
+ ## Requirements
6
+
7
+ * Rails >= 3.1
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'bad_browser'
15
+ ```
16
+
17
+ After running `bundle` use the generator `bad_browser:install`. This will add the line `//= require bad_browser` to application.js.
18
+
19
+ ## Usage
20
+
21
+ Call `bad_browser_include_tag` in your application's main layout.
22
+
23
+ ```ruby
24
+ <%= bad_browser_include_tag :ie_supported => 9 %>
25
+ ```
26
+
27
+ This will include the necessary javascript to warn users of Internet Explorer older than the version specified. Default is IE9.
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
36
+
37
+ ## To-Do
38
+
39
+ * add option to pass ```:none``` in place of an IE version to display the warning to all IE users
40
+
41
+ ## Changelog
42
+
43
+ ### 0.0.1 - 2012/04/12
44
+
45
+ * initial release of gem
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ task default: :spec
@@ -0,0 +1,7 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require bad_browser
@@ -0,0 +1,43 @@
1
+ $(document).ready(function() {
2
+
3
+ $('#warningClose').click(function(e){
4
+ e.preventDefault();
5
+ $('#browserWarning').slideUp('slow');
6
+ return false;
7
+ });
8
+
9
+ $('#chromeFrameOpen').click(function(e) {
10
+ e.preventDefault();
11
+ openChromeFrame($(this).data('url'));
12
+ return false;
13
+ });
14
+ });
15
+
16
+ // Launch the Chrome Frame check
17
+ function openChromeFrame(url) {
18
+ CFInstall.check({
19
+ mode:'overlay',
20
+ destination: url
21
+ });
22
+ }
23
+
24
+ // Source derived from http://think2loud.com/147-build-an-unsupported-browser-warning-with-jquery/
25
+ function badBrowser(url){
26
+ var badBrowserMessage = "You are using an unsupported browser. Please install <a id='chromeFrameOpen' href='#'>Google Chrome Frame</a> or switch to <a href='http://getfirefox.com' target='_blank'>Firefox</a> or <a href='https://www.google.com/chrome' target='_blank'>Google Chrome</a>. Thanks! [<a id='warningClose' href='#'>close</a>]";
27
+
28
+ $(document.createElement('div')).attr('id', 'browserWarning')
29
+ .html(badBrowserMessage)
30
+ .data('url', url)
31
+ .css({
32
+ 'background-color': '#f9db17',
33
+ 'color': '#000000',
34
+ 'width': '100%',
35
+ 'border-top': 'solid 1px #000',
36
+ 'border-bottom': 'solid 1px #000',
37
+ 'text-align': 'center',
38
+ 'padding': '5px 0px 5px 0px'
39
+ })
40
+ .prependTo("body")
41
+ .hide();
42
+ $('#browserWarning').slideDown('slow');
43
+ }
@@ -0,0 +1,6 @@
1
+ <!-- Prompt users using IE older than <%= ie_supported %> to install Chrome Frame.
2
+ chromium.org/developers/how-tos/chrome-frame-getting-started -->
3
+ <!--[if lt IE <%= ie_supported %> ]>
4
+ <script defer src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
5
+ <script defer>badBrowser("<%= request.url %>");</script>
6
+ <![endif]-->
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/bad_browser/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Trey Dockendorf"]
6
+ gem.email = ["treydock@gmail.com"]
7
+ gem.description = %{'Unsupported browser' warning to IE users with Chrome Frame install link, for Rails (>= 3.1)}
8
+ gem.summary = %{'Unsupported browser' warning to IE users with Chrome Frame install link, for Rails (>= 3.1)}
9
+ gem.homepage = "https://github.com/treydock/bad_browser"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "bad_browser"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = BadBrowser::VERSION
17
+
18
+ gem.add_dependency "rails", "~> 3.1.0"
19
+ gem.add_dependency "activesupport", "~> 3.1.0"
20
+
21
+ end
@@ -0,0 +1,3 @@
1
+ module BadBrowser
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,10 @@
1
+ module BadBrowser
2
+ module ViewHelpers
3
+
4
+ def bad_browser_include_tag(options = {})
5
+ options[:ie_supported] ||= 9
6
+ render :partial => "bad_browser", :locals => { :ie_supported => options[:ie_supported] }
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ require "rails/engine"
2
+ require "bad_browser/version"
3
+ require "bad_browser/view_helpers"
4
+
5
+ module BadBrowser
6
+ class Engine < Rails::Engine
7
+ initializer "bad_browser.view_helpers" do
8
+ ActionView::Base.send :include, ViewHelpers
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ module BadBrowser
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ desc 'This generator adds bad_browser to the asset pipeline'
6
+
7
+ def inject_bad_browser_js
8
+ if File.exist?("app/assets/javascripts/application.js")
9
+ inject_into_file "app/assets/javascripts/application.js", :after => "//= require jquery_ujs\n" do
10
+ "//= require bad_browser\n"
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bad_browser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Trey Dockendorf
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-13 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &14478980 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *14478980
25
+ - !ruby/object:Gem::Dependency
26
+ name: activesupport
27
+ requirement: &14478480 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 3.1.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *14478480
36
+ description: ! '''Unsupported browser'' warning to IE users with Chrome Frame install
37
+ link, for Rails (>= 3.1)'
38
+ email:
39
+ - treydock@gmail.com
40
+ executables: []
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - .gitignore
45
+ - .rspec
46
+ - Gemfile
47
+ - LICENSE
48
+ - README.md
49
+ - Rakefile
50
+ - app/assets/javascripts/application.js
51
+ - app/assets/javascripts/bad_browser.js
52
+ - app/views/application/_bad_browser.html.erb
53
+ - bad_browser.gemspec
54
+ - lib/bad_browser.rb
55
+ - lib/bad_browser/version.rb
56
+ - lib/bad_browser/view_helpers.rb
57
+ - lib/generators/bad_browser/install/install_generator.rb
58
+ homepage: https://github.com/treydock/bad_browser
59
+ licenses: []
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 1.8.15
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: ! '''Unsupported browser'' warning to IE users with Chrome Frame install
82
+ link, for Rails (>= 3.1)'
83
+ test_files: []