Module: Aloha::Rails::Helpers

Defined in:
lib/aloha-rails/helpers.rb

Instance Method Summary collapse

Instance Method Details

#aloha!(options = {}) ⇒ Object



39
40
41
# File 'lib/aloha-rails/helpers.rb', line 39

def aloha!(options = {})
  aloha_script_tag(options) + aloha_setup
end

#aloha_script_tag(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/aloha-rails/helpers.rb', line 6

def aloha_script_tag(options={})
  options = {
    :type => 'text/javascript',
    :src => '/assets/aloha/lib/aloha.js',
    :plugins => Aloha::Rails.default_plugins,
    :extra_plugins => []
  }.update(options)

  plugins = options.delete(:plugins) || []
  plugins += options.delete(:extra_plugins)

  if plugins.any?
    options[:data] = {
      'aloha-plugins' => plugins.join(',') 
    }
  end

   :script, nil, options
end

#aloha_setupObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/aloha-rails/helpers.rb', line 27

def aloha_setup
  js = <<-JS
  Aloha.ready(function() { 
    Aloha.require(Aloha.settings.modules, function(Aloha, $) {
      Aloha.onReady();
      $(Aloha.settings.editables).aloha();
    });
  });
  JS
  javascript_tag js
end