Module: AttachedFilesListHelper::Render
- Defined in:
- app/helpers/attached_files_list_helper.rb
Class Attribute Summary collapse
-
.h ⇒ Object
Returns the value of attribute h.
-
.options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
- .build_preview_pic ⇒ Object
- .children ⇒ Object
- .controls ⇒ Object
- .current_host ⇒ Object
- .render_node(h, options) ⇒ Object
- .rotate_links ⇒ Object
- .show_link ⇒ Object
- .show_size ⇒ Object
- .url_input ⇒ Object
- .watermark_switch ⇒ Object
Class Attribute Details
.h ⇒ Object
Returns the value of attribute h.
14 15 16 |
# File 'app/helpers/attached_files_list_helper.rb', line 14 def h @h end |
.options ⇒ Object
Returns the value of attribute options.
14 15 16 |
# File 'app/helpers/attached_files_list_helper.rb', line 14 def @options end |
Class Method Details
.build_preview_pic ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/helpers/attached_files_list_helper.rb', line 73 def build_preview_pic if @node.is_image? src = @node.url(:preview) url = @node.url(:base) "<a href='#{url}'><img src='#{src}'></a>" else klass = @node.file_css_class url = @node.url "<a href='#{url}'><i class='#{klass}'></i></a>" end end |
.children ⇒ Object
107 108 109 110 111 |
# File 'app/helpers/attached_files_list_helper.rb', line 107 def children unless [:children].blank? "<ol class='nested_set'>#{ [:children] }</ol>" end end |
.controls ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'app/helpers/attached_files_list_helper.rb', line 94 def controls node = [:node] edit_path = h.url_for(:controller => [:klass].pluralize, :action => :edit, :id => node) show_path = h.url_for(:controller => [:klass].pluralize, :action => :show, :id => node) " <div class='controls'> #{ h.link_to '', show_path, :class => :delete, :method => :delete, :data => { :confirm => 'Are you sure?' } } </div> " end |
.current_host ⇒ Object
39 40 41 |
# File 'app/helpers/attached_files_list_helper.rb', line 39 def current_host h.request.protocol + h.request.host_with_port end |
.render_node(h, options) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/attached_files_list_helper.rb', line 16 def render_node(h, ) @h, @options = h, @node = [:node] " <li data-node-id='#{ @node.id }'> <div class='item'> <i class='handle'></i> #{ rotate_links } <div class='preview_pic'>#{build_preview_pic}</div> <div class='file_block'> #{ show_link } #{ url_input } #{ watermark_switch } #{ show_size } </div> #{ controls } </div> #{ children } </li> " end |
.rotate_links ⇒ Object
65 66 67 68 69 70 71 |
# File 'app/helpers/attached_files_list_helper.rb', line 65 def rotate_links if @node.is_image? left = h.link_to '', h.rotate_left_url(@node), method: :patch, class: :left right = h.link_to '', h.rotate_right_url(@node), method: :patch, class: :right "<div class='rotate'>#{left} #{right}</div>" end end |
.show_link ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'app/helpers/attached_files_list_helper.rb', line 85 def show_link node = [:node] ns = [:namespace] title_field = [:title] title = node.send(title_field) url = @node.is_image? ? @node.url(:base) : @node.url "<h4>#{ h.link_to(title, url)}</h4>" end |
.show_size ⇒ Object
49 50 51 |
# File 'app/helpers/attached_files_list_helper.rb', line 49 def show_size "<div class='fsize'>#{@node.mb_size}</div>" end |
.url_input ⇒ Object
43 44 45 46 47 |
# File 'app/helpers/attached_files_list_helper.rb', line 43 def url_input opts = {nocache: false, timestamp: false} url = @node.is_image? ? @node.url(:base, opts) : @node.url(:original, opts) "<div class='url_input'>URL: <input class='file_url' value='#{current_host + url}'></div>" end |
.watermark_switch ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/helpers/attached_files_list_helper.rb', line 53 def watermark_switch if @node.is_image? link = if @node.watermark "<span class='wm_on'>Вкл.</span>" else "<span class='wm_off'>Выкл.</span>" end "<div class='watermark_switcher'>Водный знак: #{link}</div>" end end |