Module: Zena::Use::Upload::ViewMethods

Includes:
RubyLess
Defined in:
lib/zena/use/upload.rb

Overview

ControllerMethods

Instance Method Summary collapse

Instance Method Details

#upload_field(opts = {}) ⇒ Object



210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/zena/use/upload.rb', line 210

def upload_field(opts = {})
  uuid = opts[:uuid] || @uuid
  dom  = opts[:dom]  || 'node'
  case opts[:type].to_s
  when 'onclick'
    link = link_to_remote(_("change"), :update=>'upload_field', :url => get_uf_documents_path(:uuid => @uuid), :method => :get, :complete=>"['file', 'upload_field'].each(Element.toggle);")
    <<-TXT
<label for='attachment'>#{_('file')}</label>
<div id="file" class='toggle_div'>#{link}</div>
<div id="upload_field" class='toggle_div' style='display:none;'></div>
TXT
  else
    attach_file_id, attach_url_id = "af#{uuid}", "au#{uuid}"
    onchange = %Q{onchange="Zena.get_filename(this,'#{dom}_title'); $('#{dom}_title').focus(); $('#{dom}_title').select();"}
    <<-TXT
<div id='#{attach_file_id}' class='attach'><label for='attachment' onclick=\"['#{attach_file_id}', '#{attach_url_id}'].each(Element.toggle);\">#{_('file')} / <span class='off'>#{_('url')}</span></label>
<input  style='line-height:1.5em;' id="attachment#{uuid}" name="attachment" #{onchange} class='file' type='file'/></div>

<div id='#{attach_url_id}' class='attach' style='display:none;'><label for='url' onclick=\"['#{attach_file_id}', '#{attach_url_id}'].each(Element.toggle);\"><span class='off'>#{_('file')}</span> / #{_('url')}</label>
<input  style='line-height:1.5em;' size='30' id='attachment_url' type='text' #{onchange} name='attachment_url'/><br/></div>
TXT
  end
end

#upload_form_tag(url_opts, html_opts = {}) ⇒ Object



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/zena/use/upload.rb', line 194

def upload_form_tag(url_opts, html_opts = {})
  @uuid = UUIDTools::UUID.random_create.to_s.gsub('-','')
  html_opts.reverse_merge!(:multipart => true, :id => "UploadForm#{@uuid}")
  if html_opts[:multipart]
    html_opts[:onsubmit] = "submitUploadForm('#{html_opts[:id]}', '#{@uuid}');"
    url_opts[UPLOAD_KEY] = @uuid
  end
  if block_given?
    form_tag( url_opts, html_opts ) do |f|
      yield(f)
    end
  else
    form_tag( url_opts, html_opts )
  end
end