Class: DcGalleryRenderer

Inherits:
Object
  • Object
show all
Includes:
CmsCommonHelper, DcApplicationHelper
Defined in:
app/renderers/dc_gallery_renderer.rb

Overview

DcGalleryRenderer renders data for displaying picture galary under the document.

Example:

<div id="page">
  <%= dc_render(:dc_gallery) if document.gallery %>
</div>

Instance Attribute Summary

Attributes included from DcApplicationHelper

#design, #form, #ids, #json_ld, #menu, #menu_item, #options, #page, #page_title, #part, #parts, #record, #record_footer, #site, #tables

Instance Method Summary collapse

Methods included from CmsCommonHelper

#dc_choices4_field, dc_choices_for_field, #dc_choices_for_field, #dc_date_time, dc_format_date_time, #dc_format_date_time, dc_format_number, #dc_format_number, #dc_help_body, #dc_help_fields, #dc_help_for_tab, #dc_icon4_boolean, #dc_icon_for_boolean, #dc_name4_id, #dc_name4_value, #dc_name_for_id, #dc_name_for_value, dc_name_for_value, #t, t, #t_name, #t_tablename

Methods included from DcApplicationHelper

#_origin, #dc_add2_record_cookie, #dc_add_json_ld, #dc_add_meta_tag, #dc_big_table, #dc_choices4, #dc_choices4_all_collections, #dc_choices4_cmsmenu, #dc_choices4_folders_list, #dc_choices4_menu, #dc_choices4_site_policies, #dc_deprecate, #dc_document_path, #dc_dont?, #dc_edit_mode?, #dc_edit_title, #dc_error_messages_for, #dc_flash_messages, #dc_get_json_ld, #dc_get_seo_meta_tags, #dc_get_site, #dc_icon_for_link, #dc_iframe_edit, #dc_img_alt, #dc_img_alt_tag, #dc_internal_var, #dc_label_for, #dc_limit_string, #dc_link_for_create, #dc_link_for_edit, #dc_link_for_edit1, #dc_link_menu_tag, #dc_link_to, #dc_menu_class, #dc_new_title, #dc_page_bottom, #dc_page_class, #dc_page_edit_menu, #dc_page_top, #dc_render, #dc_render_design, #dc_render_design_part, #dc_render_from_site, #dc_render_partial, #dc_replace_in_design, #dc_submit_tag, #dc_table_title, #dc_user_can_view, #dc_user_has_role, #dc_warning_messages_for, #decamelize_type, #forms_merge

Constructor Details

#initialize(parent, opts = {}) ⇒ DcGalleryRenderer

Object initialization.



41
42
43
44
45
46
# File 'app/renderers/dc_gallery_renderer.rb', line 41

def initialize( parent, opts={} ) #:nodoc:
  @parent = parent
  @opts   = opts
  @page   = @parent.page
  @css    = ''
end

Instance Method Details

#defaultObject

Default DcGallery render method. It will simply put thumbnail pictures side by side and open big picture when clicked on thumbnail.



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/renderers/dc_gallery_renderer.rb', line 52

def default
  can_view, msg = dc_user_can_view(@parent, @page)
  return msg unless can_view
# 
  html = '<div class="picture-gallery"><ul>'
  DcGallery.where(doc_id: @opts[:doc_id], active: true).order_by(order: 1).each do |picture|
    html << '<li>'
    html << edit_menu(picture) if @opts[:edit_mode] > 1
    html << "#{@parent.link_to(i@parent.mage_tag(picture.thumbnail, title: picture.title), picture.picture)}<li>"
  end
# 
  html << '</ul></div>'
end

#render_cssObject

Return CSS part of code.



77
78
79
# File 'app/renderers/dc_gallery_renderer.rb', line 77

def render_css
  @css
end

#render_htmlObject

Renderer dispatcher. Method returns HTML part of code.



69
70
71
72
# File 'app/renderers/dc_gallery_renderer.rb', line 69

def render_html
  method = @opts[:method] || 'default'
  respond_to?(method) ? send(method) : "Error DcPage: Method #{method} doesn't exist!"
end