calendar_include_dry.patch

Move repetitive calendar include code from views into helper - Peter Suschlik, 2008-03-31 18:06

Download (6.11 KB)

View differences:

app/helpers/application_helper.rb (working copy)
463 463
  end
464 464
  
465 465
  def calendar_for(field_id)
466
    include_calendar unless @calendar_included
466 467
    image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
467 468
    javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });")
468 469
  end
470

  
471
  def include_calendar
472
    @calendar_included = true
473
    content_for :header_tags do
474
      javascript_include_tag('calendar/calendar') +
475
      javascript_include_tag("calendar/lang/calendar-#{current_language}.js") +
476
      javascript_include_tag('calendar/calendar-setup') +
477
      stylesheet_link_tag('calendar')
478
    end
479
  end
469 480
  
470 481
  def wikitoolbar_for(field_id)
471 482
    return '' unless Setting.text_formatting == 'textile'
app/views/timelog/report.rhtml (working copy)
63 63
<% end %>
64 64
<% end %>
65 65
<% end %>
66

  
67
<% content_for :header_tags do %>
68
<%= javascript_include_tag 'calendar/calendar' %>
69
<%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
70
<%= javascript_include_tag 'calendar/calendar-setup' %>
71
<%= stylesheet_link_tag 'calendar' %>
72
<% end %>
app/views/timelog/details.rhtml (working copy)
44 44
<span><%= link_to 'CSV', params.merge(:format => 'csv'), :class => 'csv' %></span>
45 45
</p>
46 46
<% end %>
47

  
48
<% content_for :header_tags do %>
49
    <%= javascript_include_tag 'calendar/calendar' %>
50
    <%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
51
    <%= javascript_include_tag 'calendar/calendar-setup' %>
52
    <%= stylesheet_link_tag 'calendar' %>
53
<% end %>
app/views/timelog/edit.rhtml (working copy)
14 14
<%= submit_tag l(:button_save) %>
15 15

  
16 16
<% end %>
17

  
18
<% content_for :header_tags do %>
19
<%= javascript_include_tag 'calendar/calendar' %>
20
<%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
21
<%= javascript_include_tag 'calendar/calendar-setup' %>
22
<%= stylesheet_link_tag 'calendar' %>
23
<% end %>
app/views/users/_form.rhtml (working copy)
30 30
</div>
31 31
</div>
32 32
<!--[eoform:user]-->
33

  
34
<% content_for :header_tags do %>
35
<%= javascript_include_tag 'calendar/calendar' %>
36
<%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
37
<%= javascript_include_tag 'calendar/calendar-setup' %>
38
<%= stylesheet_link_tag 'calendar' %>
39
<% end %>
app/views/versions/_form.rhtml (working copy)
6 6
<p><%= f.text_field :wiki_page_title, :label => :label_wiki_page, :size => 60, :disabled => @project.wiki.nil? %></p>
7 7
<p><%= f.text_field :effective_date, :size => 10 %><%= calendar_for('version_effective_date') %></p>
8 8
</div>
9

  
10
<% content_for :header_tags do %>
11
<%= javascript_include_tag 'calendar/calendar' %>
12
<%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
13
<%= javascript_include_tag 'calendar/calendar-setup' %>
14
<%= stylesheet_link_tag 'calendar' %>
15
<% end %>
app/views/projects/_form.rhtml (working copy)
46 46
</fieldset>
47 47
<% end %>
48 48
<!--[eoform:project]-->
49

  
50

  
51
<% content_for :header_tags do %>
52
<%= javascript_include_tag 'calendar/calendar' %>
53
<%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
54
<%= javascript_include_tag 'calendar/calendar-setup' %>
55
<%= stylesheet_link_tag 'calendar' %>
56
<% end %>
app/views/account/register.rhtml (working copy)
35 35

  
36 36
<%= submit_tag l(:button_submit) %>
37 37
<% end %>
38

  
39
<% content_for :header_tags do %>
40
<%= javascript_include_tag 'calendar/calendar' %>
41
<%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
42
<%= javascript_include_tag 'calendar/calendar-setup' %>
43
<%= stylesheet_link_tag 'calendar' %>
44
<% end %>
app/views/issues/bulk_edit.rhtml (working copy)
47 47

  
48 48
<p><%= submit_tag l(:button_submit) %>
49 49
<% end %>
50

  
51
<% content_for :header_tags do %>
52
    <%= javascript_include_tag 'calendar/calendar' %>
53
    <%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
54
    <%= javascript_include_tag 'calendar/calendar-setup' %>
55
    <%= stylesheet_link_tag 'calendar' %>
56
<% end %>
app/views/issues/_form.rhtml (working copy)
49 49
<% end %>
50 50

  
51 51
<%= wikitoolbar_for 'issue_description' %>
52

  
53
<% content_for :header_tags do %>
54
    <%= javascript_include_tag 'calendar/calendar' %>
55
    <%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
56
    <%= javascript_include_tag 'calendar/calendar-setup' %>
57
    <%= stylesheet_link_tag 'calendar' %>
58
<% end %>