annotate app/helpers/calendars_helper.rb @ 1452:d6b9fd02bb89
feature_36_js_refactoring
Deprecated develoment branch.
author |
luisf <luis.figueira@eecs.qmul.ac.uk> |
date |
Fri, 11 Oct 2013 17:01:24 +0100 |
parents |
cbce1fd3b1b7 |
children |
cbb26bc654de |
rev |
line source |
chris@22
|
1 module CalendarsHelper
|
chris@22
|
2 def link_to_previous_month(year, month, options={})
|
chris@22
|
3 target_year, target_month = if month == 1
|
chris@22
|
4 [year - 1, 12]
|
chris@22
|
5 else
|
chris@22
|
6 [year, month - 1]
|
chris@22
|
7 end
|
chris@22
|
8
|
chris@22
|
9 name = if target_month == 12
|
chris@22
|
10 "#{month_name(target_month)} #{target_year}"
|
chris@22
|
11 else
|
chris@22
|
12 "#{month_name(target_month)}"
|
chris@22
|
13 end
|
chris@22
|
14
|
chris@22
|
15 link_to_month(('« ' + name), target_year, target_month, options)
|
chris@22
|
16 end
|
chris@22
|
17
|
chris@22
|
18 def link_to_next_month(year, month, options={})
|
chris@22
|
19 target_year, target_month = if month == 12
|
chris@22
|
20 [year + 1, 1]
|
chris@22
|
21 else
|
chris@22
|
22 [year, month + 1]
|
chris@22
|
23 end
|
chris@22
|
24
|
chris@22
|
25 name = if target_month == 1
|
chris@22
|
26 "#{month_name(target_month)} #{target_year}"
|
chris@22
|
27 else
|
chris@22
|
28 "#{month_name(target_month)}"
|
chris@22
|
29 end
|
chris@22
|
30
|
chris@22
|
31 link_to_month((name + ' »'), target_year, target_month, options)
|
chris@22
|
32 end
|
chris@22
|
33
|
chris@22
|
34 def link_to_month(link_name, year, month, options={})
|
Chris@441
|
35 link_to_content_update(link_name, params.merge(:year => year, :month => month))
|
chris@22
|
36 end
|
chris@22
|
37 end
|