sibu 0.9.5 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) 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/stylesheets/sibu/defaults.scss +72 -80
  5. data/app/assets/stylesheets/sibu/sibu.css +8 -0
  6. data/app/controllers/sibu/application_controller.rb +8 -0
  7. data/app/controllers/sibu/pages_controller.rb +4 -3
  8. data/app/controllers/sibu/sites_controller.rb +1 -0
  9. data/app/helpers/sibu/pages_helper.rb +61 -12
  10. data/app/models/sibu/page.rb +0 -1
  11. data/app/models/sibu/site.rb +7 -0
  12. data/app/models/sibu/site_template.rb +1 -1
  13. data/app/views/layouts/sibu/edit_content.html.erb +189 -117
  14. data/app/views/sibu/images/edit.js.erb +5 -3
  15. data/app/views/sibu/pages/_code_edit_panel.html.erb +2 -2
  16. data/app/views/sibu/pages/_link_edit_panel.html.erb +6 -6
  17. data/app/views/sibu/pages/_map_edit_panel.html.erb +2 -2
  18. data/app/views/sibu/pages/_media_edit_panel.html.erb +2 -2
  19. data/app/views/sibu/pages/_new_section_panel.html.erb +1 -1
  20. data/app/views/sibu/pages/_paragraph_edit_panel.html.erb +2 -2
  21. data/app/views/sibu/pages/_text_edit_panel.html.erb +2 -2
  22. data/app/views/sibu/pages/child_element.js.erb +2 -2
  23. data/app/views/sibu/pages/clone_element.js.erb +2 -2
  24. data/app/views/sibu/pages/create_section.js.erb +1 -1
  25. data/app/views/sibu/pages/delete_element.js.erb +1 -1
  26. data/app/views/sibu/pages/delete_section.js.erb +1 -1
  27. data/app/views/sibu/pages/edit_element.js.erb +68 -66
  28. data/app/views/sibu/pages/edit_section.js.erb +6 -5
  29. data/app/views/sibu/pages/index.html.erb +1 -1
  30. data/app/views/sibu/pages/new_section.js.erb +22 -13
  31. data/app/views/sibu/pages/update_element.js.erb +2 -2
  32. data/app/views/sibu/pages/update_section.js.erb +3 -3
  33. data/db/migrate/20200401130601_add_ref_to_site_templates.rb +5 -0
  34. data/lib/sibu/engine.rb +0 -2
  35. data/lib/sibu/version.rb +1 -1
  36. metadata +3 -18
  37. data/app/views/sibu/pages/destroy.html.erb +0 -2
  38. data/app/views/sibu/pages/update.html.erb +0 -2
@@ -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,
@@ -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";
@@ -31,7 +31,7 @@
31
31
  <% end %>
32
32
  <% if @pages.empty? %>
33
33
  <tr>
34
- <td colspan="4">Aucune page créée pour le moment.</td>
34
+ <td colspan="5">Aucune page créée pour le moment.</td>
35
35
  </tr>
36
36
  <% end %>
37
37
  </tbody>
@@ -1,16 +1,25 @@
1
- var sectionsPanel = $("#sections_panel");
2
- if (sectionsPanel.size()) {
3
- sectionsPanel.html("<%= j(render 'new_section_panel') %>");
4
- van11yAccessibleTabPanelAria($(".sibu_sections_tabs")[0]);
5
- var sections = sectionsPanel.find(".sibu_sections [data-sb-template]");
6
- sections.click(function() {
7
- if(!$(this).hasClass('selected')) {
8
- sections.removeClass('selected');
9
- $(this).addClass('selected');
10
- $("#section_template").val($(this).data("sb-template"));
11
- $("#section_category").val($(this).data("sb-category"));
12
- }
13
- });
1
+ var sectionsPanel = document.querySelector("#sections_panel");
2
+ if (sectionsPanel) {
3
+ sectionsPanel.innerHTML = "<%= j(render 'new_section_panel') %>";
4
+ try {
5
+ sibuVan11yAccessibleTabPanelAria(document.querySelector(".sibu_sections_tabs"));
6
+ } catch (e) {
7
+ console.log('Sibu sections - Tabs init error : ' + e);
8
+ }
9
+ var sections = sectionsPanel.querySelectorAll(".sibu_sections [data-sb-template]");
10
+ for (var i = 0; i < sections.length; i++) {
11
+ sections[i].addEventListener("click", function(evt) {
12
+ if(!evt.currentTarget.classList.contains('selected')) {
13
+ var selected = sectionsPanel.querySelector(".sibu_sections [data-sb-template].selected");
14
+ if (selected) {
15
+ selected.classList.remove('selected');
16
+ }
17
+ evt.currentTarget.classList.add('selected');
18
+ document.querySelector("#section_template").value = evt.currentTarget.getAttribute('data-sb-template');
19
+ document.querySelector("#section_category").value = evt.currentTarget.getAttribute('data-sb-category');
20
+ }
21
+ });
22
+ }
14
23
  if(typeof initSectionsForm === "function") {
15
24
  initSectionsForm();
16
25
  }
@@ -1,6 +1,6 @@
1
1
  <% if @updated.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 @updated %>
2
- $("#edit_panel").slideUp();
3
- refreshAfterEdit(true, '<%= @section_id %>');
2
+ document.querySelector("#edit_panel").classList.remove("active");
3
+ refreshAfterEdit(true, '<%= @section_id %>');
4
4
  <% else %>
5
- $("#edit_panel #edit_msg").html("<p class='sibu_alert'>Une erreur s'est produite lors de l'enregistrement.</p>");
5
+ document.querySelector("#edit_panel #edit_msg").innerHTML = "<p class='sibu_alert'>Une erreur s'est produite lors de l'enregistrement.</p>";
6
6
  <% end %>