chris@22: module CalendarsHelper chris@22: def link_to_previous_month(year, month, options={}) chris@22: target_year, target_month = if month == 1 chris@22: [year - 1, 12] chris@22: else chris@22: [year, month - 1] chris@22: end chris@22: chris@22: name = if target_month == 12 chris@22: "#{month_name(target_month)} #{target_year}" chris@22: else chris@22: "#{month_name(target_month)}" chris@22: end chris@22: chris@22: link_to_month(('« ' + name), target_year, target_month, options) chris@22: end chris@22: chris@22: def link_to_next_month(year, month, options={}) chris@22: target_year, target_month = if month == 12 chris@22: [year + 1, 1] chris@22: else chris@22: [year, month + 1] chris@22: end chris@22: chris@22: name = if target_month == 1 chris@22: "#{month_name(target_month)} #{target_year}" chris@22: else chris@22: "#{month_name(target_month)}" chris@22: end chris@22: chris@22: link_to_month((name + ' »'), target_year, target_month, options) chris@22: end chris@22: chris@22: def link_to_month(link_name, year, month, options={}) chris@22: project_id = options[:project].present? ? options[:project].to_param : nil chris@22: chris@22: link_target = calendar_path(:year => year, :month => month, :project_id => project_id) chris@22: chris@22: link_to_remote(link_name, chris@22: {:update => "content", :url => link_target, :method => :put}, chris@22: {:href => link_target}) chris@22: chris@22: end chris@22: chris@22: end