Module: Platform::AssetTagHelper

Includes:
ActionView::Helpers::AssetTagHelper
Included in:
PlatformHelper
Defined in:
app/helpers/platform/asset_tag_helper.rb

Instance Method Summary collapse

Instance Method Details

#admin_image_tag(source, options = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/helpers/platform/asset_tag_helper.rb', line 31

def admin_image_tag(source, options = {})
  options.symbolize_keys!
  src = options[:src] = "/admin/images/#{source}"
  unless src =~ /^cid:/
    options[:alt] = options.fetch(:alt){ File.basename(src, '.*').capitalize }
  end
  if size = options.delete(:size)
    options[:width], options[:height] = size.split("x") if size =~ %r{^\d+x\d+$}
  end
  if mouseover = options.delete(:mouseover)
    options[:onmouseover] = "this.src='/admin/images/#{mouseover}'"
    options[:onmouseout]  = "this.src='#{src}'"
  end
  tag("img", options)
end

#compute_public_path_with_context(source, dir, ext = nil, include_host = true) ⇒ Object



47
48
49
50
# File 'app/helpers/platform/asset_tag_helper.rb', line 47

def compute_public_path_with_context(source, dir, ext = nil, include_host = true)
  r = compute_public_path_without_context(source, dir, ext, include_host)
  @active_context != :site ? "/#{@active_context}#{r}" : r
end

#javascript_include_tag_with_context(*sources) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/platform/asset_tag_helper.rb', line 18

def javascript_include_tag_with_context(*sources)
  options = sources.extract_options!.stringify_keys
  context = options.delete("context") || :site
  if context
    assets_with_context context do
      javascript_include_tag_without_context *(sources + [options])
    end
  else
    javascript_include_tag_without_context *(sources + [options])
  end
end


5
6
7
8
9
10
11
12
13
14
15
# File 'app/helpers/platform/asset_tag_helper.rb', line 5

def stylesheet_link_tag_with_context(*sources)
  options = sources.extract_options!.stringify_keys
  context = options.delete("context") || :site
  if context
    assets_with_context context do
      stylesheet_link_tag_without_context *(sources + [options])
    end
  else
    stylesheet_link_tag_without_context *(sources + [options])
  end
end