index.html.erb
1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
<h1><%= _('Oauth Client Settings') %></h1>
<%= form_for(:settings) do |f| %>
<div class="providers">
<h3><%= _('Providers') %></h3>
<%= f.fields_for :providers, OpenStruct.new(@providers) do |p| %>
<% OauthClientPlugin::PROVIDERS.each do |available_provider, options| %>
<% provider = OpenStruct.new(@providers[available_provider]) %>
<% provider.options ||= {} %>
<%= p.fields_for available_provider, provider do |a| %>
<div class="provider">
<div class="name">
<h4><%= a.check_box :enabled, {:class => 'enable', :checked => provider.enabled=='true'}, true, false %>
<%= options[:name] %></h4>
</div>
<%= a.fields_for :options, OpenStruct.new(provider.options) do |o| %>
<div class="options" style="<%= provider.enabled=='true' ? '':'display:none' %>">
<div class="client-id">
<span class="label"><%= _('Client ID') %></span>
<span class="value"><%= o.text_field :client_id %></span>
</div>
<div class="client-secret">
<span class="label"><%= _('Client Secret') %></span>
<span class="value"><%= o.text_field :client_secret %></span>
</div>
<% if File.exists?(File.join(File.dirname(__FILE__), "_#{available_provider}.html.erb")) %>
<%= render :partial => "#{available_provider}", :locals => {:options => o, :provider => provider} %>
<% end %>
</div>
<% end %>
</div>
<% end %>
<% end %>
<% end %>
<% button_bar do %>
<%= submit_button(:save, _('Save'), :cancel => {:controller => 'plugins', :action => 'index'}) %>
<% end %>
</div>
<% end %>
<script>
jQuery(document).ready(function($) {
$('.providers .provider .enable').on('click', function() {
$(this).parents('.provider').find('.options').toggle('fast');
});
});
</script>