Class: DcGalleryRenderer
- Inherits:
-
Object
- Object
- DcGalleryRenderer
- 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
-
#default ⇒ Object
Default DcGallery render method.
-
#initialize(parent, opts = {}) ⇒ DcGalleryRenderer
constructor
Object initialization.
-
#render_css ⇒ Object
Return CSS part of code.
-
#render_html ⇒ Object
Renderer dispatcher.
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_button, #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, #dc_steps_menu_get, #t, t, #t_label_for_column, #t_label_for_field, #t_tablename
Methods included from DcApplicationHelper
#_origin, #dc_add2_record_cookie, #dc_add_json_ld, #dc_add_meta_tag, #dc_big_table, #dc_big_table_name_for_value, #dc_choices4, #dc_choices4_all_collections, #dc_choices4_folders_list, #dc_choices4_menu, #dc_choices4_site_policies, #dc_cms_menu, #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_link_canonical_tag, #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_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
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
#default ⇒ Object
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 65 66 67 68 69 70 |
# 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>' if @opts[:edit_mode] > 1 html << (picture) html << %( <span class="dc-inline-link dc-link-ajax" data-url="/cmsedit/run?control=DcGalleryControl.picture_remove;id=#{picture.id};table=DcGallery" data-confirm="#{t('drgcms.confirm_delete')}" title="#{t('drgcms.delete')}"> <i class="mi-o mi-delete"></i> </span>) end html << "#{@parent.link_to(i@parent.mage_tag(picture.thumbnail, title: picture.title), picture.picture)}<li>" end html << '</ul></div>' end |
#render_css ⇒ Object
Return CSS part of code.
83 84 85 |
# File 'app/renderers/dc_gallery_renderer.rb', line 83 def render_css @css end |
#render_html ⇒ Object
Renderer dispatcher. Method returns HTML part of code.
75 76 77 78 |
# File 'app/renderers/dc_gallery_renderer.rb', line 75 def render_html method = @opts[:method] || 'default' respond_to?(method) ? send(method) : "Error DcPage: Method #{method} doesn't exist!" end |