sibu 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -20
  3. data/README.md +38 -38
  4. data/Rakefile +36 -36
  5. data/app/assets/config/sibu_manifest.js +2 -2
  6. data/app/assets/fonts/sibu/Sibu.eot +0 -0
  7. data/app/assets/fonts/sibu/Sibu.svg +13 -13
  8. data/app/assets/fonts/sibu/Sibu.ttf +0 -0
  9. data/app/assets/fonts/sibu/Sibu.woff +0 -0
  10. data/app/assets/javascripts/cropper/cropper.js +3694 -3694
  11. data/app/assets/javascripts/quill/quill.js +11401 -11401
  12. data/app/assets/javascripts/sibu/common.js +6 -6
  13. data/app/assets/javascripts/sibu/sibu.js.erb +155 -155
  14. data/app/assets/javascripts/tabs/van11y-accessible-tab-panel-aria.js +465 -465
  15. data/app/assets/stylesheets/cropper/cropper.css +304 -304
  16. data/app/assets/stylesheets/quill/quill.snow.css +945 -945
  17. data/app/assets/stylesheets/sibu/defaults.scss +336 -336
  18. data/app/assets/stylesheets/sibu/icons.scss +40 -40
  19. data/app/assets/stylesheets/sibu/sibu.css +131 -131
  20. data/app/controllers/sibu/application_controller.rb +14 -14
  21. data/app/controllers/sibu/documents_controller.rb +35 -35
  22. data/app/controllers/sibu/images_controller.rb +78 -78
  23. data/app/controllers/sibu/pages_controller.rb +197 -197
  24. data/app/controllers/sibu/sites_controller.rb +81 -81
  25. data/app/helpers/sibu/application_helper.rb +11 -11
  26. data/app/helpers/sibu/documents_helper.rb +4 -4
  27. data/app/helpers/sibu/images_helper.rb +4 -4
  28. data/app/helpers/sibu/pages_helper.rb +194 -194
  29. data/app/helpers/sibu/sites_helper.rb +23 -23
  30. data/app/jobs/sibu/application_job.rb +4 -4
  31. data/app/mailers/sibu/application_mailer.rb +6 -6
  32. data/app/models/concerns/sibu/document_uploader.rb +8 -8
  33. data/app/models/concerns/sibu/image_uploader.rb +31 -31
  34. data/app/models/concerns/sibu/sections_concern.rb +134 -134
  35. data/app/models/concerns/sibu/style_uploader.rb +1 -1
  36. data/app/models/concerns/sibu/user_concern.rb +8 -8
  37. data/app/models/sibu/application_record.rb +5 -5
  38. data/app/models/sibu/document.rb +16 -16
  39. data/app/models/sibu/dynamic_style.rb +76 -76
  40. data/app/models/sibu/image.rb +10 -19
  41. data/app/models/sibu/page.rb +66 -66
  42. data/app/models/sibu/site.rb +97 -97
  43. data/app/models/sibu/site_template.rb +22 -22
  44. data/app/views/layouts/sibu/application.html.erb +23 -23
  45. data/app/views/layouts/sibu/edit_content.html.erb +262 -262
  46. data/app/views/layouts/sibu/site.html.erb +45 -45
  47. data/app/views/sibu/documents/_form.html.erb +14 -14
  48. data/app/views/sibu/documents/index.html.erb +37 -37
  49. data/app/views/sibu/documents/new.html.erb +12 -12
  50. data/app/views/sibu/images/_edit_form.html.erb +23 -23
  51. data/app/views/sibu/images/_form.html.erb +34 -34
  52. data/app/views/sibu/images/edit.js.erb +2 -2
  53. data/app/views/sibu/images/index.html.erb +31 -13
  54. data/app/views/sibu/images/new.html.erb +12 -12
  55. data/app/views/sibu/images/show.html.erb +2 -2
  56. data/app/views/sibu/pages/_code_edit_panel.html.erb +17 -17
  57. data/app/views/sibu/pages/_element_actions.html.erb +4 -4
  58. data/app/views/sibu/pages/_error_panel.html.erb +4 -4
  59. data/app/views/sibu/pages/_form.html.erb +62 -62
  60. data/app/views/sibu/pages/_group_edit_panel.html.erb +3 -3
  61. data/app/views/sibu/pages/_link_edit_panel.html.erb +50 -50
  62. data/app/views/sibu/pages/_map_edit_panel.html.erb +27 -27
  63. data/app/views/sibu/pages/_media_edit_panel.html.erb +46 -46
  64. data/app/views/sibu/pages/_new_section_panel.html.erb +43 -43
  65. data/app/views/sibu/pages/_paragraph_edit_panel.html.erb +18 -18
  66. data/app/views/sibu/pages/_text_edit_panel.html.erb +19 -19
  67. data/app/views/sibu/pages/child_element.js.erb +6 -6
  68. data/app/views/sibu/pages/clone_element.js.erb +6 -6
  69. data/app/views/sibu/pages/create_section.js.erb +6 -6
  70. data/app/views/sibu/pages/delete_element.js.erb +6 -6
  71. data/app/views/sibu/pages/delete_section.js.erb +6 -6
  72. data/app/views/sibu/pages/destroy.html.erb +2 -2
  73. data/app/views/sibu/pages/edit.html.erb +8 -8
  74. data/app/views/sibu/pages/edit_content.html.erb +3 -3
  75. data/app/views/sibu/pages/edit_element.js.erb +100 -100
  76. data/app/views/sibu/pages/edit_section.js.erb +7 -7
  77. data/app/views/sibu/pages/index.html.erb +40 -40
  78. data/app/views/sibu/pages/new.html.erb +8 -8
  79. data/app/views/sibu/pages/new_section.js.erb +19 -19
  80. data/app/views/sibu/pages/show.html.erb +3 -3
  81. data/app/views/sibu/pages/update.html.erb +2 -2
  82. data/app/views/sibu/pages/update_element.js.erb +5 -5
  83. data/app/views/sibu/pages/update_section.js.erb +5 -5
  84. data/app/views/sibu/sites/_form.html.erb +125 -125
  85. data/app/views/sibu/sites/destroy.html.erb +2 -2
  86. data/app/views/sibu/sites/edit.html.erb +9 -9
  87. data/app/views/sibu/sites/edit_styles.html.erb +8 -8
  88. data/app/views/sibu/sites/index.html.erb +41 -41
  89. data/app/views/sibu/sites/new.html.erb +18 -18
  90. data/app/views/sibu/sites/update.html.erb +2 -2
  91. data/config/initializers/constants.rb +2 -2
  92. data/config/initializers/shrine.rb +18 -18
  93. data/config/routes.rb +30 -30
  94. data/config/tinymce.yml +5 -5
  95. data/db/migrate/20180124095041_create_sibu_sites.rb +12 -12
  96. data/db/migrate/20180124095213_create_sibu_pages.rb +15 -15
  97. data/db/migrate/20180124145030_create_sibu_site_templates.rb +10 -10
  98. data/db/migrate/20180125231638_add_user_id_to_sites.rb +5 -5
  99. data/db/migrate/20180126114522_rename_url_to_path_in_pages.rb +5 -5
  100. data/db/migrate/20180126114628_add_domain_to_sites.rb +5 -5
  101. data/db/migrate/20180127211533_create_sibu_images.rb +11 -11
  102. data/db/migrate/20180208082317_rename_images_user_id_to_site_id.rb +5 -5
  103. data/db/migrate/20180208125024_rename_image_data_column.rb +5 -5
  104. data/db/migrate/20180210181644_add_defaults_to_site_templates.rb +6 -6
  105. data/db/migrate/20180214134653_add_fields_to_sites.rb +5 -5
  106. data/db/migrate/20180227151519_add_default_templates_to_site_templates.rb +5 -5
  107. data/db/migrate/20180301121902_add_style_data_to_sites.rb +5 -5
  108. data/db/migrate/20180301152101_add_default_styles_to_templates.rb +5 -5
  109. data/db/migrate/20180321144021_move_images_to_user_level.rb +7 -7
  110. data/db/migrate/20180321170310_add_version_to_sibu_sites.rb +7 -7
  111. data/db/migrate/20180405095448_create_sibu_documents.rb +10 -10
  112. data/db/migrate/20190110204854_add_custom_data_to_sibu_pages.rb +5 -5
  113. data/lib/sibu.rb +4 -4
  114. data/lib/sibu/engine.rb +19 -19
  115. data/lib/sibu/utils.rb +14 -14
  116. data/lib/sibu/version.rb +3 -3
  117. data/lib/tasks/sibu_tasks.rake +4 -4
  118. metadata +3 -3
@@ -1,262 +1,262 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title><%= conf[:title] %></title>
5
- <%= stylesheet_link_tag "#{conf[:stylesheet]}-edit", media: 'all' %>
6
- <%= stylesheet_link_tag 'sibu/sibu', media: 'all' %>
7
- <%= javascript_include_tag "#{conf[:javascript]}-edit" %>
8
- <%= javascript_include_tag 'sibu/sibu' %>
9
- <% if @site %>
10
- <%= stylesheet_link_tag (conf[:custom_styles] ? @site.style_url : @site.site_template.path), media: "all" %>
11
- <%= javascript_include_tag "#{@site.site_template.path}-core" %>
12
- <% end %>
13
- <%= csrf_meta_tags %>
14
- <%= yield :styles %>
15
- </head>
16
- <body>
17
- <% [:top_panel, :side_panel, :content_panel, :bottom_panel].each do |panel| %>
18
- <% unless conf[panel].blank? %>
19
- <div class="<%= panel == :content_panel ? 'sibu_content_panel' : 'sibu_panel' %>">
20
- <%= render conf[panel] %>
21
- <% if panel == :content_panel %>
22
- <div id="edit_panel" class="sibu_panel sibu_view"></div>
23
- <div id="sections_panel"></div>
24
- <div id="edit_mode_overlay" class="sibu_panel sibu_view">
25
- <div class="overlay_top"></div>
26
- <div class="overlay_right"></div>
27
- <div class="overlay_left"></div>
28
- <div class="overlay_bottom"></div>
29
- <div class="edit_mode_actions">
30
- <p id="edit_section_msg">Modifier la section</p>
31
- <% if conf[:section_form] %>
32
- <button id="edit_section" onclick="editSection()">Configurer</button>
33
- <% end %>
34
- <button id="new_section_before" onclick="newSection(false)">Insérer un bloc avant</button>
35
- <button id="new_section_after" onclick="newSection(true)">Insérer un bloc après</button>
36
- <button id="delete_section" onclick="deleteSection()">Supprimer</button>
37
- <button onclick="cancelEditMode()">Fermer</button>
38
- </div>
39
- </div>
40
- <div id="edit_overlays"></div>
41
- <% end %>
42
- </div>
43
- <% end %>
44
- <% end %>
45
- <script>
46
- var rootElt = $('html, body');
47
-
48
- $(function () {
49
- initOverlays();
50
- sibuCallback("editContent");
51
- <% unless @edit_section.blank? %>
52
- $("[data-sb-overlay='<%= @edit_section %>']").click();
53
- <% end %>
54
- });
55
-
56
- function setEditMode(section, overlay, left, top, width, height) {
57
- var editMode = $("#edit_mode_overlay");
58
- editMode.find(".overlay_top").css("height", top);
59
- editMode.find(".overlay_bottom").css("top", top + height);
60
- editMode.find(".overlay_left").css({"height": height, "width": left, "top": top});
61
- editMode.find(".overlay_right").css({"height": height, "left": left + width, "top": top});
62
- editMode.find(".edit_mode_actions").css({"top": (top <= 120 ? (top + height) : (top - 40 - 20)), left: left, width: width});
63
- editMode.find("#edit_section_msg").text("Modifier la section");
64
- editMode.show();
65
- if(!section.data('sb-repeat')) {
66
- editMode.find("#new_section_before").hide();
67
- editMode.find("#new_section_after").hide();
68
- editMode.find("#delete_section").hide();
69
- } else {
70
- editMode.find("#new_section_before").show();
71
- editMode.find("#new_section_after").show();
72
- editMode.find("#delete_section").show();
73
- }
74
- rootElt.animate({scrollTop: top}, 500);
75
- section.addClass('sb-editing');
76
- initInnerOverlays(section);
77
- $("#edit_overlays").html("");
78
- }
79
-
80
- function cancelEditMode() {
81
- refreshAfterEdit(false);
82
- $("#edit_mode_overlay").hide();
83
- cancelEdit();
84
- $(".sb-editing").removeClass("sb-editing");
85
- initOverlays();
86
- if(typeof editCancelledCallback === "function") {
87
- editCancelledCallback();
88
- }
89
- }
90
-
91
- function newSection(isAfter) {
92
- var section = $(".sb-editing").first();
93
- var sectionsPanel = $("#sections_panel");
94
- sectionsPanel.html(
95
- '<div class="sibu_panel sibu_view"><h2>Choix du type de section</h2></div>' +
96
- '<div><div class="sibu_sections sibu_site_content" style="text-align: center;">Chargement en cours...</div></div>' +
97
- '<div class="sibu_panel sibu_view"><div class="sibu_actions"><a href="#" onclick="cancelSectionsEdit(); return false;">Annuler</a></div></div>'
98
- );
99
- sectionsPanel.slideDown("fast");
100
- $.ajax({
101
- url: "<%= new_section_site_page_path(@site.id, @page.id) %>",
102
- method: "GET",
103
- data: {
104
- section_id: section.data("sb-id"),
105
- entity: section.data("sb-entity"),
106
- after: isAfter
107
- }
108
- })
109
- }
110
-
111
- function editSection() {
112
- var section = $(".sb-editing").first();
113
- $.ajax({
114
- url: "<%= edit_section_site_page_path(@site.id, @page.id) %>",
115
- method: "GET",
116
- data: {
117
- section_id: section.data("sb-id"),
118
- entity: section.data("sb-entity")
119
- }
120
- })
121
- }
122
-
123
- function deleteSection() {
124
- if (window.confirm("Supprimer la section ?")) {
125
- var section = $(".sb-editing").first();
126
- $.ajax({
127
- url: "<%= delete_section_site_page_path(@site.id, @page.id) %>",
128
- method: "DELETE",
129
- data: {
130
- section_id: section.data("sb-id"),
131
- entity: section.data("sb-entity")
132
- }
133
- })
134
- }
135
- }
136
-
137
- function cloneElement(entity, sectionId, elementId) {
138
- if (window.confirm("Dupliquer l'élément ?")) {
139
- $.ajax({
140
- url: "<%= clone_element_site_page_path(@site.id, @page.id) %>",
141
- method: "POST",
142
- data: {
143
- section_id: sectionId,
144
- element_id: elementId,
145
- entity: entity
146
- }
147
- })
148
- }
149
- }
150
-
151
- function deleteElement(entity, sectionId, elementId) {
152
- if (window.confirm("Supprimer l'élément ?")) {
153
- $.ajax({
154
- url: "<%= delete_element_site_page_path(@site.id, @page.id) %>",
155
- method: "DELETE",
156
- data: {
157
- section_id: sectionId,
158
- element_id: elementId,
159
- entity: entity
160
- }
161
- })
162
- }
163
- }
164
-
165
- function addChildElement(entity, sectionId, elementId) {
166
- if (window.confirm("Ajouter un sous-menu ?")) {
167
- $.ajax({
168
- url: "<%= child_element_site_page_path(@site.id, @page.id) %>",
169
- method: "POST",
170
- data: {
171
- section_id: sectionId,
172
- element_id: elementId,
173
- entity: entity
174
- }
175
- })
176
- }
177
- }
178
-
179
- function cancelEdit() {
180
- $("#edit_panel").slideUp("fast");
181
- $("#edit_panel").html("");
182
- document.body.style.overflow = "initial";
183
- }
184
-
185
- function cancelSectionsEdit() {
186
- $("#sections_panel").slideUp("fast");
187
- $("#sections_panel").html("");
188
- document.body.style.overflow = "initial";
189
- }
190
-
191
- function editContent(eltId, sectionId, entity, repeat, contentType, size, children) {
192
- $.ajax({
193
- url: "<%= edit_element_site_page_path(@site.id, @page.id) %>",
194
- method: "GET",
195
- data: {
196
- element_id: eltId,
197
- section_id: sectionId,
198
- entity: entity,
199
- repeat: repeat,
200
- content_type: contentType,
201
- size: size,
202
- children: children
203
- }
204
- })
205
- }
206
-
207
- function initInnerOverlays(section) {
208
- var editables = section.find("[data-type]");
209
- editables.off();
210
- editables.hover(function(evt) {
211
- evt.stopPropagation();
212
- $(this).addClass("sb-editable");
213
- }, function() {
214
- $(this).removeClass("sb-editable");
215
- });
216
- editables.click(function(evt) {
217
- evt.stopPropagation();
218
- evt.preventDefault();
219
- var elt = $(this), eltId = elt.data("id"), repeat = elt.data("repeat"), type = elt.data("type"),
220
- size = elt.data("size"), children = elt.data("children");
221
- var sectionId = section.data("sb-id"), entity = section.data("sb-entity");
222
- editContent(eltId, sectionId, entity, repeat, type, size, children);
223
- })
224
- }
225
-
226
- function initOverlays() {
227
- var container = $("#edit_overlays");
228
- container.html("");
229
- $("[data-sb-id]").each(function() {
230
- var section = $(this);
231
- var offset = section.offset();
232
- var yOffset = offset.top - $(".sibu_content_panel").offset().top;
233
- var width = section.outerWidth(), height = (section.outerHeight() === 0 ? childrenHeight(section) : section.outerHeight());
234
- var overlay = $("<div data-sb-overlay='" + section.attr("data-sb-id") + "'>Modifier</div>");
235
- container.append(overlay);
236
- overlay.css({top: yOffset, left: offset.left, width: width, height: height});
237
- overlay.hover(function() {
238
- $(this).css("opacity", 1);
239
- }, function() {
240
- $(this).css("opacity", 0);
241
- });
242
- overlay.click(function() {
243
- setEditMode(section, $(this), offset.left, yOffset, width, height);
244
- })
245
- });
246
- }
247
-
248
- function childrenHeight(parentElt) {
249
- var height = 0;
250
- parentElt.find("*").each(function() {
251
- var childHeight = $(this).height();
252
- if(childHeight > height) {
253
- height = childHeight;
254
- }
255
- });
256
- return height;
257
- }
258
- </script>
259
- <%= yield :site_scripts %>
260
- <%= yield :page_scripts %>
261
- </body>
262
- </html>
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= conf[:title] %></title>
5
+ <%= stylesheet_link_tag "#{conf[:stylesheet]}-edit", media: 'all' %>
6
+ <%= stylesheet_link_tag 'sibu/sibu', media: 'all' %>
7
+ <%= javascript_include_tag "#{conf[:javascript]}-edit" %>
8
+ <%= javascript_include_tag 'sibu/sibu' %>
9
+ <% if @site %>
10
+ <%= stylesheet_link_tag (conf[:custom_styles] ? @site.style_url : @site.site_template.path), media: "all" %>
11
+ <%= javascript_include_tag "#{@site.site_template.path}-core" %>
12
+ <% end %>
13
+ <%= csrf_meta_tags %>
14
+ <%= yield :styles %>
15
+ </head>
16
+ <body>
17
+ <% [:top_panel, :side_panel, :content_panel, :bottom_panel].each do |panel| %>
18
+ <% unless conf[panel].blank? %>
19
+ <div class="<%= panel == :content_panel ? 'sibu_content_panel' : 'sibu_panel' %>">
20
+ <%= render conf[panel] %>
21
+ <% if panel == :content_panel %>
22
+ <div id="edit_panel" class="sibu_panel sibu_view"></div>
23
+ <div id="sections_panel"></div>
24
+ <div id="edit_mode_overlay" class="sibu_panel sibu_view">
25
+ <div class="overlay_top"></div>
26
+ <div class="overlay_right"></div>
27
+ <div class="overlay_left"></div>
28
+ <div class="overlay_bottom"></div>
29
+ <div class="edit_mode_actions">
30
+ <p id="edit_section_msg">Modifier la section</p>
31
+ <% if conf[:section_form] %>
32
+ <button id="edit_section" onclick="editSection()">Configurer</button>
33
+ <% end %>
34
+ <button id="new_section_before" onclick="newSection(false)">Insérer un bloc avant</button>
35
+ <button id="new_section_after" onclick="newSection(true)">Insérer un bloc après</button>
36
+ <button id="delete_section" onclick="deleteSection()">Supprimer</button>
37
+ <button onclick="cancelEditMode()">Fermer</button>
38
+ </div>
39
+ </div>
40
+ <div id="edit_overlays"></div>
41
+ <% end %>
42
+ </div>
43
+ <% end %>
44
+ <% end %>
45
+ <script>
46
+ var rootElt = $('html, body');
47
+
48
+ $(function () {
49
+ initOverlays();
50
+ sibuCallback("editContent");
51
+ <% unless @edit_section.blank? %>
52
+ $("[data-sb-overlay='<%= @edit_section %>']").click();
53
+ <% end %>
54
+ });
55
+
56
+ function setEditMode(section, overlay, left, top, width, height) {
57
+ var editMode = $("#edit_mode_overlay");
58
+ editMode.find(".overlay_top").css("height", top);
59
+ editMode.find(".overlay_bottom").css("top", top + height);
60
+ editMode.find(".overlay_left").css({"height": height, "width": left, "top": top});
61
+ editMode.find(".overlay_right").css({"height": height, "left": left + width, "top": top});
62
+ editMode.find(".edit_mode_actions").css({"top": (top <= 120 ? (top + height) : (top - 40 - 20)), left: left, width: width});
63
+ editMode.find("#edit_section_msg").text("Modifier la section");
64
+ editMode.show();
65
+ if(!section.data('sb-repeat')) {
66
+ editMode.find("#new_section_before").hide();
67
+ editMode.find("#new_section_after").hide();
68
+ editMode.find("#delete_section").hide();
69
+ } else {
70
+ editMode.find("#new_section_before").show();
71
+ editMode.find("#new_section_after").show();
72
+ editMode.find("#delete_section").show();
73
+ }
74
+ rootElt.animate({scrollTop: top}, 500);
75
+ section.addClass('sb-editing');
76
+ initInnerOverlays(section);
77
+ $("#edit_overlays").html("");
78
+ }
79
+
80
+ function cancelEditMode() {
81
+ refreshAfterEdit(false);
82
+ $("#edit_mode_overlay").hide();
83
+ cancelEdit();
84
+ $(".sb-editing").removeClass("sb-editing");
85
+ initOverlays();
86
+ if(typeof editCancelledCallback === "function") {
87
+ editCancelledCallback();
88
+ }
89
+ }
90
+
91
+ function newSection(isAfter) {
92
+ var section = $(".sb-editing").first();
93
+ var sectionsPanel = $("#sections_panel");
94
+ sectionsPanel.html(
95
+ '<div class="sibu_panel sibu_view"><h2>Choix du type de section</h2></div>' +
96
+ '<div><div class="sibu_sections sibu_site_content" style="text-align: center;">Chargement en cours...</div></div>' +
97
+ '<div class="sibu_panel sibu_view"><div class="sibu_actions"><a href="#" onclick="cancelSectionsEdit(); return false;">Annuler</a></div></div>'
98
+ );
99
+ sectionsPanel.slideDown("fast");
100
+ $.ajax({
101
+ url: "<%= new_section_site_page_path(@site.id, @page.id) %>",
102
+ method: "GET",
103
+ data: {
104
+ section_id: section.data("sb-id"),
105
+ entity: section.data("sb-entity"),
106
+ after: isAfter
107
+ }
108
+ })
109
+ }
110
+
111
+ function editSection() {
112
+ var section = $(".sb-editing").first();
113
+ $.ajax({
114
+ url: "<%= edit_section_site_page_path(@site.id, @page.id) %>",
115
+ method: "GET",
116
+ data: {
117
+ section_id: section.data("sb-id"),
118
+ entity: section.data("sb-entity")
119
+ }
120
+ })
121
+ }
122
+
123
+ function deleteSection() {
124
+ if (window.confirm("Supprimer la section ?")) {
125
+ var section = $(".sb-editing").first();
126
+ $.ajax({
127
+ url: "<%= delete_section_site_page_path(@site.id, @page.id) %>",
128
+ method: "DELETE",
129
+ data: {
130
+ section_id: section.data("sb-id"),
131
+ entity: section.data("sb-entity")
132
+ }
133
+ })
134
+ }
135
+ }
136
+
137
+ function cloneElement(entity, sectionId, elementId) {
138
+ if (window.confirm("Dupliquer l'élément ?")) {
139
+ $.ajax({
140
+ url: "<%= clone_element_site_page_path(@site.id, @page.id) %>",
141
+ method: "POST",
142
+ data: {
143
+ section_id: sectionId,
144
+ element_id: elementId,
145
+ entity: entity
146
+ }
147
+ })
148
+ }
149
+ }
150
+
151
+ function deleteElement(entity, sectionId, elementId) {
152
+ if (window.confirm("Supprimer l'élément ?")) {
153
+ $.ajax({
154
+ url: "<%= delete_element_site_page_path(@site.id, @page.id) %>",
155
+ method: "DELETE",
156
+ data: {
157
+ section_id: sectionId,
158
+ element_id: elementId,
159
+ entity: entity
160
+ }
161
+ })
162
+ }
163
+ }
164
+
165
+ function addChildElement(entity, sectionId, elementId) {
166
+ if (window.confirm("Ajouter un sous-menu ?")) {
167
+ $.ajax({
168
+ url: "<%= child_element_site_page_path(@site.id, @page.id) %>",
169
+ method: "POST",
170
+ data: {
171
+ section_id: sectionId,
172
+ element_id: elementId,
173
+ entity: entity
174
+ }
175
+ })
176
+ }
177
+ }
178
+
179
+ function cancelEdit() {
180
+ $("#edit_panel").slideUp("fast");
181
+ $("#edit_panel").html("");
182
+ document.body.style.overflow = "initial";
183
+ }
184
+
185
+ function cancelSectionsEdit() {
186
+ $("#sections_panel").slideUp("fast");
187
+ $("#sections_panel").html("");
188
+ document.body.style.overflow = "initial";
189
+ }
190
+
191
+ function editContent(eltId, sectionId, entity, repeat, contentType, size, children) {
192
+ $.ajax({
193
+ url: "<%= edit_element_site_page_path(@site.id, @page.id) %>",
194
+ method: "GET",
195
+ data: {
196
+ element_id: eltId,
197
+ section_id: sectionId,
198
+ entity: entity,
199
+ repeat: repeat,
200
+ content_type: contentType,
201
+ size: size,
202
+ children: children
203
+ }
204
+ })
205
+ }
206
+
207
+ function initInnerOverlays(section) {
208
+ var editables = section.find("[data-type]");
209
+ editables.off();
210
+ editables.hover(function(evt) {
211
+ evt.stopPropagation();
212
+ $(this).addClass("sb-editable");
213
+ }, function() {
214
+ $(this).removeClass("sb-editable");
215
+ });
216
+ editables.click(function(evt) {
217
+ evt.stopPropagation();
218
+ evt.preventDefault();
219
+ var elt = $(this), eltId = elt.data("id"), repeat = elt.data("repeat"), type = elt.data("type"),
220
+ size = elt.data("size"), children = elt.data("children");
221
+ var sectionId = section.data("sb-id"), entity = section.data("sb-entity");
222
+ editContent(eltId, sectionId, entity, repeat, type, size, children);
223
+ })
224
+ }
225
+
226
+ function initOverlays() {
227
+ var container = $("#edit_overlays");
228
+ container.html("");
229
+ $("[data-sb-id]").each(function() {
230
+ var section = $(this);
231
+ var offset = section.offset();
232
+ var yOffset = offset.top - $(".sibu_content_panel").offset().top;
233
+ var width = section.outerWidth(), height = (section.outerHeight() === 0 ? childrenHeight(section) : section.outerHeight());
234
+ var overlay = $("<div data-sb-overlay='" + section.attr("data-sb-id") + "'>Modifier</div>");
235
+ container.append(overlay);
236
+ overlay.css({top: yOffset, left: offset.left, width: width, height: height});
237
+ overlay.hover(function() {
238
+ $(this).css("opacity", 1);
239
+ }, function() {
240
+ $(this).css("opacity", 0);
241
+ });
242
+ overlay.click(function() {
243
+ setEditMode(section, $(this), offset.left, yOffset, width, height);
244
+ })
245
+ });
246
+ }
247
+
248
+ function childrenHeight(parentElt) {
249
+ var height = 0;
250
+ parentElt.find("*").each(function() {
251
+ var childHeight = $(this).height();
252
+ if(childHeight > height) {
253
+ height = childHeight;
254
+ }
255
+ });
256
+ return height;
257
+ }
258
+ </script>
259
+ <%= yield :site_scripts %>
260
+ <%= yield :page_scripts %>
261
+ </body>
262
+ </html>