Module: Admin::BannersHelper

Defined in:
app/helpers/admin/banners_helper.rb

Instance Method Summary collapse

Instance Method Details



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 banner_edit_javascripts
  <<-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


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, options)
  if options[:id] == params[options[:param]]
    (:span, text)
  else
    link_to text, url, options
  end
end

#pages_for_selectObject



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.show_banner
        [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)
     = updated_by ? updated_by. : 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  or time
      html << 'Last updated ' 
      html << %{by #{} } if 
      html << %{at #{ timestamp(time) }} if time
      html << '. '
    end
    # if promoted_at
    #   html << %{Last promoted at #{ timestamp(promoted_at) }.}
    # end
    html << %{</small></p>}
    html
  else
    %{<p class="clear">&nbsp;</p>}
  end
end