module Applicants module ApplicantsHelper def current_translations @translations ||= I18n.backend.send(:translations) @translations[I18n.locale].with_indifferent_access end def video_transition_time_string(time) return nil unless time time.strftime('%m/%d/%Y %-I:%M%P') end def stale_state(applicant) return unless applicant.reviewable? state = "stale" if applicant.stale? state = "very-stale" if applicant.very_stale? state end def admin_navigation_link state link = link_to state.capitalize, with_state_admin_applicants_path(state: state) active_class = viewing?(state) ? 'active' : '' content_tag(:li, link, class: active_class) end def viewing? state @state and @state.to_s == state end def screen_recorder_descriptor_url Applicants::ScreencastOMatic::UrlBuilder.new(@applicant, request.host, request.port).descriptor_file_url end def macintosh_operating_system_user? detect_user_operating_system == :macintosh end def windows_operating_system_user? detect_user_operating_system == :windows end def mobile_operating_system_user? detect_user_operating_system == :mobile end def detect_user_operating_system case UseragentParser.parse(user_agent).os_family.try(:downcase) when /mac/ :macintosh when /windows/ :windows when /ios/ :mobile when /android/ :mobile else :unknown end end def macintosh_installer_url "#{racym(:applicants_orders_base_url)}/install-mac-recorder" end def windows_installer_url "#{racym(:applicants_orders_base_url)}/install-windows-recorder" end def macintosh_activator_url "#{racym(:applicants_activator_download_base_url)}/#{macintosh_activator_filename}" end def macintosh_activator_filename racym(:applicants_activator_filename_macintosh) end def windows_activator_url "#{racym(:applicants_activator_download_base_url)}/#{windows_activator_filename}" end def windows_activator_filename racym(:applicants_activator_filename_windows) end def user_agent request.env['HTTP_USER_AGENT'] end def icon(type, options=[]) content_tag(:i, '', class: "icon-#{type} #{options.join(' ') if options.any?}") end def test_exclude(&block) unless Rails.application.config.test_exclude yield return '' # http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/3ebf8c1ed79a9855 end end end end