Module: FileShare::ApplicationHelper

Defined in:
app/helpers/file_share/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#file_share_asset_prefixObject



85
86
87
# File 'app/helpers/file_share/application_helper.rb', line 85

def file_share_asset_prefix
  'file_share/'
end

#file_share_javascript_includesObject



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'app/helpers/file_share/application_helper.rb', line 88

def file_share_javascript_includes
  list = [
    "#{file_share_asset_prefix}jquery-ui-1.7.2.custom.min.js",
    "#{file_share_asset_prefix}jquery.tablesorter.min.js",
    "#{file_share_asset_prefix}jquery.string.1.0-min.js",
    "#{file_share_asset_prefix}jquery.clonePosition.js",
    "#{file_share_asset_prefix}lowpro.jquery.js",
    "#{file_share_asset_prefix}jquery.qtip-1.0.0-rc3.js",
    "#{file_share_asset_prefix}rails",
    "#{file_share_asset_prefix}file_share_behaviors",
    "#{file_share_asset_prefix}file_share",
    "http://www.google.com/jsapi",
    "#{file_share_asset_prefix}plupload/gears_init",
    "#{file_share_asset_prefix}plupload/plupload.full.min.js",
    "#{file_share_asset_prefix}plupload/jquery.plupload.queue.min.js"
  ]
  unless Rails.env == 'production'
    list.unshift("#{file_share_asset_prefix}jquery")
  else
    list.unshift("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js")
  end
  list
end


61
62
63
64
65
66
67
68
# File 'app/helpers/file_share/application_helper.rb', line 61

def link_to_attachable(attachable, wrapper_options={}, link_options={})
  return unless has_authorization?(:read, attachable)
  link_wrapper(polymorphic_path(attachable), {
    :no_wrapper => true
  }.merge!(wrapper_options), {
    :link_text => attachable.name
  }.merge!(link_options))
end


70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'app/helpers/file_share/application_helper.rb', line 70

def link_to_attachable_or_file_attachments(attachable, wrapper_options={}, link_options={})
  unless attachable.blank?
    return link_to_attachable(attachable, {
      :no_wrapper => false
    }, {
      :link_text => '< back',
      :class => 'fake_button'
    })
  else
    return link_to_file_attachments({}, {
      :link_text => '< back',
      :class => 'fake_button'
    })
  end
end


40
41
42
43
44
45
46
47
48
49
50
# File 'app/helpers/file_share/application_helper.rb', line 40

def link_to_delete_file_attachment(file_attachment, wrapper_options={}, link_options={})
  return unless has_authorization?(:delete, file_attachment)
  link_wrapper(file_attachment_path(file_attachment), {
    :no_wrapper => true
  }.merge!(wrapper_options), {
    :link_text => 'delete',
    :method => :delete,
    :confirm => "Did you mean to Delete #{file_attachment.name}?",
    :class => 'fake_button'
  }.merge!(link_options))
end


52
53
54
55
56
57
58
59
# File 'app/helpers/file_share/application_helper.rb', line 52

def link_to_download_file_attachment(file_attachment, wrapper_options={}, link_options={})
  return unless has_authorization?(:read, file_attachment)
  link_wrapper(download_file_attachment_path(file_attachment), {
    :no_wrapper => true
  }.merge!(wrapper_options), {
    :link_text => file_attachment.name
  }.merge!(link_options))
end


30
31
32
33
34
35
36
37
38
# File 'app/helpers/file_share/application_helper.rb', line 30

def link_to_edit_file_attachment(file_attachment, wrapper_options={}, link_options={})
  return unless has_authorization?(:update, file_attachment)
  link_wrapper(edit_file_attachment_path(file_attachment), {
    :no_wrapper => true
  }.merge!(wrapper_options), {
    :link_text => 'update',
    :class => 'file_attachment_dynamic_form_link fake_button'
  }.merge!(link_options))
end


16
17
18
19
20
# File 'app/helpers/file_share/application_helper.rb', line 16

def link_to_file_attachments(wrapper_options={}, link_options={})
  link_wrapper(file_attachments_path, wrapper_options, {
    :link_text => 'List / Upload Files'
  }.merge!(link_options))
end


3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/helpers/file_share/application_helper.rb', line 3

def link_wrapper(path, wrapper_options={}, link_options={})
  tag       = wrapper_options.delete(:tag) || :p
  link_text = link_options.delete(:link_text) || path

  unless wrapper_options.delete(:no_wrapper)
    return (tag, wrapper_options) do
      link_to(link_text, path, link_options)
    end
  else
    return link_to(link_text, path, link_options)
  end
end


22
23
24
25
26
27
28
# File 'app/helpers/file_share/application_helper.rb', line 22

def links_to_edit_and_delete_file_attachment(file_attachment, wrapper_options={}, link_options={})
  return unless has_authorization?(:update, file_attachment) || has_authorization?(:delete, file_attachment)
   :p do
    link_to_edit_file_attachment(file_attachment) + " " +
    link_to_delete_file_attachment(file_attachment)
  end
end