Module: AttachmentMagick::AttachmentMagickHelper
- Defined in:
- app/helpers/attachment_magick/attachment_magick_helper.rb
Instance Method Summary collapse
-
#attachment_for_flash(url, width = 100, height = 60) ⇒ Object
FIXME - verify this html.
- #attachment_for_video(object) ⇒ Object
- #attachment_for_view(object, partial = nil, collection = nil, use_sortable = true) ⇒ Object
- #attachment_progress_container(object, data_type = "images") ⇒ Object
- #resize_video(html, x) ⇒ Object
Instance Method Details
#attachment_for_flash(url, width = 100, height = 60) ⇒ Object
FIXME - verify this html
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'app/helpers/attachment_magick/attachment_magick_helper.rb', line 59 def (url, width=100, height=60) "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='#{width}' height='#{height}' id='#{url}' align='middle'> <param name='movie' value='#{url}' /> <param name='quality' value='high' /> <param name='bgcolor' value='#FFF' /> <param name='play' value='true' /> <param name='loop' value='true' /> <param name='wmode' value='window' /> <param name='scale' value='showall' /> <param name='menu' value='true' /> <param name='devicefont' value='false' /> <param name='salign' value='' /> <param name='allowScriptAccess' value='sameDomain' /> <!--[if !IE]>--> <object type='application/x-shockwave-flash' data='#{url}' width='#{width}' height='#{height}'> <param name='movie' value='#{url}' /> <param name='quality' value='high' /> <param name='bgcolor' value='#FFF' /> <param name='play' value='true' /> <param name='loop' value='true' /> <param name='wmode' value='window' /> <param name='scale' value='showall' /> <param name='menu' value='true' /> <param name='devicefont' value='false' /> <param name='salign' value='' /> <param name='allowScriptAccess' value='sameDomain' /> <!--<![endif]--> <a href='http://www.adobe.com/go/getflash'> <img src='http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /> </a> <!--[if !IE]>--> </object> <!--<![endif]--> </object>".html_safe end |
#attachment_for_video(object) ⇒ Object
54 55 56 |
# File 'app/helpers/attachment_magick/attachment_magick_helper.rb', line 54 def (object) %{<label>vídeo</label><ol class='form-block'>#{render :partial => "/attachment_magick/video_upload"}</ol>}.html_safe unless object.new_record? end |
#attachment_for_view(object, partial = nil, collection = nil, use_sortable = true) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/helpers/attachment_magick/attachment_magick_helper.rb', line 30 def (object, partial = nil, collection=nil, use_sortable=true) unless object.new_record? unless collection.present? if AttachmentMagick.configuration.orms.include?("Mongoid") if object.class.include?(Mongoid::Document) collection = object.images.order_by(:priority.asc) end end if AttachmentMagick.configuration.orms.include?("ActiveRecord") if object.class.include?(ActiveRecord::Persistence) collection = object.images.order(:priority) end end end key = "#{object.class.to_s.underscore}_#{object.id}" html_partial = "<input id='attachmentmagick_partial' data-partial='#{partial}' type='hidden' value='#{key}'>" if partial html = render(:partial => partial || AttachmentMagick.configuration.default_add_partial, :collection => collection, :as =>:image) "#{html_partial}<div id='#{key}' class='#{'attachmentSortable' if use_sortable}'>#{html}</div><div></div>".html_safe end end |
#attachment_progress_container(object, data_type = "images") ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/helpers/attachment_magick/attachment_magick_helper.rb', line 4 def (object, data_type="images") unless object.new_record? obj = object key = "#{object.class.to_s.underscore}_#{object.id}" if obj.respond_to?(:embedded?) if obj. = obj.relations.values.select { |x| x.macro == :embedded_in}.first parent = .class_name parent_id = obj._parent.id.to_s inverse_of = .inverse_of text_eval = "#{parent}_#{parent_id}_#{inverse_of}_#{obj.id.to_s}" end end = text_eval.blank? ? "#{object.class}_#{object.id}" : text_eval html = %{<div id='attachmentProgressContainer'></div> <span id='attachmentButton'></span> <input id='attachmentmagick_key' data_attachment='#{}' data_type='#{data_type}' type='hidden' value='#{key}'> } html.html_safe end end |
#resize_video(html, x) ⇒ Object
95 96 97 98 |
# File 'app/helpers/attachment_magick/attachment_magick_helper.rb', line 95 def resize_video(html, x) y = x.to_i * 2 / 3 html.gsub(/width=\"([0-9]+)\"/, "width='#{x}'").gsub(/height=\"([0-9]+)\"/, "height='#{y}'").html_safe end |