Module: CommonInterface::ViewHelper

Defined in:
lib/common_interface/view_helper.rb

Instance Method Summary collapse

Instance Method Details

#build_files_uploader_for(params, opt) ⇒ Object

Folder

params =

:l => I18n.locale,

opt =

:upload_url => item_files_path(folder),
:view => 'folder_thumb',
:select_files => t(:select_files),



41
42
43
44
45
46
47
48
49
50
# File 'lib/common_interface/view_helper.rb', line 41

def build_files_uploader_for params, opt
  raise 'update me with crystal.config'
  session_key = ActionController::Base.session_options[:key]
  
  params = {
    session_key => cookies[session_key]
  }.merge(params)
  
  "new FilesUpload(#{params.to_json}, #{opt.to_json});"    
end

#cancel_button(text = t(:cancel)) ⇒ Object



10
11
12
# File 'lib/common_interface/view_helper.rb', line 10

def cancel_button text = t(:cancel)
  link_to text, :back, {}, :class => '_redirect_back_or_close_dialog'
end

#ok_button(text = t(:ok)) ⇒ Object

Form Buttons



6
7
8
# File 'lib/common_interface/view_helper.rb', line 6

def ok_button text = t(:ok)
  submit_tag text, :class => '_submit_form_or_ajax_form'
end

#tag_cloud(tags, classes, &block) ⇒ Object

Custom



17
18
19
20
21
22
23
24
25
26
# File 'lib/common_interface/view_helper.rb', line 17

def tag_cloud tags, classes, &block
  return if tags.empty?

  max_count = tags.sort{|a, b| a.count <=> b.count}.last.count.to_f

  tags.sort{|a, b| a.name <=> b.name}.each do |tag|
    index = ((tag.count / max_count) * (classes.size - 1)).round
    block.call tag, classes[index]
  end
end