browserwar_plugin
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:Rails plugin that enables you to tell surfers their browser is junk without any complex setup or pain.
Copyright (c) 2008 Peter Boling and Matt Long of Sagebit LLC, released under the MIT license

BrowserWar
==========

BrowserWar will help you to fight off evil browsers that access your website.
The cheiftan of the evil lot is of course Internet Explorer version 6, see http://iedeathmarch.org/
Though some would say "any" verison of IE is evil, and others would lump old versions of Netscape, and iCab and a littany of other browsers into the same group as well.

As a result we created this tool to display messages to any any version of any browser!

An example of one way to use BrowserWar is something you've probably seen before:

browserwar.message = "'

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.

'" (an example of the underlying javascript usage, not the rails plugin useage) This plugin takes all the javascript features and bundles them into a nice rails view helper called start_browser_war(). Does not rely on any external javascripts that are not included with the plugin. The plugin is packaged with two javascript files: browserDetect.js from http://www.quirksmode.org/js/detect.html browserWar.js from: http://github.com/sagebit/browserwar/tree/master by the same people who make this rails plugin version (Sagebit) Installation ============ script/plugin install git://github.com/sagebit/browser_war.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: ... <%= javascript_include_tag(:defaults, 'browserDetect', 'browserWar') %> ... Anywhere in your layouts or templates... (can optionally go in the tag, but must come after the javascript_include_tag) <%= start_browser_war %> <%= start_browser_war({:browsers => browserwar_browsers_default, :message => browserwar_message_default, :options => browserwar_options_default}) %> <%= start_browser_war({:browsers => {'Explorer' => 6}, :message => "'

This site is optimized for the Mozilla Firefox browser.

' + '

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.

' + '

Click the image below to learn more about alternative browser options.

' + '\"Browse'", :options => { :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' }}) %> <%= start_browser_war(:browsers => {"Explorer" => 6, "Netscape" => 6} ) %> <%= start_browser_war(:message => "'

This website does not enjoy being viewed by your browser.

'" ) %> <%= 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' }) %> <%= 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' }) %> Copyright (c) 2008 Peter Boling and Matt Long of Sagebit LLC, released under the MIT license

本源码包内暂不包含可直接显示的源代码文件,请下载源码包。