Module: HeadshotHelper

Defined in:
lib/app/helpers/headshot_helper.rb

Instance Method Summary collapse

Instance Method Details

#headshot_camera(width = 400, height = 300) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/app/helpers/headshot_helper.rb', line 18

def headshot_camera(width = 400, height = 300)
  raw(%{
  <script language="JavaScript">
    headshotInitializer.setup(#{width}, #{height}, params);
  </script>
  })
end

#headshot_config_button(label = 'Configure', options = {}) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/app/helpers/headshot_helper.rb', line 10

def headshot_config_button(label = 'Configure', options = {})
  options.reverse_merge!({
    :onclick => 'headshot.configure()'
  })

  button_tag(label, options)
end

#headshot_default_config(session_key, capture_path, options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/app/helpers/headshot_helper.rb', line 26

def headshot_default_config(session_key, capture_path, options = {})
  options.reverse_merge!(headshot_default_options)
  session_value = u(cookies[session_key])
  raw(%{
  <script language="JavaScript">
      var params = {
          session_key_name: encodeURIComponent('#{session_value}'),
          csrf_token: encodeURI(encodeURI(headshotUtils.getPageMetaValue('csrf-token')))
      };

      var headshotHandlers = {
          onComplete: function(msg) {
              headshot.reset();
          },
          snap: function() {
              headshot.snap();
          }
      }

      headshot.set_swf_url('#{options[:swf_url]}');
      headshot.set_api_url('#{capture_path}');
      headshot.set_quality(#{options[:quality]});
      headshot.set_shutter_sound(#{options[:shutter_sound]}, '#{options[:shutter_sound_url]}');
      headshot.set_hook('onComplete', '#{options[:on_complete]}');
  </script>
  })
end

#headshot_default_optionsObject



54
55
56
57
58
59
60
61
62
# File 'lib/app/helpers/headshot_helper.rb', line 54

def headshot_default_options
  {
      :swf_url => '/swfs/headshot.swf',
      :quality => 90,
      :shutter_sound => true,
      :shutter_sound_url => '/audio/shutter.mp3',
      :on_complete => 'headshotHandlers.onComplete'
  }
end

#headshot_snap_button(label = 'Snap', options = {}) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/app/helpers/headshot_helper.rb', line 2

def headshot_snap_button(label = 'Snap', options = {})
  options.reverse_merge!({
    :onclick => 'headshotHandlers.snap()'
  })

  button_tag(label, options)
end