Module: EventCalendar::ApplicationHelper
- Defined in:
- app/helpers/event_calendar/application_helper.rb
Instance Method Summary collapse
- #div_for_record(record, options = {}, &block) ⇒ Object
- #event_calendar_asset_prefix ⇒ Object
- #event_calendar_javascript_includes ⇒ Object
- #event_times(event) ⇒ Object
- #form_for_browse_event_revisions(event) ⇒ Object
- #hour_options ⇒ Object
- #link_to_add_event_attendees(event, wrapper_options = {}) ⇒ Object
- #link_to_delete_event(event, wrapper_options = {}, link_options = {}) ⇒ Object
- #link_to_delete_link(event, link, wrapper_options = {}, link_options = {}) ⇒ Object
- #link_to_deleted_events(wrapper_options = {}) ⇒ Object
- #link_to_edit_event(event, wrapper_options = {}, link_options = {}) ⇒ Object
- #link_to_edit_link(event, link, wrapper_options = {}, link_options = {}) ⇒ Object
- #link_to_event_revisions(wrapper_options = {}, link_options = {}) ⇒ Object
- #link_to_events(wrapper_options = {}, link_options = {}) ⇒ Object
- #link_to_new_event(wrapper_options = {}, link_options = {}) ⇒ Object
- #link_to_new_link(event, wrapper_options = {}, link_options = {}) ⇒ Object
- #link_wrapper(path, wrapper_options = {}, link_options = {}) ⇒ Object
- #links_to_edit_and_delete_event(event, wrapper_options = {}, link_options = {}) ⇒ Object
- #minute_options ⇒ Object
- #open_if_current_month(month, closed_or_open) ⇒ Object
- #render_event_main_menu ⇒ Object
- #render_event_navigation(event = nil) ⇒ Object
- #render_flash ⇒ Object
- #tag_for_record(tag, record, *args, &block) ⇒ Object
- #time_with_zones(time = Time.now) ⇒ Object
- #times_with_zones(event) ⇒ Object
- #timezone_in_words(zone) ⇒ Object
Instance Method Details
#div_for_record(record, options = {}, &block) ⇒ Object
2 3 4 |
# File 'app/helpers/event_calendar/application_helper.rb', line 2 def div_for_record(record, ={}, &block) div_for(record, ){ yield } end |
#event_calendar_asset_prefix ⇒ Object
220 221 222 |
# File 'app/helpers/event_calendar/application_helper.rb', line 220 def event_calendar_asset_prefix 'event_calendar/' end |
#event_calendar_javascript_includes ⇒ Object
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'app/helpers/event_calendar/application_helper.rb', line 224 def event_calendar_javascript_includes list = [ "#{event_calendar_asset_prefix}jquery.tablesorter.min.js", "#{event_calendar_asset_prefix}jquery-ui-1.8.16.custom.min.js", "#{event_calendar_asset_prefix}jquery.string.1.0-min.js", "#{event_calendar_asset_prefix}jquery.clonePosition.js", "#{event_calendar_asset_prefix}lowpro.jquery.js", "#{event_calendar_asset_prefix}fullcalendar.js", "#{event_calendar_asset_prefix}jquery.qtip-1.0.0-rc3.js", "#{event_calendar_asset_prefix}rails", "#{event_calendar_asset_prefix}event_calendar_behaviors.js", "#{event_calendar_asset_prefix}event_calendar.js" ] unless Rails.env == 'production' list.unshift("#{event_calendar_asset_prefix}jquery") else list.unshift("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js") end end |
#event_times(event) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'app/helpers/event_calendar/application_helper.rb', line 60 def event_times(event) t = [] event_times = times_with_zones(event) event_times.first.each_with_index do |z_t, i| t << "#{z_t.last} - #{event_times.last[i].last} " + content_tag(:em, z_t.first) end t.join(" / ").html_safe end |
#form_for_browse_event_revisions(event) ⇒ Object
199 200 201 202 203 204 |
# File 'app/helpers/event_calendar/application_helper.rb', line 199 def form_for_browse_event_revisions(event) return unless (:update, event) render :partial => 'events/browse_event_revisions', :locals => { :event => event } end |
#hour_options ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'app/helpers/event_calendar/application_helper.rb', line 76 def [ ['6 AM','6'], ['7 AM','7'], ['8 AM','8'], ['9 AM','9'], ['10 AM','10'], ['11 AM','11'], ['12 PM','12'], ['1 PM','13'], ['2 PM','14'], ['3 PM','15'], ['4 PM','16'], ['5 PM','17'], ['6 PM','18'], ['7 PM','19'], ['8 PM','20'] ] end |
#link_to_add_event_attendees(event, wrapper_options = {}) ⇒ Object
132 133 134 135 136 137 |
# File 'app/helpers/event_calendar/application_helper.rb', line 132 def link_to_add_event_attendees(event, ={}) return unless (:add_attendees, event) link_wrapper(new_event_attendee_path(event), , { :link_text => "Add <em>#{h(event.name)}</em> Attendees".html_safe }) end |
#link_to_delete_event(event, wrapper_options = {}, link_options = {}) ⇒ Object
174 175 176 177 178 179 180 181 182 183 |
# File 'app/helpers/event_calendar/application_helper.rb', line 174 def link_to_delete_event(event, ={}, ={}) return unless (:delete, event) link_wrapper(event_path(event), { :highlight => false }.merge!(), { :link_text => "Delete <em>#{event.name}</em>".html_safe, :confirm => "Are you sure you want to permanently delete the #{event.name} #{event.event_type}?", :method => "delete" }.merge!()) end |
#link_to_delete_link(event, link, wrapper_options = {}, link_options = {}) ⇒ Object
163 164 165 166 167 168 169 170 171 172 |
# File 'app/helpers/event_calendar/application_helper.rb', line 163 def link_to_delete_link(event, link, ={}, ={}) return unless (:delete, link) link_wrapper(event_link_path(event, link), { :no_wrapper => true }.merge!(), { :link_text => 'delete', :confirm => "Are you sure you want to permanently delete the #{link.name} link?", :method => "delete" }.merge!()) end |
#link_to_deleted_events(wrapper_options = {}) ⇒ Object
125 126 127 128 129 130 |
# File 'app/helpers/event_calendar/application_helper.rb', line 125 def link_to_deleted_events(={}) return unless (:update, Event.new) link_wrapper(event_revisions_path, , { :link_text => "Browse Deleted Events (#{EventRevision.deleted.count})" }) end |
#link_to_edit_event(event, wrapper_options = {}, link_options = {}) ⇒ Object
139 140 141 142 143 144 |
# File 'app/helpers/event_calendar/application_helper.rb', line 139 def link_to_edit_event(event, ={}, ={}) return unless (:update, event) link_wrapper(edit_event_path(event), , { :link_text => "Edit <em>#{h(event.name)}</em>".html_safe }.merge!()) end |
#link_to_edit_link(event, link, wrapper_options = {}, link_options = {}) ⇒ Object
154 155 156 157 158 159 160 161 |
# File 'app/helpers/event_calendar/application_helper.rb', line 154 def link_to_edit_link(event, link, ={}, ={}) return unless (:update, link) link_wrapper(edit_event_link_path(event, link), { :no_wrapper => true }.merge!(), { :link_text => "update" }.merge!()) end |
#link_to_event_revisions(wrapper_options = {}, link_options = {}) ⇒ Object
107 108 109 110 111 112 113 114 |
# File 'app/helpers/event_calendar/application_helper.rb', line 107 def link_to_event_revisions(={}, ={}) return unless (:read, EventRevision.new) link_wrapper(event_revisions_path, { :no_wrapper => true }.merge!(), { :link_text => 'Browse Event Revisions' }.merge!()) end |
#link_to_events(wrapper_options = {}, link_options = {}) ⇒ Object
100 101 102 103 104 105 |
# File 'app/helpers/event_calendar/application_helper.rb', line 100 def link_to_events(={}, ={}) return unless (:read, Event.new) link_wrapper(events_path, , .reverse_merge!({ :link_text => 'Event Calendar' })) end |
#link_to_new_event(wrapper_options = {}, link_options = {}) ⇒ Object
116 117 118 119 120 121 122 123 |
# File 'app/helpers/event_calendar/application_helper.rb', line 116 def link_to_new_event(={}, ={}) return unless (:create, Event.new) link_wrapper(new_event_path, { :no_wrapper => true }.merge!(), { :link_text => "Create New Event" }.merge!()) end |
#link_to_new_link(event, wrapper_options = {}, link_options = {}) ⇒ Object
146 147 148 149 150 151 152 |
# File 'app/helpers/event_calendar/application_helper.rb', line 146 def link_to_new_link(event, ={}, ={}) return unless (:create, Link.new) link_wrapper(new_event_link_path(event), , { :link_text => 'Add a new link to this event', :class => 'fake_button' }.merge!()) end |
#link_wrapper(path, wrapper_options = {}, link_options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/event_calendar/application_helper.rb', line 9 def link_wrapper(path, ={}, ={}) tag = .delete(:tag) || :p link_text = .delete(:link_text) || path unless .delete(:no_wrapper) return content_tag(tag, ) do link_to(link_text, path, ) end else return link_to(link_text, path, ) end end |
#links_to_edit_and_delete_event(event, wrapper_options = {}, link_options = {}) ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'app/helpers/event_calendar/application_helper.rb', line 185 def links_to_edit_and_delete_event(event, ={}, ={}) return unless (:delete, event) || (:update, event) link_to_edit_event(event, { :no_wrapper => true }.merge!(), { :link_text => 'update' }.merge!()) + " " + link_to_delete_event(event, { :no_wrapper => true }.merge!(), { :link_text => 'delete' }.merge!()) end |
#minute_options ⇒ Object
96 97 98 |
# File 'app/helpers/event_calendar/application_helper.rb', line 96 def ['00', '15', '30', '45'] end |
#open_if_current_month(month, closed_or_open) ⇒ Object
22 23 24 25 26 27 |
# File 'app/helpers/event_calendar/application_helper.rb', line 22 def open_if_current_month(month, closed_or_open) # setting closed_or_open='closed' in args does not seem to work when a # nil val is passed as the closed_or_open arg closed_or_open = closed_or_open.blank? ? 'closed' : closed_or_open Date.current.strftime("%B") == month ? 'open' : closed_or_open end |
#render_event_main_menu ⇒ Object
212 213 214 |
# File 'app/helpers/event_calendar/application_helper.rb', line 212 def render :partial => 'event-calendar-shared/main_menu' end |
#render_event_navigation(event = nil) ⇒ Object
206 207 208 209 210 |
# File 'app/helpers/event_calendar/application_helper.rb', line 206 def (event=nil) render :partial => 'event-calendar-shared/navigation', :locals => { :event => event } end |
#render_flash ⇒ Object
216 217 218 |
# File 'app/helpers/event_calendar/application_helper.rb', line 216 def render_flash render :partial => 'event-calendar-shared/flash', :object => flash end |
#tag_for_record(tag, record, *args, &block) ⇒ Object
5 6 7 |
# File 'app/helpers/event_calendar/application_helper.rb', line 5 def tag_for_record(tag, record, *args, &block) content_tag_for(tag, record, *args){ yield } end |
#time_with_zones(time = Time.now) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/helpers/event_calendar/application_helper.rb', line 29 def time_with_zones(time=Time.now) out = [] ActiveSupport::TimeZone.us_zones.map(&:name).each do |us_zone| next unless us_zone =~ /Pacific|Mountain|Central|Eastern/ key = time.in_time_zone(us_zone).strftime("%Z") key = timezone_in_words(key.strip) # out[key] = time.in_time_zone(us_zone).strftime(format) out << [key, time.in_time_zone(us_zone).strftime(TIME_BASE)] end out.reverse end |
#times_with_zones(event) ⇒ Object
69 70 71 72 73 74 |
# File 'app/helpers/event_calendar/application_helper.rb', line 69 def times_with_zones(event) [ time_with_zones(event.start_time), time_with_zones(event.end_time) ] end |
#timezone_in_words(zone) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/helpers/event_calendar/application_helper.rb', line 41 def timezone_in_words(zone) pac_regex = /^P(S|D)T$/ mnt_regex = /^M(S|D)T$/ ctr_regex = /^C(S|D)T$/ est_regex = /^E(S|D)T$/ case zone when pac_regex zone.gsub(pac_regex, 'Pacific') when mnt_regex zone.gsub(mnt_regex, 'Mountain') when ctr_regex zone.gsub(ctr_regex, 'Central') when est_regex zone.gsub(est_regex, 'Eastern') else zone end end |