Module: Gluttonberg::Admin::Assets
- Included in:
- Gluttonberg::Admin
- Defined in:
- app/helpers/gluttonberg/admin/assets.rb
Instance Method Summary collapse
- #_asset_browser_tag(field_name, opts = {}) ⇒ Object
-
#asset_browser_tag(field_name, opts = {}) ⇒ Object
Generates a link which launches the asset browser.
- #asset_panel(assets, name_or_id, type) ⇒ Object
-
#backend_logo(default_logo_image_path, html_opts = {}, thumbnail_type = :backend_logo) ⇒ Object
Button to select Backend logo on settings page.
-
#clear_asset_tag(field_id, opts = {}) ⇒ Object
Generates a link which clears asset browser input.
Instance Method Details
#_asset_browser_tag(field_name, opts = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/helpers/gluttonberg/admin/assets.rb', line 23 def _asset_browser_tag( field_name , opts = {} ) asset_id = opts[:asset_id] opts[:filter] = opts[:filter] || "all" asset = if asset_id.blank? nil else Gluttonberg::Asset.where(:id => asset_id).first end opts[:id] = "#{field_name}_#{asset_id}" if opts[:id].blank? render :partial => "/gluttonberg/admin/asset_library/shared/asset_browser", :locals => { :opts => opts, :asset => asset, :field_name => field_name } end |
#asset_browser_tag(field_name, opts = {}) ⇒ Object
Generates a link which launches the asset browser
For Finding image assets
asset_browser_tag( field_name , opts = { :id => "" , :asset_id => "" , :filter => "" , :id => "html_id", :data_url => "", :button_class => "" } )
19 20 21 |
# File 'app/helpers/gluttonberg/admin/assets.rb', line 19 def asset_browser_tag( field_name , opts = {} ) _asset_browser_tag( field_name , opts ) end |
#asset_panel(assets, name_or_id, type) ⇒ Object
64 65 66 |
# File 'app/helpers/gluttonberg/admin/assets.rb', line 64 def asset_panel(assets, name_or_id , type ) render :partial => "/gluttonberg/admin/shared/asset_panel" , :locals => {:assets => assets , :name_or_id => name_or_id , :type => type} , :formats => [:html] end |
#backend_logo(default_logo_image_path, html_opts = {}, thumbnail_type = :backend_logo) ⇒ Object
Button to select Backend logo on settings page
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/helpers/gluttonberg/admin/assets.rb', line 69 def backend_logo(default_logo_image_path , html_opts={}, thumbnail_type = :backend_logo) backend_logo = Gluttonberg::Setting.get_setting("backend_logo") if !backend_logo.blank? && backend_logo.to_i > 0 asset = Asset.where(:id => backend_logo).first unless asset.blank? path = thumbnail_type.blank? ? asset.url : asset.url_for(thumbnail_type) content_tag(:img , "" , html_opts.merge( :alt => asset.name , :src => path ) ) else image_tag(default_logo_image_path) end end end |
#clear_asset_tag(field_id, opts = {}) ⇒ Object
Generates a link which clears asset browser input
For clearing image asset
clear_asset_tag( field_name , opts = { :id => "", :asset_id => "", :id => "html_id", :data_url => "", :button_class => "" } )
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/helpers/gluttonberg/admin/assets.rb', line 51 def clear_asset_tag( field_id , opts = {} ) asset_id = opts[:asset_id] if opts[:id].blank? rel = field_id.to_s + "_" + id.to_s opts[:id] = rel end html_id = opts[:id] link_to("Remove", "Javascript:;" , { :class => "btn btn-danger button remove #{opts[:button_class]}", :data_url => opts[:data_url] }) end |