home_page 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/home_page/application.js +8 -1
  3. data/app/assets/javascripts/home_page/base.js.coffee.erb +44 -0
  4. data/app/assets/javascripts/home_page/lib/jquery.multisortable.js +254 -0
  5. data/app/assets/javascripts/home_page/page_module_collections/index.js.coffee +14 -0
  6. data/app/assets/javascripts/home_page/shared/sortable_list.js.coffee +44 -0
  7. data/app/assets/stylesheets/home_page/application.css +4 -0
  8. data/app/assets/stylesheets/home_page/bootswatch.css.less +4 -0
  9. data/app/assets/stylesheets/vendors/keen/dashboards.css +59 -0
  10. data/app/controllers/home_page/application_controller.rb +24 -0
  11. data/app/controllers/page_module_collections_controller.rb +96 -0
  12. data/app/controllers/page_module_collections_modules_controller.rb +43 -0
  13. data/app/controllers/page_modules_controller.rb +121 -0
  14. data/app/controllers/settings_controller.rb +30 -0
  15. data/app/controllers/users_controller.rb +7 -3
  16. data/app/helpers/home_page/application_helper.rb +22 -0
  17. data/app/helpers/home_page/form_helper.rb +23 -0
  18. data/app/helpers/home_page/show_helper.rb +67 -0
  19. data/app/models/page_module.rb +78 -0
  20. data/app/models/page_module_collection.rb +24 -0
  21. data/app/models/page_module_collection_module.rb +8 -0
  22. data/app/models/setting.rb +26 -0
  23. data/app/views/apis/volontariat/_settings.html.erb +5 -0
  24. data/app/views/layouts/application.html.erb +2 -1
  25. data/app/views/layouts/fluid/without_rows.html.erb +17 -0
  26. data/app/views/layouts/shared/_foot.html.erb +9 -1
  27. data/app/views/layouts/shared/_modal.html.erb +16 -0
  28. data/app/views/page_module_collections/_collection.html.erb +18 -0
  29. data/app/views/page_module_collections/_form.html.erb +29 -0
  30. data/app/views/page_module_collections/_page_module.html.erb +27 -0
  31. data/app/views/page_module_collections/_page_module_collection.html.erb +41 -0
  32. data/app/views/page_module_collections/destroy.js.erb +9 -0
  33. data/app/views/page_module_collections/edit.html.erb +3 -0
  34. data/app/views/page_module_collections/index.html.erb +67 -0
  35. data/app/views/page_module_collections/new.html.erb +3 -0
  36. data/app/views/page_module_collections/show.html.erb +44 -0
  37. data/app/views/page_module_collections/update.js.erb +11 -0
  38. data/app/views/page_module_collections_modules/_fields.html.erb +10 -0
  39. data/app/views/page_module_collections_modules/create.js.erb +8 -0
  40. data/app/views/page_module_collections_modules/destroy.js.erb +9 -0
  41. data/app/views/page_module_collections_modules/new.html.erb +27 -0
  42. data/app/views/page_modules/_actions.html.erb +26 -0
  43. data/app/views/page_modules/_collection.html.erb +19 -0
  44. data/app/views/page_modules/_fields.html.erb +52 -0
  45. data/app/views/page_modules/_form.html.erb +25 -0
  46. data/app/views/page_modules/_page_module.html.erb +14 -0
  47. data/app/views/page_modules/_tab.html.erb +39 -0
  48. data/app/views/page_modules/destroy.js.erb +9 -0
  49. data/app/views/page_modules/edit.html.erb +3 -0
  50. data/app/views/page_modules/new.html.erb +3 -0
  51. data/app/views/page_modules/update.js.erb +11 -0
  52. data/app/views/settings/_apis.html.erb +20 -0
  53. data/app/views/settings/index.html.erb +13 -0
  54. data/app/views/settings/plugins/home_page/_panel.html.erb +42 -0
  55. data/app/views/settings/plugins/home_page/tabs/_apis.html.erb +24 -0
  56. data/app/views/shared/_javascript_response.js.erb +50 -0
  57. data/app/views/shared/layouts/_modal.html.erb +14 -0
  58. data/app/views/users/index.html.erb +5 -1
  59. data/app/views/users/show.html.erb +5 -0
  60. data/config/initializers/default_settings.rb +8 -0
  61. data/config/locales/general/en.yml +33 -2
  62. data/config/locales/resources/page_module/en.yml +34 -0
  63. data/config/locales/resources/page_module_collection/en.yml +21 -0
  64. data/config/locales/resources/setting/en.yml +26 -0
  65. data/config/routes.rb +18 -1
  66. data/db/migrate/20150307193102_create_friendly_id_slugs.rb +3 -3
  67. data/db/migrate/20150313154924_create_settings.rb +17 -0
  68. data/db/migrate/20150315082328_create_page_modules_and_page_module_collections.rb +43 -0
  69. data/lib/home_page.rb +9 -0
  70. data/lib/home_page/api_provider_host.rb +54 -0
  71. data/lib/home_page/engine.rb +1 -0
  72. data/lib/home_page/navigation.rb +62 -21
  73. data/lib/home_page/pagination_metadata.rb +1 -2
  74. data/lib/home_page/simple_navigation_renderer/breadcrumbs_without_method_links.rb +6 -2
  75. data/lib/home_page/version.rb +1 -1
  76. metadata +242 -50
  77. data/README.rdoc +0 -3
  78. data/config/initializers/volontariat.rb +0 -3
@@ -0,0 +1,11 @@
1
+ <% message = flash[:notice] %>
2
+ <% flash.delete(:notice) %>
3
+ <% alert = message.present? ? "alert('#{message}');" : '' %>
4
+
5
+ $("#page_module_collections_row_<%= @page_module_collection.id %>").replaceWith("<%= escape_javascript(
6
+ render(
7
+ partial: 'page_module_collections/page_module_collection', locals: { page_module_collection: @page_module_collection }
8
+ )
9
+ ) %>");
10
+ $('#modal').modal('hide');
11
+ <%= raw alert %>
@@ -0,0 +1,10 @@
1
+ <%= devise_error_messages! %>
2
+
3
+ <%= f.input :collection_id, as: :hidden %>
4
+ <%= f.select :module_id, @page_modules, { include_blank: true }, { class: 'selectize_select' } %>
5
+
6
+ <script type="text/javascript">
7
+ $(function () {
8
+ $('.selectize_select').selectize({ create: true, sortField: 'text' });
9
+ });
10
+ </script>
@@ -0,0 +1,8 @@
1
+ if($("#page_module_collection_module_<%= @collection_module_id %>").length == 0) {
2
+ $("#page_module_collection_modules").append("<%= escape_javascript(
3
+ render(
4
+ partial: 'page_module_collections/page_module', locals: { page_module: @page_module }
5
+ )
6
+ ) %>");
7
+ $('#modal').modal('hide');
8
+ }
@@ -0,0 +1,9 @@
1
+ <% message = flash[:notice] || flash[:alert] %>
2
+ <% flash.delete(:notice); flash.delete(:alert) %>
3
+ <% alert = message.present? ? "alert('#{message}');" : '' %>
4
+
5
+ <% unless @page_module_collection_module.persisted? %>
6
+ $("#page_module_collection_module_<%= @page_module_collection_module.id %>").remove();
7
+ <% end %>
8
+
9
+ <%= raw alert %>
@@ -0,0 +1,27 @@
1
+ <% content_for :title do %><%= t('page_module_collections.show.add_module') %><% end %>
2
+
3
+ <% content_for :modal_footer do %>
4
+ <button type="button" class="btn btn-default" data-dismiss="modal"><%= t('general.close') %></button>
5
+ <button type="submit" class="btn btn-primary"><%= t('general.select_existing_item_or_create_new_one') %></button>
6
+ <% end %>
7
+
8
+ <%= simple_form_for(
9
+ @page_module_collection_module, url: page_module_collections_modules_path, wrapper: :horizontal_form,
10
+ method: :post, remote: request.xhr?, html: { class: 'form-horizontal', autocomplete: 'off' }
11
+ ) do |f| %>
12
+ <% if request.xhr? %>
13
+ <% content_for :modal_body do %>
14
+ <%= render partial: 'page_module_collections_modules/fields', locals: { f: f } %>
15
+ <% end %>
16
+
17
+ <%= render partial: 'shared/layouts/modal' %>
18
+ <% else %>
19
+ <%= render partial: 'page_module_collections_modules/fields', locals: { f: f } %>
20
+
21
+ <div class="form-group">
22
+ <div class="col-sm-offset-3 col-sm-9">
23
+ <button type="submit" class="btn btn-primary"><%= t('general.select_existing_item_or_create_new_one') %></button>
24
+ </div>
25
+ </div>
26
+ <% end %>
27
+ <% end %>
@@ -0,0 +1,26 @@
1
+ <div class="dropdown">
2
+ <button
3
+ class="btn btn-default dropdown-toggle" type="button" id="page_module_<%= page_module.id %>_actions"
4
+ data-toggle="dropdown" aria-expanded="true">
5
+ <%= t('general.actions') %>
6
+ <span class="caret"></span>
7
+ </button>
8
+ <ul class="dropdown-menu" role="menu" aria-labelledby="page_module_<%= page_module.id %>_actions">
9
+ <li role="presentation">
10
+ <%= link_to(
11
+ t('general.destroy'), page_module_path(page_module), id: "page_module_#{page_module.id}", method: :delete,
12
+ data: { confirm: t('general.questions.are_you_sure') }, remote: true
13
+ ) %>
14
+ </li>
15
+ <li role="presentation">
16
+ &nbsp;&nbsp;
17
+ <button
18
+ type="button" class="btn btn-default" data-toggle="modal" data-target="#modal"
19
+ data-url="<%= edit_page_module_path(page_module) %>"
20
+ data-title="<%= t('page_modules.edit.title') %>" data-only-update-body="false"
21
+ >
22
+ <span class="glyphicon glyphicon-pencil"></span> <%= t('general.edit') %>
23
+ </button>
24
+ </li>
25
+ </ul>
26
+ </div>
@@ -0,0 +1,19 @@
1
+ <% if @page_modules.none? %>
2
+ <p><%= t('page_modules.index.empty_collection') %></p>
3
+ <% else %>
4
+ <table class='table table-striped'>
5
+ <thead>
6
+ <tr class='<%= cycle('odd', 'even') %>'>
7
+ <th style='width: 200px'><%= t('general.attributes.title') %></th>
8
+ <th style='width: 200px'><%= t('general.attributes.slug') %></th>
9
+ <th style='width: 200px'><%= t('general.attributes.published') %></th>
10
+ <th></th>
11
+ </tr>
12
+ </thead>
13
+ <tbody>
14
+ <%= render partial: 'page_modules/page_module', collection: @page_modules %>
15
+ </tbody>
16
+ </table>
17
+
18
+ <%= will_paginate @page_modules, renderer: BootstrapPagination::Rails %>
19
+ <% end %>
@@ -0,0 +1,52 @@
1
+ <%= devise_error_messages! %>
2
+
3
+ <%= f.input :collection_id, as: :hidden %>
4
+ <%= f.input :title %>
5
+ <%= f.input :description %>
6
+ <%= f.input(
7
+ :plugin, collection: Setting['home_page.general.plugins'].map do |p|
8
+ p = p == 'home_page' ? 'home' : p.gsub('home_page_', ''); [p.humanize.titleize, p]
9
+ end, input_html: { data: { 'setting-url' => setting_path('show', id2: 'x') }}
10
+ ) %>
11
+ <%= f.input(
12
+ :partial_path, collection: if f.object.plugin.present?
13
+ Setting["#{(f.object.plugin == 'home' ? 'home_page' : 'home_page_' + f.object.plugin)}.general.partial_paths"]
14
+ else
15
+ []
16
+ end
17
+ ) %>
18
+
19
+ <div class="form-group string optional page_module_published_from">
20
+ <label for="page_module_published_from" class="string optional col-sm-3 control-label">
21
+ <%= t('activerecord.attributes.page_module.published_from') %>
22
+ </label>
23
+ <div class="col-sm-9">
24
+ <div class='input-group date' id='page_module_published_from_datetime_picker'>
25
+ <%= f.text_field :published_from, class: 'form-control' %>
26
+ <span class="input-group-addon">
27
+ <span class="glyphicon glyphicon-calendar"></span>
28
+ </span>
29
+ </div>
30
+ </div>
31
+ </div>
32
+
33
+ <div class="form-group string optional page_module_published_until">
34
+ <label for="page_module_published_until" class="string optional col-sm-3 control-label">
35
+ <%= t('activerecord.attributes.page_module.published_until') %>
36
+ </label>
37
+ <div class="col-sm-9">
38
+ <div class='input-group date' id='page_module_published_until_datetime_picker'>
39
+ <%= f.text_field :published_until, class: 'form-control' %>
40
+ <span class="input-group-addon">
41
+ <span class="glyphicon glyphicon-calendar"></span>
42
+ </span>
43
+ </div>
44
+ </div>
45
+ </div>
46
+
47
+ <script type="text/javascript">
48
+ $(function () {
49
+ $('#page_module_published_from_datetime_picker').datetimepicker({ format: 'YYYY-MM-DD hh:mm:ss' });
50
+ $('#page_module_published_until_datetime_picker').datetimepicker({ format: 'YYYY-MM-DD hh:mm:ss' });
51
+ });
52
+ </script>
@@ -0,0 +1,25 @@
1
+ <% content_for :modal_footer do %>
2
+ <button type="button" class="btn btn-default" data-dismiss="modal"><%= t('general.close') %></button>
3
+ <button type="submit" class="btn btn-primary"><%= t('general.submit') %></button>
4
+ <% end %>
5
+
6
+ <%= simple_form_for(
7
+ resource, url: resource.new_record? ? page_modules_path : page_module_path(resource), wrapper: :horizontal_form,
8
+ method: resource.new_record? ? :post : :put, remote: request.xhr?, html: { class: 'form-horizontal', autocomplete: 'off' }
9
+ ) do |f| %>
10
+ <% if request.xhr? %>
11
+ <% content_for :modal_body do %>
12
+ <%= render partial: 'page_modules/fields', locals: { f: f } %>
13
+ <% end %>
14
+
15
+ <%= render partial: 'shared/layouts/modal' %>
16
+ <% else %>
17
+ <%= render partial: 'page_modules/fields', locals: { f: f } %>
18
+
19
+ <div class="form-group">
20
+ <div class="col-sm-offset-3 col-sm-9">
21
+ <button type="submit" class="btn btn-primary"><%= t('general.submit') %></button>
22
+ </div>
23
+ </div>
24
+ <% end %>
25
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <tr class="<%= cycle('odd', 'even') %>" id="page_modules_row_<%= page_module.id %>">
2
+ <td><%= link_to page_module.title, edit_page_module_path(page_module) %></td>
3
+ <td><%= page_module.slug %></td>
4
+ <td style="text-align:center;">
5
+ <%= page_module.published_from.nil? ? t('general.not_available_short') : page_module.published_from.strftime('%d.%m.%Y %H:%M:%S') %>
6
+ <br/>
7
+ -
8
+ <br/>
9
+ <%= page_module.published_until.nil? ? t('general.not_available_short') : page_module.published_until.strftime('%d.%m.%Y %H:%M:%S') %>
10
+ </td>
11
+ <td>
12
+ <%= render partial: 'page_modules/actions', locals: { page_module: page_module } %>
13
+ </td>
14
+ </tr>
@@ -0,0 +1,39 @@
1
+ <p>
2
+ <% if @page_module_slug_stubs.none? %>
3
+ <div class="alert alert-info" role="alert">
4
+ <%= t('page_modules.index.empty_collection') %>
5
+ </div>
6
+ <% else %>
7
+ <div role="tabpanel">
8
+ <ul class="nav nav-tabs" role="tablist">
9
+ <% @page_module_slug_stubs.each_with_index do |slug_stub, index| %>
10
+ <li role="presentation"<% if index == 0 %> class="active"<% end %>>
11
+ <a
12
+ href="<%= page_modules_path(slug_stub: slug_stub) %>"
13
+ data-target="#page_modules_slug_stub_<%= slug_stub %>" aria-controls="page_modules_slug_stub_<%= slug_stub %>"
14
+ role="tab" data-toggle="tabajax"
15
+ >
16
+ <%= slug_stub.titleize %>
17
+ </a>
18
+ </li>
19
+ <% end %>
20
+ </ul>
21
+ <div class="tab-content">
22
+ <% @page_module_slug_stubs.each_with_index do |slug_stub, index| %>
23
+ <div role="tabpanel" class="tab-pane active" id="page_modules_slug_stub_<%= slug_stub %>">
24
+ <%= render partial: 'page_modules/collection' if index == 0 %>
25
+ </div>
26
+ <% end %>
27
+ </div>
28
+ </div>
29
+ <% end %>
30
+ </p>
31
+
32
+ <p>
33
+ <button
34
+ type="button" class="btn btn-default" data-toggle="modal" data-target="#modal" data-url="<%= new_page_module_path %>"
35
+ data-title="<%= t('page_modules.new.title') %>" data-only-update-body="false"
36
+ >
37
+ <span class="glyphicon glyphicon-plus"></span> <%= t('page_modules.new.short_title') %>
38
+ </button>
39
+ </p>
@@ -0,0 +1,9 @@
1
+ <% message = flash[:notice] || flash[:alert] %>
2
+ <% flash.delete(:notice); flash.delete(:alert) %>
3
+ <% alert = message.present? ? "alert('#{message}');" : '' %>
4
+
5
+ <% unless @page_module.persisted? %>
6
+ $("#page_modules_row_<%= @page_module.id %>").remove();
7
+ <% end %>
8
+
9
+ <%= raw alert %>
@@ -0,0 +1,3 @@
1
+ <% content_for :title do %><%= t('page_modules.edit.title') %><% end %>
2
+
3
+ <%= render partial: 'page_modules/form' %>
@@ -0,0 +1,3 @@
1
+ <% content_for :title do %><%= t('page_modules.new.title') %><% end %>
2
+
3
+ <%= render partial: 'page_modules/form' %>
@@ -0,0 +1,11 @@
1
+ <% message = flash[:notice] %>
2
+ <% flash.delete(:notice) %>
3
+ <% alert = message.present? ? "alert('#{message}');" : '' %>
4
+
5
+ $("#page_modules_row_<%= @page_module.id %>").replaceWith("<%= escape_javascript(
6
+ render(
7
+ partial: 'page_modules/page_module', locals: { page_module: @page_module }
8
+ )
9
+ ) %>");
10
+ $('#modal').modal('hide');
11
+ <%= raw alert %>
@@ -0,0 +1,20 @@
1
+ <div role="tabpanel">
2
+ <ul class="nav nav-tabs" role="tablist">
3
+ <% Setting["#{plugin}.general.available_apis"].each_with_index do |provider, index| %>
4
+ <li role="presentation"<% if index == 0 %> class="active"<% end %>>
5
+ <a href="#home_page_settings_apis_<%= provider %>" aria-controls="<%= plugin %>_settings_apis_<%= provider %>" role="tab" data-toggle="tab">
6
+ <%= t("general.apis.providers.#{provider}.title") %>
7
+ </a>
8
+ </li>
9
+ <% end %>
10
+ </ul>
11
+ <div class="tab-content">
12
+ <% Setting["#{plugin}.general.available_apis"].each_with_index do |provider, index| %>
13
+ <div role="tabpanel" class="tab-pane<% if index == 0 %> active<% end %>" id="<%= plugin %>_settings_apis_<%= provider %>">
14
+ <p>
15
+ <%= render partial: "apis/#{provider}/settings", locals: { f: f } %>
16
+ </p>
17
+ </div>
18
+ <% end %>
19
+ </div>
20
+ </div>
@@ -0,0 +1,13 @@
1
+ <% content_for :title do %><%= t('settings.index.title') %><% end %>
2
+
3
+ <%= simple_form_for :setting, url: updates_settings_path, html: { method: :put, class: 'form-horizontal' }, wrapper: :horizontal_form do |f| %>
4
+ <div class="panel-group" id="settings_accordion" role="tablist" aria-multiselectable="true">
5
+ <% Setting['home_page.general.plugins'].each_with_index do |plugin, index| %>
6
+ <%= render partial: "settings/plugins/#{plugin}/panel", locals: { f: f, index: index } %>
7
+ <% end %>
8
+ </div>
9
+
10
+ <p>
11
+ <%= f.submit t('general.submit'), class: 'btn btn-default' %>
12
+ </p>
13
+ <% end %>
@@ -0,0 +1,42 @@
1
+ <div class="panel panel-default">
2
+ <div class="panel-heading" role="tab" id="heading<%= index + 1 %>">
3
+ <h4 class="panel-title">
4
+ <a data-toggle="collapse" data-parent="#settings_accordion" href="#home_page_settings" aria-expanded="true" aria-controls="home_page_settings">
5
+ <%= t('settings.index.plugins.home_page.index.title') %>
6
+ </a>
7
+ </h4>
8
+ </div>
9
+
10
+ <div id="home_page_settings" class="panel-collapse collapse<% if index == 0 %> in<% end %>" role="tabpanel" aria-labelledby="heading<%= index + 1 %>">
11
+ <div class="panel-body">
12
+ <div role="tabpanel">
13
+ <ul class="nav nav-tabs" role="tablist">
14
+ <li role="presentation" class="active">
15
+ <a href="#home_page_settings_general" aria-controls="home_page_settings_general" role="tab" data-toggle="tab">
16
+ <%= t('settings.index.plugins.home_page.tabs.general.title') %>
17
+ </a>
18
+ </li>
19
+ <li role="presentation">
20
+ <a href="#home_page_settings_apis" aria-controls="home_page_settings_apis" role="tab" data-toggle="tab">
21
+ <%= t('settings.index.plugins.home_page.tabs.apis.title') %>
22
+ </a>
23
+ </li>
24
+ </ul>
25
+ <div class="tab-content">
26
+ <div role="tabpanel" class="tab-pane active" id="home_page_settings_general">
27
+ <p>
28
+ <%= setting_input f, 'home_page.general.navigation.items' %>
29
+ <%= setting_input f, 'home_page.general.enabled_apis' %>
30
+ <%= setting_input f, 'home_page.general.partial_paths' %>
31
+ </p>
32
+ </div>
33
+ <div role="tabpanel" class="tab-pane" id="home_page_settings_apis">
34
+ <p>
35
+ <%= render partial: "settings/plugins/home_page/tabs/apis", locals: { f: f } %>
36
+ </p>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ </div>
41
+ </div>
42
+ </div>
@@ -0,0 +1,24 @@
1
+ <div role="tabpanel">
2
+ <ul class="nav nav-tabs" role="tablist">
3
+ <% Setting['home_page.general.plugins'].each_with_index do |plugin, index| %>
4
+ <% next if (Setting["#{plugin}.general.available_apis"] || []).none? %>
5
+ <li role="presentation"<% if index == 0 %> class="active"<% end %>>
6
+ <% id = "home_page_settings_#{plugin == 'home_page' ? 'core' : plugin}_apis" %>
7
+ <a href="#<%= id %>" aria-controls="<%= id %>" role="tab" data-toggle="tab">
8
+ <%= t("settings.index.plugins.#{plugin}.index.title") %>
9
+ </a>
10
+ </li>
11
+ <% end %>
12
+ </ul>
13
+ <div class="tab-content">
14
+ <% Setting['home_page.general.plugins'].each_with_index do |plugin, index| %>
15
+ <% next if (Setting["#{plugin}.general.available_apis"] || []).none? %>
16
+ <% id = "home_page_settings_#{plugin == 'home_page' ? 'core' : plugin}_apis" %>
17
+ <div role="tabpanel" class="tab-pane<% if index == 0 %> active<% end %>" id="<%= id %>">
18
+ <p>
19
+ <%= render partial: 'settings/apis', locals: { f: f, plugin: plugin } %>
20
+ </p>
21
+ </div>
22
+ <% end %>
23
+ </div>
24
+ </div>
@@ -0,0 +1,50 @@
1
+ <% message = flash[:notice] || flash[:alert] %>
2
+ <% flash.delete(:notice); flash.delete(:alert) %>
3
+ <% alert = message.present? ? "alert('#{message}');" : '' %>
4
+
5
+ <% if @path.present? %>
6
+ <% if @template_format == 'html' %>
7
+ $.ajax({ url: "<%= @path %>", data: <%= raw @data.to_json %>, type: "<%= @method.to_s.upcase %>", dataType: "html"}).done(function(data) {
8
+ $("<%= @target %>").html(data);
9
+ <%= raw alert %>
10
+ <% if @close_modal %>$('#modal').modal('hide');<% end %>
11
+ })
12
+ .fail(function(data) {
13
+ <%= raw alert %>
14
+ alert("Failed to load <%= @path %>!");
15
+ <% if @close_modal %>$('#modal').modal('hide');<% end %>
16
+ });
17
+ <% else %>
18
+ $.ajax({ url: "<%= @path %>", data: <%= raw @data.to_json %>, type: "<%= @method.to_s.upcase %>", dataType: "script"}).done(function(data) {
19
+ eval(data);
20
+ <%= raw alert %>
21
+ <% if @close_modal %>$('#modal').modal('hide');<% end %>
22
+ })
23
+ .fail(function(data) {
24
+ <%= raw alert %>
25
+ alert("Failed to load <%= @path %>!");
26
+ <% if @close_modal %>$('#modal').modal('hide');<% end %>
27
+ });
28
+ <% end %>
29
+ <% elsif @template.present? %>
30
+ <% if @template_format == 'html' %>
31
+ <% if @target_needs_modal_layout %>
32
+ $("<%= @target %>").html("<%= escape_javascript(
33
+ render(
34
+ partial: 'shared/layouts/modal',
35
+ locals: { title: @modal_title, body: render(template: "#{@template_namespace}/#{@template}.html") }
36
+ )
37
+ ) %>");
38
+ <% else %>
39
+ $("<%= @target %>").html("<%= escape_javascript render(template: "#{@template_namespace}/#{@template}.html") %>");
40
+ <% if @close_modal %>$('#modal').modal('hide');<% end %>
41
+ <% end %>
42
+ <% elsif @template_format == 'js' %>
43
+ <%= render template: "#{@template_namespace}/#{@template}.js" %>
44
+ <% if @close_modal %>$('#modal').modal('hide');<% end %>
45
+ <% end %>
46
+ <%= raw alert %>
47
+ <% elsif message.present? %>
48
+ <%= raw alert %>
49
+ <% if @close_modal %>$('#modal').modal('hide');<% end %>
50
+ <% end %>