Module: Admin::AttachmentHelper

Defined in:
app/helpers/admin/attachment_helper.rb

Instance Method Summary collapse

Instance Method Details

#display_visual(object_name, picture, name = 'picture') ⇒ Object

Display object visual ####



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/admin/attachment_helper.rb', line 4

def display_visual(object_name, picture, name = 'picture')
   :div, :class => 'fieldset open' do
    link_to(t(:name, :scope => [object_name, name]), '#', :class => 'small-icons panel') +
    (:div, :class =>'option-panel-content') do
      label = (picture.nil? ? t(:add, :scope => [object_name,name]) : t(:change, :scope => [object_name, name])).capitalize
      picture.nil? ? picture_id = '' : picture_id = picture.id
      hidden_field_tag("#{object_name}[#{name}_id]", picture_id, :id => name) +
      link_to((:span, label,:class => 'big-icons add-picture'),
              '#', :class => "add-#{name}picture backgrounds button right") +
      (:div, :class => 'grid_9', :id => "#{name}-picture") do
        (:ul, :class => 'sortable') do
          unless picture.nil?
            (:li) do
              image_tag(picture.public_filename(:normal)) +
              link_to_function('', "$(this).parents('li').remove(); $('##{name}').val('null');", :title => t('media.picture.destroy.confirm').capitalize, :class => 'big-icons delete')
            end
          end
        end
      end
    end +
    (:div,'', :class => 'clear')
  end
end

#display_visuals(object_name, pictures) ⇒ Object

Display object visuals ####



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/helpers/admin/attachment_helper.rb', line 29

def display_visuals(object_name, pictures)
   :div, :class => 'fieldset open' do
    link_to(t("#{object_name}.visuals.name"), '#', :class => 'small-icons panel') +
    (:div, :class =>'option-panel-content') do
      link_to((:span, t("add_picture").capitalize,
                            :class => 'big-icons add-picture'),
                '#', :class => 'add-visualpictures backgrounds button right') +
      (:div, :class => 'grid_9', :id => 'visuals-picture') do
        (:ul, :class => 'sortable') do
          pictures.collect{ |picture|
            (:li) do
              link_to_function('', "$(this).parents('li').remove();", :title => t('media.picture.destroy.confirm').capitalize, :class => 'big-icons delete') +
              hidden_field_tag("#{object_name}[attachment_ids][]", picture.id, :id => "attachment_#{picture.id}") +
              image_tag(picture.public_filename(:thumb)) +
              (:div, :class => 'handler') do
                (:div,'',:class => 'inner')
              end
            end
          }.join +
          (:li,'', :class => 'clear')
        end
      end
    end +
    (:div,'', :class => 'clear')
  end
end