Class: DcCommonRenderer
- Inherits:
-
DcRenderer
- Object
- DcRenderer
- DcCommonRenderer
- Includes:
- DcApplicationHelper
- Defined in:
- app/helpers/dc_common_renderer.rb
Overview
Renderer methods which may be useful on any site.
Instance Attribute Summary
Attributes included from DcApplicationHelper
#design, #form, #ids, #options, #page, #page_title, #part, #parts, #site, #tables
Instance Method Summary collapse
-
#_remove_iframe_edit ⇒ Object
Will return html code required for open edit form in iframe.
-
#google_analytics ⇒ Object
Renderer for Google analytics code.
-
#layout_4print ⇒ Object
Renderer for printer friendly layout.
-
#render_html ⇒ Object
Return HTML part of code.
Methods included from DcApplicationHelper
#_origin, #dc_add2_record_cookie, #dc_big_table, #dc_choices4, #dc_choices4_all_collections, #dc_choices4_cmsmenu, #dc_choices4_folders_list, #dc_choices4_menu, #dc_choices4_site_policies, #dc_date_time, #dc_deprecate, #dc_dont?, #dc_edit_mode?, #dc_edit_title, #dc_error_messages_for, #dc_flash_messages, #dc_format_date_time, #dc_get_site, #dc_icon4_boolean, #dc_iframe_edit, #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_name4_id, #dc_name4_value, #dc_new_title, #dc_page_class, #dc_page_edit_menu, #dc_render, #dc_render_design, #dc_replace_in_design, #dc_submit_tag, #dc_table_title, #dc_user_can_view, #dc_user_has_role, #decamelize_type, #forms_merge, #t, #t_name, #t_tablename
Methods inherited from DcRenderer
Constructor Details
This class inherits a constructor from DcRenderer
Instance Method Details
#_remove_iframe_edit ⇒ Object
Will return html code required for open edit form in iframe. If parameters are found in url iframe will be initial loaded with url parameters thus enabling forms load on page display.
97 98 99 |
# File 'app/helpers/dc_common_renderer.rb', line 97 def _remove_iframe_edit() @parent.render(partial: 'dc_common/iframe_edit', formats: [:html]) end |
#google_analytics ⇒ Object
Renderer for Google analytics code.
Parameters: Are passed through @opts hash and can therefore be set on site
or page document parameters field as ga_acc key. You may also disable sending
If eu_cookies_allowed function is defined in javascript libraries it will be called and if false is returned GA code will not be executed. This is in order with European cookie law.
Example:
dc_render(:dc_common_renderer, method: 'google_analytics', code: 'UA-12345678-9')
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/helpers/dc_common_renderer.rb', line 69 def google_analytics ga_acc = @opts[:code] || @opts[:ga_acc] return '' if ga_acc.nil? or ga_acc == '/' html =" <!-- Google analytics. -->\n<script type=\"text/javascript\">\n (function(i,s,o,g,r,a,m){\n if (typeof(eu_cookies_allowed) === \"function\" && !eu_cookies_allowed() ) return;\n\n i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n })(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\n if (typeof(ga) === \"function\") {\n ga('create', '\#{ga_acc}', 'auto');\n ga('send', 'pageview')\n }\n</script>\n" html.html_safe end |
#layout_4print ⇒ Object
Renderer for printer friendly layout. Will call another renderer which should provide html code for printer friendly output.
Parameters are passed through link. There are currently two parameters, which define renderer and method to be used for creating output.
- renderer
-
Defines renderer’s class
- method
-
Defines renderer’s class method
43 44 45 46 47 48 49 50 51 52 |
# File 'app/helpers/dc_common_renderer.rb', line 43 def layout_4print opts = @opts.dup opts[:method] = @parent.params[:method] klass = (@parent.params[:renderer] + '_renderer').classify obj = Kernel.const_get(klass, Class.new).new(@parent, opts) # html = obj.render_html @css << obj.render_css.to_s html end |
#render_html ⇒ Object
Return HTML part of code.
104 105 106 107 |
# File 'app/helpers/dc_common_renderer.rb', line 104 def render_html method = @opts[:method] || 'default' respond_to?(method) ? send(method) : "Error DcCommonRenderer: Method #{method} doesn't exist!" end |