Module: Admin::BannersHelper
- Defined in:
- app/helpers/admin/banners_helper.rb
Instance Method Summary collapse
- #banner_edit_javascripts ⇒ Object
- #link_or_span_unless_current(params, text, url, options) ⇒ Object
- #pages_for_select ⇒ Object
- #updated_stamp(model) ⇒ Object
Instance Method Details
#banner_edit_javascripts ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/helpers/admin/banners_helper.rb', line 49 def <<-CODE var AddSelector = Behavior.create({ initialize: function(type){ this.template = $(type + '_select_template'); }, onclick: function(event) { event.stop(); var newField = new Element("p").update(this.template.innerHTML); this.element.up("div").insert(newField); } }); Event.addBehavior({ '#add-page-link': AddSelector('placement')}); CODE end |
#link_or_span_unless_current(params, text, url, options) ⇒ Object
3 4 5 6 7 8 9 |
# File 'app/helpers/admin/banners_helper.rb', line 3 def link_or_span_unless_current(params, text, url, ) if [:id] == params[[:param]] content_tag(:span, text) else link_to text, url, end end |
#pages_for_select ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/admin/banners_helper.rb', line 11 def pages_for_select @pages_for_select ||= begin collect_children = lambda do |page| if page. [page] + (page.children.any? ? page.children.map(&collect_children) : []) else (page.children.any? ? page.children.map(&collect_children) : []) end end collect_children[Page.find_by_parent_id(nil)].flatten.uniq.map do |page| ["#{page.path} - '#{page.title}'", page.id] end end end |
#updated_stamp(model) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/helpers/admin/banners_helper.rb', line 26 def updated_stamp(model) unless model.new_record? updated_by = (model.updated_by || model.created_by) if model.respond_to?(:updated_by) login = updated_by ? updated_by.login : nil time = (model.updated_at || model.created_at) # promoted_at = model.draft_promoted_at if model.respond_to?(:draft_promoted_at) html = %{<p style="clear: left"><small>} if login or time html << 'Last updated ' html << %{by #{login} } if login html << %{at #{ (time) }} if time html << '. ' end # if promoted_at # html << %{Last promoted at #{ timestamp(promoted_at) }.} # end html << %{</small></p>} html else %{<p class="clear"> </p>} end end |