Sha256: bc3b444106fb2a120a964a54e00d6063839df5ce9e84a10181911bd959fc0cc7

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

module CommonInterfaceHelper
  # 
  # Form Buttons
  # 
  def ok_button text = t(:ok)
    submit_tag text, :class => '_submit_form_or_ajax_form'
  end

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

  # 
  # Custom
  # 
  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
  
  
  # 
  # Folder
  # 
  # params = {
  #   :l => I18n.locale,
  # }
  # 
  # opt = {
  #   :upload_url => item_files_path(folder),
  #   :view => 'folder_thumb',
  #   :select_files => t(:select_files),
  # }
  def build_files_uploader_for params, opt
    session_key = ActionController::Base.session_options[:key]
  
    params = {
      session_key => cookies[session_key]
    }.merge(params)
  
    "new FilesUpload(#{params.to_json}, #{opt.to_json});"    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
crystal-ext-0.0.3 lib/common_interface/lib/common_interface_helper.rb
crystal-ext-0.0.2 lib/common_interface/lib/common_interface_helper.rb
crystal-ext-0.0.1 lib/common_interface/lib/common_interface_helper.rb