Module: IE6Fixer::Helpers
- Defined in:
- lib/ie6_fixer/helpers.rb
Constant Summary collapse
- FIXED =
See the README.txt for an explanation for all helpers.
"ie6_fixer/fixed.js"
- FIXED_ACTIVE =
"ie6_fixer/fixed_active.js"
- FIXED_BACKGROUND =
"body {background:url(/javascripts/ie6_fixer/foo) fixed;}\n"
- WARNING =
"ie6_fixer/warning/warning.js"
Instance Method Summary collapse
-
#css3_fix(*args) ⇒ Object
> Fixes some of the CSS3 functions with PIE.htc.
-
#fixed_fix(*args) ⇒ Object
> Allows you to easily use ‘position:fixed’.
-
#fixed_fix_active ⇒ Object
> Another ‘position:fixed’ fix.
-
#ie6_fixer(&block) ⇒ Object
USE: <% ie_fixer do %> Only IE6, IE7 and IE8 see this! <% end %>.
-
#ie_fixer(*args, &block) ⇒ Object
> A block that is only visible to IE6, IE7 and IE8.
-
#kill_ie6 ⇒ Object
> A helper that’s just for fun: sets ‘display: none’ on the body tag.
-
#max_fix(*args) ⇒ Object
> Allows you to easily use max-width and max-height.
-
#min_fix(*args) ⇒ Object
> Allows you to easily use min-width and min-height.
-
#png_fix(*args) ⇒ Object
> Fixes transparent PNG’s with CSS3 PIE.
-
#warn_ie6(*args) ⇒ Object
> A helper that shows the user a notification that he/she is using an outdated browser.
Instance Method Details
#css3_fix(*args) ⇒ Object
> Fixes some of the CSS3 functions with PIE.htc.
46 47 48 49 50 51 |
# File 'lib/ie6_fixer/helpers.rb', line 46 def css3_fix *args # => Fixes some of the CSS3 functions with PIE.htc. args.each do |arg| @styles.push("#{arg} {behavior: url(/javascripts/ie6_fixer/PIE.htc);}\n") end nil end |
#fixed_fix(*args) ⇒ Object
> Allows you to easily use ‘position:fixed’. Won’t work in combination with css3_fix!
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ie6_fixer/helpers.rb', line 58 def fixed_fix *args # => Allows you to easily use 'position:fixed'. Won't work in combination with css3_fix! = args. @script_sources.push(FIXED) unless @script_sources.include?(FIXED) @styles.push(FIXED_BACKGROUND) unless @styles.include?(FIXED_BACKGROUND) .each_key do |key| top = "" left = "" top = "top:expression(fixedIE('Top',#{options[key][:top]},this));" if [key][:top].present? top = "top:expression(fixedIE('Bottom',#{options[key][:bottom]},this));" if [key][:bottom].present? left = "left:expression(fixedIE('Left',#{options[key][:left]},this));" if [key][:left].present? left = "left:expression(fixedIE('Right',#{options[key][:right]},this));" if [key][:right].present? @styles.push("#{key} {position:absolute; #{top} #{left} }\n") end nil end |
#fixed_fix_active ⇒ Object
> Another ‘position:fixed’ fix. Loads a Javascript file that runs the whole time.
79 80 81 82 |
# File 'lib/ie6_fixer/helpers.rb', line 79 def fixed_fix_active # => Another 'position:fixed' fix. Loads a Javascript file that runs the whole time. @script_sources.push(FIXED_ACTIVE) unless @script_sources.include?(FIXED_ACTIVE) nil end |
#ie6_fixer(&block) ⇒ Object
USE: <% ie_fixer do %>
Only IE6, IE7 and IE8 see this!
<% end %>
22 23 24 25 26 27 |
# File 'lib/ie6_fixer/helpers.rb', line 22 def ie6_fixer &block # => A block that is only visibly to IE6. if request.user_agent[/msie\s+6\.\d+/i].present? set_fixes(&block) end nil end |
#ie_fixer(*args, &block) ⇒ Object
> A block that is only visible to IE6, IE7 and IE8.
10 11 12 13 14 15 16 |
# File 'lib/ie6_fixer/helpers.rb', line 10 def ie_fixer *args, &block # => A block that is only visible to IE6, IE7 and IE8. versions = "6-8" || args.map { |arg| arg.to_s.gsub("ie", "") } if request.user_agent[/msie\s+[#{versions}]\.\d+/i].present? set_fixes(&block) end nil end |
#kill_ie6 ⇒ Object
> A helper that’s just for fun: sets ‘display: none’ on the body tag. ;)
138 139 140 141 |
# File 'lib/ie6_fixer/helpers.rb', line 138 def kill_ie6 # => A helper that's just for fun: sets 'display: none' on the body tag. ;) @styles.push("body{display:none !important;}\n") nil end |
#max_fix(*args) ⇒ Object
> Allows you to easily use max-width and max-height.
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/ie6_fixer/helpers.rb', line 89 def max_fix *args # => Allows you to easily use max-width and max-height. = args. .each_key do |key| width = "" height = "" width = "width: expression(document.body.clientWidth > #{options[key][:width].to_i} ? '#{options[key][:width]}px' : 'auto');" if [key][:width].present? height = "height: expression(this.scrollHeight > #{options[key][:height].to_i} ? '#{options[key][:height]}px' : 'auto')" if [key][:height].present? @styles.push("#{key} {#{width}#{height}}\n") end nil end |
#min_fix(*args) ⇒ Object
> Allows you to easily use min-width and min-height.
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/ie6_fixer/helpers.rb', line 106 def min_fix *args # => Allows you to easily use min-width and min-height. = args. .each_key do |key| width = "" height = "" width = "width: auto !important; width: #{options[key][:width]}px;" if [key][:width].present? height = "height: auto !important; height: #{options[key][:height]}px;" if [key][:height].present? @styles.push("#{key} {#{width}#{height}}\n") end nil end |
#png_fix(*args) ⇒ Object
> Fixes transparent PNG’s with CSS3 PIE.
34 35 36 37 38 39 |
# File 'lib/ie6_fixer/helpers.rb', line 34 def png_fix *args # => Fixes transparent PNG's with CSS3 PIE. args.each do |arg| @styles.push("#{arg} {-pie-png-fix: true; behavior: url(/javascripts/ie6_fixer/PIE.htc);}") end nil end |
#warn_ie6(*args) ⇒ Object
> A helper that shows the user a notification that he/she is using an outdated browser.
123 124 125 126 127 128 129 130 131 |
# File 'lib/ie6_fixer/helpers.rb', line 123 def warn_ie6 *args # => A helper that shows the user a notification that he/she is using an outdated browser. = args. @script_sources.push(WARNING) unless @script_sources.include?(WARNING) .each_key do |key| @scripts.push("\t#{key} = '#{options[key]}';\n") end @scripts.push("\twarn_ie6('/javascripts/ie6_fixer/warning/');\n") nil end |