Module ItemsHelper
In: app/helpers/items_helper.rb

Methods

Public Instance methods

[Source]

   # File app/helpers/items_helper.rb, line 2
2:   def activate_link(id, active, qid = nil)
3:     text = active > 0 ? t('common.deactivate') : t('common.activate')
4:     link_to text, state_admin_item_path(id, :active => active, :question_id => qid)
5:   end

[Source]

    # File app/helpers/items_helper.rb, line 7
 7:   def gmap(locs, label = nil)
 8:     text = "
 9:       google.load('visualization', '1', {'packages': ['geomap']});
10:       google.setOnLoadCallback(drawMap);
11: 
12:       function drawMap() {
13:         var data = new google.visualization.DataTable();
14:         data.addRows(#{locs.length});
15:         data.addColumn('number', 'LATITUDE', 'Latitude');
16:         data.addColumn('number', 'LONGITUDE', 'Longitude');
17:         data.addColumn('number', '#{label || t('items.number_of_votes')}', 'Value');
18:         data.addColumn('string', 'HOVER', 'HoverText');"
19:     0.upto(locs.length - 1) do |i|
20:       text << "\n\tdata.setValue(#{i}, 0, #{locs[i][0]});"
21:       text << "\n\tdata.setValue(#{i}, 1, #{locs[i][1]});"
22:       text << "\n\tdata.setValue(#{i}, 2, #{locs[i][3]});"
23:       text << "\n\tdata.setValue(#{i}, 3, '#{locs[i][2]}');"
24:     end
25:     text << "
26:         var options = {};
27:         options['region'] = 'world';
28:         options['width'] = '700px';
29:         options['height'] = '400px';
30:         //options['colors'] = [0xFF8747, 0xFFB581, 0xc06000]; //orange colors
31:         options['dataMode'] = 'markers';
32: 
33:         var container = document.getElementById('map_canvas');
34:         var geomap = new google.visualization.GeoMap(container);
35:         geomap.draw(data, options);
36:       };"
37:     text
38:   end

[Validate]