Browser War plugin
Plugin details
Documentation
Install the plugin:
ruby script/plugin install git://github.com/sagebit/browserwar_plugin.git
Usage
===========
start_browser_war() is the central mathod of the plugin, and it takes many parameters, but these are the defaults:
start_browser_war({:browsers => browserwar_browsers_default, :message => browserwar_message_default, :options => browserwar_options_default})
Breaking down these three parameters:
:browsers => hash
* Format:
{'name' => version, 'name' => version, 'name = version, ...}
* List of possible brosers to include in the hash:
["Chrome","OmniWeb","Safari","Opera","iCab","Konqueror","Firefox","Camino","Netscape","Explorer","Mozilla"]
* if version is not specified for a browser ('' or nil) BrowserWar will display the message for ALL versions of the browser
:message => Ruby string containing a javascript string
* Format:
"'It looks like you are using ' + browserwar.browser_display_name + ' ' + BrowserDetect.version + ' or older. To get the best experience from this site we suggest you upgrade your browser.'"
* if :message is not specified the default message will be used (see def browserwar_message_default in browser_war/lib/browser_war_helper.rb)
The default message tells people to upgrade their browser and has a link to http://browsehappy.com/browsers
:options => hash
* Default values:
{
:id => 'browser_warning',
:class => nil,
:closeable => true,
:background => '#fff',
:color => '#000',
:top => '90px',
:left => '0px',
:width => '200px',
:padding => '20px',
:border => '20px solid #fff',
:z_index => '200'
}
* Any of these values that are left unspecified will not be used, so tweak them however you need to.
Helpful bits:
----------------------
Some CSS to improve images and links in the browser_warning div (change if you do not use default :id in options hash)
#browser_warning a, #browser_warning a img { color: #000; border: 0px solid #fff; } #browser_warning a:hover { color: #68CCFF; }
Example
=======
In your layouts:
< head> ... < !-- DON'T FORGET THESE!!! (:defaults are NOT needed AT ALL for this plugin, and are only here because I said so)-- > <%= javascript_include_tag(:defaults, 'browserDetect', 'browserWar') %> ... < /head>
Anywhere in your layouts or templates... (can optionally go in the tag, but must come after the javascript_include_tag)
< !-- Then, to go with all the defaults -- >
<%= start_browser_war %>
< !-- which is equivalent to the following: -- >
<%= start_browser_war({:browsers => browserwar_browsers_default,
:message => browserwar_message_default,
:options => browserwar_options_default}) %>
< !-- which is equivalent to the following: -- >
<%= start_browser_war({:browsers => {'Explorer' => 6},
:message =>
"'This site is optimized for the {
:id => 'browser_warning',
:class => nil,
:closeable => true,
:background => '#fff',
:color => '#000',
:top => '90px',
:left => '0px',
:width => '200px',
:padding => '20px',
:border => '8px ridge #68CCFF',
:z_index => '200' }}) %>
< !-- To only fight specific browsers -- >
<%= start_browser_war(:browsers => {"Explorer" => 6, "Netscape" => 6} ) %>
< !-- To customize the message (:message value must be a javascript string inside a ruby string e.g. "'string
here'")-- >
<%= start_browser_war(:message => "'This website does not enjoy being viewed by your browser.'" ) %>
< !-- To customize the style -- >
<%= start_browser_war(:options => { :id => 'browser_foo',
:class => 'myclass',
:closeable => false, #for no close link
:background => '#fff',
:color => '#000',
:top => '150px',
:left => '100px',
:width => '300px',
:padding => '20px',
:border => '20px solid #fff',
:z_index => '200' }) %>
< !-- To use all the options -- >
< !-- As you can see in the example below you have access to some special browserwar fodder for your cannons: -- >
< !-- browserwar.browser_display_name + ' ' + BrowserDetect.version will display the browser and version accessing
your site! -- >
<%= start_browser_war(:browsers => {"Explorer" => 6, "Netscape" => 6, "Firefox" => 3},
:message => "'You are using ' + browserwar.browser_display_name + ' ' +
BrowserDetect.version + ', which means that my website is better than your browser!'",
:options => { :id => 'go_ahead_inslut_me',
:class => 'myclass',
:closeable => true, #for no close link
:background => '#ccc',
:color => '#333555',
:top => '150px',
:left => '100px',
:width => '300px',
:padding => '20px',
:border => '10px ridge #9c9c9c',
:z_index => '200' }) %>
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | Back in time (1 older version) | Last edited by: hardway, about 1 year ago


