sibu 0.9.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/sibu/sibu.js.erb +17 -3
  3. data/app/assets/javascripts/tabs/van11y-accessible-tab-panel-aria.js +122 -124
  4. data/app/assets/javascripts/tarteaucitron/advertising.js +1 -0
  5. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.cs.js +75 -0
  6. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.de.js +75 -0
  7. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.el.js +75 -0
  8. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.en.js +75 -0
  9. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.es.js +75 -0
  10. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.fr.js +75 -0
  11. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.it.js +75 -0
  12. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.nl.js +75 -0
  13. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.pl.js +76 -0
  14. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.pt.js +73 -0
  15. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.ru.js +75 -0
  16. data/app/assets/javascripts/tarteaucitron/tarteaucitron.js.erb +1480 -0
  17. data/app/assets/javascripts/tarteaucitron/tarteaucitron.services.js +2627 -0
  18. data/app/assets/stylesheets/sibu/defaults.scss +118 -61
  19. data/app/assets/stylesheets/sibu/sibu.css +8 -0
  20. data/app/assets/stylesheets/tarteaucitron/tarteaucitron.css +749 -0
  21. data/app/controllers/sibu/application_controller.rb +8 -0
  22. data/app/controllers/sibu/pages_controller.rb +4 -3
  23. data/app/controllers/sibu/sites_controller.rb +4 -0
  24. data/app/helpers/sibu/pages_helper.rb +89 -25
  25. data/app/models/sibu/page.rb +3 -3
  26. data/app/models/sibu/site.rb +15 -1
  27. data/app/models/sibu/site_template.rb +4 -1
  28. data/app/views/layouts/sibu/edit_content.html.erb +176 -119
  29. data/app/views/layouts/sibu/site.html.erb +42 -6
  30. data/app/views/sibu/images/edit.js.erb +5 -3
  31. data/app/views/sibu/pages/_code_edit_panel.html.erb +2 -2
  32. data/app/views/sibu/pages/_link_edit_panel.html.erb +6 -6
  33. data/app/views/sibu/pages/_map_edit_panel.html.erb +2 -2
  34. data/app/views/sibu/pages/_media_edit_panel.html.erb +6 -6
  35. data/app/views/sibu/pages/_new_section_panel.html.erb +1 -1
  36. data/app/views/sibu/pages/_paragraph_edit_panel.html.erb +2 -2
  37. data/app/views/sibu/pages/_text_edit_panel.html.erb +2 -2
  38. data/app/views/sibu/pages/child_element.js.erb +2 -2
  39. data/app/views/sibu/pages/clone_element.js.erb +2 -2
  40. data/app/views/sibu/pages/create_section.js.erb +1 -1
  41. data/app/views/sibu/pages/delete_element.js.erb +1 -1
  42. data/app/views/sibu/pages/delete_section.js.erb +1 -1
  43. data/app/views/sibu/pages/edit_element.js.erb +68 -66
  44. data/app/views/sibu/pages/edit_section.js.erb +6 -5
  45. data/app/views/sibu/pages/index.html.erb +1 -1
  46. data/app/views/sibu/pages/new_section.js.erb +22 -13
  47. data/app/views/sibu/pages/update_element.js.erb +2 -2
  48. data/app/views/sibu/pages/update_section.js.erb +3 -3
  49. data/config/initializers/assets.rb +1 -0
  50. data/config/initializers/constants.rb +5 -3
  51. data/config/routes.rb +3 -0
  52. data/db/migrate/20200401130601_add_ref_to_site_templates.rb +5 -0
  53. data/lib/sibu/engine.rb +0 -2
  54. data/lib/sibu/version.rb +1 -1
  55. metadata +19 -18
  56. data/app/views/sibu/pages/destroy.html.erb +0 -2
  57. data/app/views/sibu/pages/update.html.erb +0 -2
@@ -10,12 +10,48 @@
10
10
  <%= stylesheet_link_tag (conf[:custom_styles] ? @site.style_url : @site.site_template.path), media: "all" %>
11
11
  <%= javascript_include_tag @site.site_template.path %>
12
12
  <% unless @site.analytics_id.blank? %>
13
- <script async src="https://www.googletagmanager.com/gtag/js?id=<%= @site.analytics_id %>"></script>
14
- <script>
15
- window.dataLayer = window.dataLayer || [];
16
- function gtag(){dataLayer.push(arguments);}
17
- gtag('js', new Date());
18
- gtag('config', '<%= @site.analytics_id %>');
13
+ <%= stylesheet_link_tag 'tarteaucitron/tarteaucitron' %>
14
+ <%= javascript_include_tag 'tarteaucitron/tarteaucitron' %>
15
+ <script type="text/javascript">
16
+ var defaultOpts = {
17
+ "privacyUrl": "", /* Privacy policy url */
18
+ "hashtag": "#tarteaucitron", /* Open the panel with this hashtag */
19
+ "cookieName": "tarteaucitron", /* Cookie name */
20
+ "orientation": "bottom", /* Banner position (top - bottom) */
21
+ "showAlertSmall": false, /* Show the small banner on bottom right */
22
+ "cookieslist": true, /* Show the cookie list */
23
+ "adblocker": false, /* Show a Warning if an adblocker is detected */
24
+ "AcceptAllCta": true, /* Show the accept all button when highPrivacy on */
25
+ "highPrivacy": false, /* Disable auto consent */
26
+ "handleBrowserDNTRequest": false, /* If Do Not Track == 1, disallow all */
27
+ "removeCredit": false, /* Remove credit link */
28
+ "moreInfoLink": true, /* Show more info link */
29
+ "useExternalCss": true, /* If false, the tarteaucitron.css file will be loaded */
30
+ "readmoreLink": "/cookiespolicy" /* Change the default readmore link */
31
+ };
32
+ if (typeof tarteaucitronOpts === 'undefined') {
33
+ var tarteaucitronOpts = defaultOpts;
34
+ } else {
35
+ tarteaucitronOpts["hashtag"] = "#tarteaucitron";
36
+ tarteaucitronOpts["cookieName"] = "tarteaucitron";
37
+ tarteaucitronOpts["orientation"] = tarteaucitronOpts["orientation"] || "top";
38
+ tarteaucitronOpts["showAlertSmall"] = !(tarteaucitronOpts["showAlertSmall"] === false);
39
+ tarteaucitronOpts["cookieslist"] = !(tarteaucitronOpts["cookieslist"] === false);
40
+ tarteaucitronOpts["adblocker"] = tarteaucitronOpts["adblocker"] === true;
41
+ tarteaucitronOpts["AcceptAllCta"] = tarteaucitronOpts["AcceptAllCta"] === true;
42
+ tarteaucitronOpts["highPrivacy"] = !(tarteaucitronOpts["AcceptAllCta"] === false);
43
+ tarteaucitronOpts["handleBrowserDNTRequest"] = !(tarteaucitronOpts["handleBrowserDNTRequest"] === false);
44
+ tarteaucitronOpts["removeCredit"] = !(tarteaucitronOpts["removeCredit"] === false);
45
+ tarteaucitronOpts["moreInfoLink"] = tarteaucitronOpts["moreInfoLink"] === true;
46
+ tarteaucitronOpts["useExternalCss"] = !(tarteaucitronOpts["useExternalCss"] === false);
47
+ tarteaucitronOpts["cookieDomain"] = "<%= @site.domain %>";
48
+ }
49
+ tarteaucitron.init(tarteaucitronOpts);
50
+ </script>
51
+ <script type="text/javascript">
52
+ tarteaucitron.user.analyticsUa = '<%= @site.analytics_id %>';
53
+ tarteaucitron.user.analyticsMore = function () { };
54
+ (tarteaucitron.job = tarteaucitron.job || []).push('analytics');
19
55
  </script>
20
56
  <% end %>
21
57
  <% end %>
@@ -1,3 +1,5 @@
1
- $(".sibu_edit_image").html("<%= j(render 'edit_form') %>");
2
- $(".sibu_image").removeClass("selected");
3
- $("<%= "#sibu_image_#{@image.id}" %>").addClass("selected");
1
+ document.querySelector(".sibu_edit_image").innerHTML = "<%= j(render 'edit_form') %>";
2
+ if (document.querySelector(".sibu_image.selected")) {
3
+ document.querySelector(".sibu_image.selected").classList.remove("selected");
4
+ }
5
+ document.querySelector("<%= "#sibu_image_#{@image.id}" %>").classList.add("selected");
@@ -1,7 +1,7 @@
1
1
  <h2>Modifier le contenu</h2>
2
2
  <div id="edit_msg"></div>
3
3
  <div class="sibu_edit_form">
4
- <%= form_tag(update_element_site_page_path(@site.id, @page.id), method: :patch, remote: true) do |f| %>
4
+ <form class="edit_element_form" action="<%= update_element_site_page_path(@site.id, @page.id, format: :js) %>" accept-charset="UTF-8" method="patch">
5
5
  <div class="sibu_field">
6
6
  <%= label_tag 'element[code]', "Code d'intégration du contenu" %>
7
7
  <%= text_area_tag 'element[code]', @element["code"], placeholder: ' ex: <iframe src="..."></iframe>' %>
@@ -14,5 +14,5 @@
14
14
  <%= submit_tag 'Valider' %>
15
15
  <%= link_to 'Annuler', '#', onclick: 'cancelEdit(); return false;' %>
16
16
  </div>
17
- <% end %>
17
+ </form>
18
18
  </div>
@@ -2,32 +2,32 @@
2
2
  <div id="edit_msg"></div>
3
3
  <%= render 'element_actions' %>
4
4
  <div class="sibu_edit_form">
5
- <%= form_tag(update_element_site_page_path(@site.id, @page.id), method: :patch, remote: true) do |f| %>
5
+ <form class="edit_element_form" action="<%= update_element_site_page_path(@site.id, @page.id, format: :js) %>" accept-charset="UTF-8" method="patch">
6
6
  <% current_type = link_type(@element["value"]) %>
7
7
  <div class="sibu_field">
8
8
  <%= label_tag 'element[text]', 'Libellé' %>
9
9
  <%= text_field_tag 'element[text]', @element["text"] %>
10
10
  </div>
11
11
  <div id="link_internal" class="sibu_field link_mode">
12
- <%= radio_button_tag :mode, 'internal', current_type == 'internal', class: 'radio' %>
12
+ <%= radio_button_tag :mode, 'internal', current_type == 'internal', class: 'radio', onclick: 'setLinkMode(this)' %>
13
13
  <%= label_tag 'mode_internal', 'Lien vers une page du site' %>
14
14
  <%= select_tag 'element[value]', available_links, prompt: 'Sélectionnez une page', disabled: current_type != 'internal' %>
15
15
  <%= hidden_field_tag 'element[target]', '_self', disabled: current_type != 'internal' %>
16
16
  </div>
17
17
  <div id="link_external" class="sibu_field link_mode">
18
- <%= radio_button_tag :mode, 'external', current_type == 'external', class: 'radio' %>
18
+ <%= radio_button_tag :mode, 'external', current_type == 'external', class: 'radio', onclick: 'setLinkMode(this)' %>
19
19
  <%= label_tag 'mode_external', 'Lien personnalisé' %>
20
20
  <%= text_field_tag 'element[value]', (@element["value"] if current_type == 'external'), placeholder: 'Ex : http://www.un-site.com', disabled: current_type != 'external' %>
21
21
  <%= hidden_field_tag 'element[target]', '_blank', disabled: current_type != 'external' %>
22
22
  </div>
23
23
  <div id="link_email" class="sibu_field link_mode">
24
- <%= radio_button_tag :mode, 'email', current_type == 'email', class: 'radio' %>
24
+ <%= radio_button_tag :mode, 'email', current_type == 'email', class: 'radio', onclick: 'setLinkMode(this)' %>
25
25
  <%= label_tag 'mode_external', 'Lien vers un Email' %>
26
26
  <%= text_field_tag 'element[value]', (@element["value"] if current_type == 'email'), placeholder: 'Ex : email@exemple.fr', disabled: current_type != 'email' %>
27
27
  <%= hidden_field_tag 'element[target]', '_blank', disabled: current_type != 'email' %>
28
28
  </div>
29
29
  <div id="link_document" class="sibu_field link_mode">
30
- <%= radio_button_tag :mode, 'document', current_type == 'document', class: 'radio' %>
30
+ <%= radio_button_tag :mode, 'document', current_type == 'document', class: 'radio', onclick: 'setLinkMode(this)' %>
31
31
  <%= label_tag 'mode_document', 'Lien vers un document' %>
32
32
  <%= select_tag 'element[value]', available_docs, prompt: 'Sélectionnez un document', disabled: current_type != 'document' %>
33
33
  <%= hidden_field_tag 'element[target]', '_blank', disabled: current_type != 'document' %>
@@ -46,5 +46,5 @@
46
46
  <%= submit_tag 'Valider' %>
47
47
  <%= link_to 'Annuler', '#', onclick: 'cancelEdit(); return false;' %>
48
48
  </div>
49
- <% end %>
49
+ </form>
50
50
  </div>
@@ -1,7 +1,7 @@
1
1
  <h2>Modifier la carte</h2>
2
2
  <div id="edit_msg"></div>
3
3
  <div class="sibu_edit_form">
4
- <%= form_tag(update_element_site_page_path(@site.id, @page.id), method: :patch, remote: true) do |f| %>
4
+ <form class="edit_element_form" action="<%= update_element_site_page_path(@site.id, @page.id, format: :js) %>" accept-charset="UTF-8" method="patch">
5
5
  <div class="sibu_field">
6
6
  <%= label_tag 'element[data-lat]', 'Latitude' %>
7
7
  <%= text_field_tag 'element[data-lat]', @element["data-lat"] %>
@@ -23,5 +23,5 @@
23
23
  <%= submit_tag 'Valider' %>
24
24
  <%= link_to 'Annuler', '#', onclick: 'cancelEdit(); return false;' %>
25
25
  </div>
26
- <% end %>
26
+ </form>
27
27
  </div>
@@ -2,7 +2,7 @@
2
2
  <div id="edit_msg"></div>
3
3
  <%= render 'element_actions' %>
4
4
  <div class="sibu_edit_form">
5
- <%= form_tag(update_element_site_page_path(@site.id, @page.id), method: :patch, remote: true) do |f| %>
5
+ <form class="edit_element_form" action="<%= update_element_site_page_path(@site.id, @page.id, format: :js) %>" accept-charset="UTF-8" method="patch">
6
6
  <div class="sibu_image_selection">
7
7
  <div class="sibu_select_images sibu_field">
8
8
  <p>Sélectionnez ou <%= link_to 'téléchargez', new_image_path(page_id: @page.id, section_id: @section_id, entity_type: @entity_type,
@@ -32,19 +32,19 @@
32
32
  </table>
33
33
  </div>
34
34
  <div class="sibu_selected_image">
35
- <% if @element["src"] == DEFAULT_IMG || @element["src"].blank? %>
35
+ <% if @element["src"] == Sibu::DEFAULT_IMG || @element["src"].blank? %>
36
36
  <p>Veuillez sélectionner une image.</p>
37
37
  <% end %>
38
- <div class="sibu_custom_center" style="display: <%= (@element["src"] == DEFAULT_IMG || @element["src"].blank?) ? 'none' : 'block' %>">
38
+ <div class="sibu_custom_center" style="display: <%= (@element["src"] == Sibu::DEFAULT_IMG || @element["src"].blank?) ? 'none' : 'block' %>">
39
39
  <%= check_box_tag('custom_center', true, (!@element["class"].blank? && @element["class"].include?('posx')), id: 'custom_center', class: 'checkbox') %>
40
40
  <%= label_tag 'custom_center', "Recentrer l'image" %>
41
41
  </div>
42
42
  <div class="sibu_center">
43
- <%= image_tag(@element["src"]) unless @element["src"] == DEFAULT_IMG || @element["src"].blank? %>
43
+ <%= image_tag(@element["src"]) unless @element["src"] == Sibu::DEFAULT_IMG || @element["src"].blank? %>
44
44
  <div id="sibu_center_pos" style="display: none;">✕</div>
45
45
  <div id="sibu_center_desc" style="display: none;"><em>Cliquez sur l'image pour la recentrer sur un point donné (à utiliser lorsque l'image est tronquée car la zone d'affichage est trop petite).</em></div>
46
46
  </div>
47
- <div class="sibu_field" style="display: <%= (@element["src"] == DEFAULT_IMG || @element["src"].blank?) ? 'none' : 'block' %>">
47
+ <div class="sibu_field" style="display: <%= (@element["src"] == Sibu::DEFAULT_IMG || @element["src"].blank?) ? 'none' : 'block' %>">
48
48
  <%= label_tag 'element[alt]', 'Légende / texte alternatif' %>
49
49
  <%= text_field_tag 'element[alt]', @element["alt"] %>
50
50
  </div>
@@ -60,5 +60,5 @@
60
60
  <%= submit_tag 'Valider' %>
61
61
  <%= link_to 'Annuler', '#', onclick: 'cancelEdit(); return false;' %>
62
62
  </div>
63
- <% end %>
63
+ </form>
64
64
  </div>
@@ -19,7 +19,7 @@
19
19
  <h3 style="display: none;"><%= t "sibu.section.category.#{cat}" %></h3>
20
20
  <% sections.each do |st| %>
21
21
  <div data-sb-template="<%= st["template"] %>" data-sb-category="<%= st["category"] %>">
22
- <%= render "shared/#{@site.section_template(st)}", sec: st %>
22
+ <%= render_page_section st %>
23
23
  </div>
24
24
  <% end %>
25
25
  </div>
@@ -2,7 +2,7 @@
2
2
  <div id="edit_msg"></div>
3
3
  <%= render 'element_actions' %>
4
4
  <div class="sibu_edit_form">
5
- <%= form_tag(update_element_site_page_path(@site.id, @page.id), method: :patch, remote: true) do |f| %>
5
+ <form class="edit_element_form" action="<%= update_element_site_page_path(@site.id, @page.id, format: :js) %>" accept-charset="UTF-8" method="patch">
6
6
  <div id="editor-container"></div>
7
7
 
8
8
  <%= hidden_field_tag 'element[text]' %>
@@ -14,5 +14,5 @@
14
14
  <%= submit_tag 'Valider' %>
15
15
  <%= link_to 'Annuler', '#', onclick: 'cancelEdit(); return false;' %>
16
16
  </div>
17
- <% end %>
17
+ </form>
18
18
  </div>
@@ -2,7 +2,7 @@
2
2
  <div id="edit_msg"></div>
3
3
  <%= render 'element_actions' %>
4
4
  <div class="sibu_edit_form">
5
- <%= form_tag(update_element_site_page_path(@site.id, @page.id), method: :patch, remote: true) do |f| %>
5
+ <form class="edit_element_form" action="<%= update_element_site_page_path(@site.id, @page.id, format: :js) %>" accept-charset="UTF-8" method="patch">
6
6
  <div class="sibu_field">
7
7
  <%= label_tag 'element[text]', 'Texte' %>
8
8
  <%= text_field_tag 'element[text]', @element["text"] %>
@@ -15,5 +15,5 @@
15
15
  <%= submit_tag 'Valider' %>
16
16
  <%= link_to 'Annuler', '#', onclick: 'cancelEdit(); return false;' %>
17
17
  </div>
18
- <% end %>
18
+ </form>
19
19
  </div>
@@ -1,6 +1,6 @@
1
1
  <% if @added.nil? %>
2
- $("#edit_panel #edit_msg").html("<p class='sibu_alert'>Une erreur s'est produite lors de l'ajout du sous-menu.</p>");
2
+ document.querySelector("#edit_panel #edit_msg").innerHTML = "<p class='sibu_alert'>Une erreur s'est produite lors de l'ajout du sous-menu.</p>";
3
3
  <% else %>
4
- $("#edit_panel").slideUp();
4
+ document.querySelector("#edit_panel").classList.remove('active');
5
5
  location.reload(true);
6
6
  <% end %>
@@ -1,6 +1,6 @@
1
1
  <% if @cloned.nil? %>
2
- $("#edit_panel #edit_msg").html("<p class='sibu_alert'>Une erreur s'est produite lors de l'enregistrement.</p>");
2
+ document.querySelector("#edit_panel #edit_msg").innerHTML = "<p class='sibu_alert'>Une erreur s'est produite lors de l'enregistrement.</p>";
3
3
  <% else %>
4
- $("#edit_panel").slideUp();
4
+ document.querySelector("#edit_panel").classList.remove("active");
5
5
  refreshAfterEdit(true, '<%= @section_id %>');
6
6
  <% end %>
@@ -1,6 +1,6 @@
1
1
  <% if @created %>
2
2
  location.reload(true);
3
3
  <% else %>
4
- $("#edit_section_msg").html("<p class='sibu_alert'>Une erreur s'est produite lors de l'enregistrement.</p>");
4
+ document.querySelector("#edit_section_msg").innerHTML = "<p class='sibu_alert'>Une erreur s'est produite lors de l'enregistrement.</p>";
5
5
  <% end %>
6
6
 
@@ -1,6 +1,6 @@
1
1
  <% if @deleted %>
2
2
  refreshAfterEdit(true, '<%= @section_id %>');
3
3
  <% else %>
4
- $("#edit_section_msg").text("La suppression n'a pas pu être effectuée.");
4
+ document.querySelector("#edit_section_msg").innerHTML = "<p class='sibu_alert'>La suppression n'a pas pu être effectuée.</p>";
5
5
  <% end %>
6
6
 
@@ -1,6 +1,6 @@
1
1
  <% if @deleted %>
2
2
  location.reload(true);
3
3
  <% else %>
4
- $("#edit_section_msg").text("Une erreur s'est produite lors de la suppression.");
4
+ document.querySelector("#edit_section_msg").innerHTML = "<p class='sibu_alert'>Une erreur s'est produite lors de la suppression..</p>";
5
5
  <% end %>
6
6
 
@@ -1,105 +1,107 @@
1
- var editPanel = $("#edit_panel");
2
- editPanel.html("");
1
+ var editPanel = document.querySelector("#edit_panel");
2
+ editPanel.innerHTML = "";
3
+
3
4
  <% case @content_type %>
4
5
  <% when 'text' %>
5
- editPanel.html("<%= j(render 'text_edit_panel') %>");
6
+ editPanel.innerHTML = "<%= j(render 'text_edit_panel') %>";
6
7
  <% when 'embed' %>
7
- editPanel.html("<%= j(render 'code_edit_panel') %>");
8
+ editPanel.innerHTML = "<%= j(render 'code_edit_panel') %>";
8
9
  <% when 'paragraph' %>
9
- editPanel.html("<%= j(render 'paragraph_edit_panel') %>");
10
+ editPanel.innerHTML = "<%= j(render 'paragraph_edit_panel') %>";
10
11
  <% when 'media' %>
11
- editPanel.html("<%= j(render 'media_edit_panel') %>");
12
+ editPanel.innerHTML = "<%= j(render 'media_edit_panel') %>";
12
13
  <% when 'link' %>
13
- editPanel.html("<%= j(render 'link_edit_panel') %>");
14
+ editPanel.innerHTML = "<%= j(render 'link_edit_panel') %>";
14
15
  <% when 'group' %>
15
- editPanel.html("<%= j(render 'group_edit_panel') %>");
16
+ editPanel.innerHTML = "<%= j(render 'group_edit_panel') %>";
16
17
  <% when 'map' %>
17
- editPanel.html("<%= j(render 'map_edit_panel') %>");
18
+ editPanel.innerHTML = "<%= j(render 'map_edit_panel') %>";
18
19
  <% when /^widget/ %>
19
- editPanel.html("<%= j(render "shared/sibu/#{@content_type}_panel") %>");
20
+ editPanel.innerHTML = "<%= j(render "shared/sibu/#{@content_type}_panel") %>";
20
21
  <% else %>
21
- editPanel.html("<%= j(render 'error_panel') %>");
22
+ editPanel.innerHTML = "<%= j(render 'error_panel') %>";
22
23
  <% end %>
23
24
 
24
-
25
- editPanel.slideDown("fast", function() {
25
+ editPanel.classList.add("active");
26
+ setTimeout(function() {
26
27
  <% case @content_type %>
27
28
  <% when 'paragraph' %>
28
29
  var quill = initQuillEditor('#editor-container');
29
30
  quill.root.innerHTML = "<%= j(raw(@element["text"] || 'Texte à modifier')) %>";
30
31
  quill.on('text-change', function() {
31
- $("#element_text").val(quill.root.innerHTML);
32
- });
33
- var wrapper = $("[data-sb-id='<%= @section_id %>']").find("[data-id='<%= @element_id %>']");
34
- editPanel.find(".ql-editor").css({
35
- "font-family": wrapper.css("font-family"),
36
- "font-size": wrapper.css("font-size"),
37
- "color": wrapper.css("color"),
38
- "text-align": wrapper.css("text-align")
32
+ document.querySelector("#element_text").value = quill.root.innerHTML;
39
33
  });
34
+ var wrapper = document.querySelector("[data-sb-id='<%= @section_id %>'] [data-id='<%= @element_id %>']"),
35
+ editor = editPanel.querySelector(".ql-editor");
36
+ editor.style['font-family'] = wrapper.style['font-family'];
37
+ editor.style['font-size'] = wrapper.style['font-size'];
38
+ editor.style.color = wrapper.style.color;
39
+ editor.style['text-align'] = wrapper.style['text-align'];
40
40
  <% when 'media' %>
41
- var images = editPanel.find(".sibu_image");
42
- var customCenter = $("#custom_center");
43
- images.click(function() {
44
- if(!$(this).hasClass('selected')) {
45
- images.removeClass('selected');
46
- $(this).addClass('selected');
47
- var imgElt = $(this).find("img");
48
- $("#element_src").val(imgElt.data("src"));
49
- $("#element_alt").val(imgElt.data("alt"));
50
- editPanel.find(".sibu_center").html(
51
- '<img src="' + $("#element_src").val() + '"/>' +
52
- '<div id="sibu_center_pos" style="display: none;">✕</div>' +
53
- '<div id="sibu_center_desc" style="display: none;"><em>Cliquez sur l\'image pour la recentrer sur un point donné (à utiliser lorsque l\'image est tronquée car la zone d\'affichage est trop petite)</em></div>');
54
- editPanel.find(".sibu_selected_image > p:first-child").hide();
55
- editPanel.find(".sibu_selected_image").find(".sibu_custom_center").show();
56
- editPanel.find(".sibu_selected_image").find(".sibu_field").show();
57
- if(customCenter.is(":checked")) {
58
- customCenter.removeAttr("checked");
59
- $("#element_class").val("");
60
- $(".sibu_center").attr("style", "");
41
+ var images = editPanel.querySelectorAll(".sibu_image");
42
+ var customCenter = document.querySelector("#custom_center");
43
+ for (var i = 0; i < images.length; i++) {
44
+ images[i].addEventListener("click", function(evt) {
45
+ if(!evt.currentTarget.classList.contains('selected')) {
46
+ evt.currentTarget.classList.remove('selected');
47
+ evt.currentTarget.classList.add('selected');
48
+ var imgElt = evt.currentTarget.querySelector("img");
49
+ document.querySelector("#element_src").value = imgElt.getAttribute("data-src");
50
+ document.querySelector("#element_alt").value = imgElt.getAttribute("data-alt");
51
+ editPanel.querySelector(".sibu_center").innerHTML =
52
+ '<img src="' + $("#element_src").val() + '"/>' +
53
+ '<div id="sibu_center_pos" style="display: none;">✕</div>' +
54
+ '<div id="sibu_center_desc" style="display: none;"><em>Cliquez sur l\'image pour la recentrer sur un point donné (à utiliser lorsque l\'image est tronquée car la zone d\'affichage est trop petite)</em></div>';
55
+ editPanel.querySelector(".sibu_selected_image > p:first-child").style.display = "none";
56
+ editPanel.querySelector(".sibu_selected_image .sibu_custom_center").style.display = "block";
57
+ editPanel.querySelector(".sibu_selected_image .sibu_field").style.display = "";
58
+ if(customCenter.checked) {
59
+ customCenter.removeAttribute("checked");
60
+ document.querySelector("#element_class").value = "";
61
+ document.querySelector(".sibu_center").setAttribute("style", "");
62
+ }
61
63
  }
62
- }
63
- });
64
- if(editPanel.find(".sibu_center img").size() > 0) {
65
- if(customCenter.is(":checked")) {
64
+ })
65
+ }
66
+ if(editPanel.querySelectorAll(".sibu_center img").length > 0) {
67
+ if(customCenter.checked) {
66
68
  initCustomCenter("<%= @element_id %>");
67
69
  }
68
70
  }
69
- customCenter.change(function() {
70
- if($(this).is(":checked")) {
71
+ customCenter.onchange = function(evt) {
72
+ if(this.checked) {
71
73
  initCustomCenter("<%= @element_id %>");
72
74
  } else {
73
- $("#element_class").val("");
74
- $(".sibu_center").attr("style", "");
75
- $(".sibu_center > #sibu_center_pos").hide();
76
- $(".sibu_center > #sibu_center_desc").hide();
75
+ document.querySelector("#element_class").value = "";
76
+ document.querySelector(".sibu_center").setAttribute("style", "");
77
+ document.querySelector(".sibu_center > #sibu_center_pos").style.display = "none";
78
+ document.querySelector(".sibu_center > #sibu_center_desc").style.display = "none";
77
79
  }
78
- });
80
+ };
79
81
  <% when 'link' %>
80
- $("input[name='mode']").change(function() {
81
- var selected = $(this).val();
82
- $("#link_" + selected).find("#element_value, #element_target").removeAttr("disabled");
83
- $(".sibu_edit_form").find(".link_mode").each(function() {
84
- if($(this).attr("id") !== ("link_" + selected)) {
85
- $(this).find("#element_value, #element_target").attr("disabled", "disabled");
86
- }
87
- });
88
- });
89
82
  <% else %>
90
83
  <% end %>
91
84
 
92
85
  <% if @repeat %>
93
- $("#clone_elt, #duplicate_elt").show();
86
+ document.querySelector("#clone_elt").style.display = "inline-block";
87
+ document.querySelector("#duplicate_elt").style.display = "inline-block";
94
88
  <% else %>
95
- $("#clone_elt, #duplicate_elt").remove();
89
+ document.querySelector("#clone_elt").remove();
90
+ document.querySelector("#duplicate_elt").remove();
96
91
  <% end %>
97
92
 
98
93
  <% if @children %>
99
- $("#child_elt").show();
94
+ document.querySelector("#child_elt").style.display = "inline-block";
100
95
  <% else %>
101
- $("#child_elt").remove();
96
+ document.querySelector("#child_elt").remove();
102
97
  <% end %>
98
+ var formElt = document.querySelector("form.edit_element_form");
99
+ if (formElt) {
100
+ formElt.onsubmit = function(evt) {
101
+ evt.preventDefault();
102
+ submitForm(formElt);
103
+ }
104
+ }
103
105
  sibuCallback("editElement", "<%= @content_type %>");
104
- });
106
+ }, 500);
105
107
  document.body.style.overflow = "hidden";
@@ -1,7 +1,8 @@
1
- var editPanel = $("#edit_panel");
2
- editPanel.html("");
3
- editPanel.html("<%= j(render conf[:section_form]) %>");
4
- editPanel.slideDown("fast", function() {
1
+ var editPanel = document.querySelector("#edit_panel");
2
+ editPanel.innerHTML = "";
3
+ editPanel.innerHTML = "<%= j(render conf[:section_form]) %>";
4
+ editPanel.classList.add("active");
5
+ setTimeout(function() {
5
6
  sibuCallback("editSection");
6
- });
7
+ }, 500);
7
8
  document.body.style.overflow = "hidden";