sibu 1.0.3 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7991033d4b4015c8079d0952b34c7f11cb9a9e01
4
- data.tar.gz: 4b908d62c7a595af8127ab72b71c77f9abfd2095
3
+ metadata.gz: 9be2c0e35af2b8d5bb5e9283434dff69b764aac6
4
+ data.tar.gz: e83fbe2deb769b75efe13a4211cb9f88542d9c03
5
5
  SHA512:
6
- metadata.gz: eef44db76d0e344005e6070543eb9b8829b5c1fb751cdfdde9cd299bd9688686f6cf1b97335a404b14808ff0f8ddc7bfebac1610964c307c17743db68081b467
7
- data.tar.gz: 010ac8a10ff5cedb1e96d576354c600245a33f9b253bef5a07fab9fb3cca51344ebf8a529bb2621380dcb7977c554fae4edef5db4353c25aa022ffe7d2b6c401
6
+ metadata.gz: 593deedf3cecf0eae5c84ce825726d3889d4c9e4b4eba5d2733c0a8c02ba7d1c0fb1a366dfe9523710cb55962cdd7479095e6aac0703cda77282731522e3c851
7
+ data.tar.gz: 7e46c8092624205af3b6506587c8a0de7f55fd406d49f2bfc5034455a2b7187c297baa35ee447982d3aeb74f4048102f457734378db1d729bb8282e4524e9fd5
@@ -229,8 +229,7 @@ $sibu-color3 : #333 !default;
229
229
  padding: 2rem;
230
230
 
231
231
  img {
232
- padding-top: 2rem;
233
- padding-bottom: 2rem;
232
+ margin-bottom: 2rem;
234
233
  border-top: 2px solid $sibu-color1;
235
234
  box-shadow: 0 0 5px #ccc;
236
235
  }
@@ -3,10 +3,21 @@
3
3
  *= require_self
4
4
  */
5
5
 
6
- .sibu_content_panel {
6
+ body.sibu_edit_content, .sibu_content_panel {
7
7
  position: relative
8
8
  }
9
9
 
10
+ body.sibu_edit_content > .sibu_panel:first-child {
11
+ position: fixed;
12
+ width: 100%;
13
+ z-index: 999999;
14
+ top: 0;
15
+ }
16
+
17
+ body.sibu_edit_content > .sibu_content_panel {
18
+ padding-top: 60px;
19
+ }
20
+
10
21
  .sb-editable {
11
22
  cursor: pointer;
12
23
  outline: dashed rgba(94, 219, 255, 0.8) 3px;
@@ -0,0 +1,4 @@
1
+ module Sibu
2
+ module ExtendableHelper
3
+ end
4
+ end
@@ -27,6 +27,13 @@ module Sibu
27
27
  options_from_collection_for_select(Sibu::Document.for_user(sibu_user), :file_url, :file_name, @element["value"])
28
28
  end
29
29
 
30
+ def input_categories
31
+ options_for_select([['Nom', 'name'], ['Adresse', 'address'], ['Email', 'email'], ['Téléphone', 'telephone'],
32
+ ['Arrivée', 'arrival_date'], ['Départ', 'departure_date'], ['Nombre de personnes', 'people'],
33
+ ['Message (texte libre)', 'message'], ['Inscription à la newsletter', 'newsletter']],
34
+ @element["field_name"])
35
+ end
36
+
30
37
  def link_type(val)
31
38
  if val.blank? || /^\d+$/.match(val.to_s)
32
39
  'internal'
@@ -124,25 +131,33 @@ module Sibu
124
131
  wrapper = opts.delete(:wrapper)
125
132
  repeat = opts.delete(:repeat)
126
133
  size = opts.delete(:size)
127
- defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "src" => Sibu::DEFAULT_IMG}
134
+ t_id = elt.is_a?(Hash) ? elt["id"] : elt
135
+ defaults = {"id" => t_id, "src" => Sibu::DEFAULT_IMG}
128
136
  content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
137
+ @sb_section = (@sb_section || []) + [t_id]
129
138
  if action_name == 'show'
130
139
  content["src"] = ("/#{conf[:deployment_path]}" + content["src"]) if @online && conf[:deployment_path]
131
140
  else
132
- opts.merge!({data: {id: elt_id(elt), type: "media", repeat: repeat, size: size}})
141
+ opts.merge!({data: {id: @sb_section[1..-1].join('|'), type: "media", repeat: repeat, size: size}})
133
142
  end
134
- wrapper ? content_tag(wrapper, content_tag(:img, nil, content.except("id")), opts)
143
+ html_output = wrapper ? content_tag(wrapper, content_tag(:img, nil, content.except("id")), opts)
135
144
  : content_tag(:img, nil, content.except("id").merge(opts.stringify_keys) {|k, old, new| k == 'class' ? [old, new].join(' ') : new})
145
+ @sb_section -= [t_id]
146
+ html_output
136
147
  end
137
148
 
138
149
  def grp(elt, opts = {}, &block)
139
150
  wrapper = opts.delete(:wrapper) || :div
140
151
  repeat = opts.delete(:repeat)
141
152
  children = opts.delete(:children)
142
- defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt}
153
+ t_id = elt.is_a?(Hash) ? elt["id"] : elt
154
+ @sb_section = (@sb_section || []) + [t_id]
155
+ defaults = {"id" => t_id}
143
156
  opts = defaults.merge(opts)
144
- opts.merge!({data: {id: elt_id(elt), type: "group", repeat: repeat, children: children}}) if action_name != 'show'
145
- content_tag(wrapper, capture(*elts(elt), &block), opts)
157
+ opts.merge!({data: {id: @sb_section[1..-1].join('|'), type: "group", repeat: repeat, children: children}}) if action_name != 'show'
158
+ html_output = content_tag(wrapper, capture(*elts(elt), &block), opts)
159
+ @sb_section -= [t_id]
160
+ html_output
146
161
  end
147
162
 
148
163
  def empty_tag(elt, tag, type, opts = {})
@@ -160,6 +175,41 @@ module Sibu
160
175
  content_tag(:label, raw(content["text"]).html_safe, html_opts)
161
176
  end
162
177
 
178
+ def form_input(elt, html_opts = {})
179
+ repeat = html_opts.delete(:repeat)
180
+ children = html_opts.delete(:children)
181
+ t_id = elt.is_a?(Hash) ? elt["id"] : elt
182
+ opts = {"id" => t_id}.merge(html_opts.stringify_keys).merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
183
+ form_name = opts.delete('form_name') || 'contact'
184
+ field_name = opts.delete('field_name') || 'name'
185
+ name_attr = "#{form_name}[#{field_name}]"
186
+
187
+ @sb_section = (@sb_section || []) + [t_id]
188
+ opts.merge!({data: {id: @sb_section[1..-1].join('|'), type: "input", repeat: repeat, children: children}}) if action_name != 'show'
189
+
190
+ case field_name
191
+ when 'name', 'address'
192
+ html_output = content_tag(:input, nil, opts.merge('type' => 'text', 'name' => name_attr))
193
+ when 'email'
194
+ html_output = content_tag(:input, nil, opts.merge('type' => 'email', 'name' => name_attr))
195
+ when 'telephone'
196
+ html_output = content_tag(:input, nil, opts.merge('type' => 'tel', 'name' => name_attr))
197
+ when 'arrival_date', 'departure_date'
198
+ html_output = content_tag(:input, nil, opts.merge('type' => 'date', 'name' => name_attr))
199
+ when 'people'
200
+ html_output = content_tag(:input, nil, opts.merge('type' => 'number', 'name' => name_attr))
201
+ when 'message'
202
+ html_output = content_tag(:textarea, nil, opts.merge('name' => name_attr))
203
+ when 'newsletter'
204
+ html_output = content_tag(:input, nil, opts.merge('type' => 'checkbox', 'name' => name_attr))
205
+ else
206
+ html_output = content_tag(:input, nil, opts.merge('type' => 'text', 'name' => name_attr))
207
+ end
208
+
209
+ @sb_section -= [t_id]
210
+ html_output
211
+ end
212
+
163
213
  def widget(elt, widget_type, opts = {}, &block)
164
214
  content = elt.is_a?(Hash) ? elt : (select_element(elt) || {})
165
215
  opts.merge!({data: {id: elt_id(elt), type: "widget_#{widget_type.to_s.split('::').last.underscore}"}}) if action_name != 'show'
@@ -229,12 +279,14 @@ module Sibu
229
279
  def link(elt, html_opts = {}, &block)
230
280
  repeat = html_opts.delete(:repeat)
231
281
  children = html_opts.delete(:children)
232
- defaults = {"id" => elt_id(elt), "value" => "", "text" => Sibu::DEFAULT_TEXT}
282
+ t_id = elt.is_a?(Hash) ? elt["id"] : elt
283
+ defaults = {"id" => t_id, "value" => "", "text" => Sibu::DEFAULT_TEXT}
233
284
  link_elt = current_elt(elt)
234
285
  content = defaults.merge(link_elt)
235
286
  val = content.delete("value") || ""
236
287
  text = content.delete("text")
237
- html_opts.merge!({data: {id: elt_id(elt), type: "link", repeat: repeat, children: children}}) if action_name != 'show'
288
+ @sb_section = (@sb_section || []) + [t_id]
289
+ html_opts.merge!({data: {id: @sb_section[1..-1].join('|'), type: "link", repeat: repeat, children: children}}) if action_name != 'show'
238
290
  if val.to_s.start_with?('http')
239
291
  content["href"] = val
240
292
  elsif val.to_s.start_with?('#')
@@ -248,20 +300,19 @@ module Sibu
248
300
  content["href"] = @links.keys.include?(val.to_s) ? (action_name == 'show' ? link_path(val) : site_page_edit_content_path(@site.id, val)) : '#'
249
301
  end
250
302
  if block_given?
251
- @sb_section = (@sb_section || []) + [elt_id(elt)]
252
- html_output = content_tag(:a, capture(link_elt, elts(elt), &block), content.merge(html_opts).except("elements"))
253
- @sb_section -= [elt_id(elt)]
254
- html_output
303
+ html_output = content_tag(:a, capture(link_elt, nested_elements(elt), &block), content.merge(html_opts).except("elements"))
255
304
  else
256
- content_tag(:a, raw(text), content.merge(html_opts).except("elements"))
305
+ html_output = content_tag(:a, raw(text), content.merge(html_opts).except("elements"))
257
306
  end
307
+ @sb_section -= [t_id]
308
+ html_output
258
309
  end
259
310
 
260
311
  def interactive_map(elt, html_opts = {})
261
- defaults = {"data-lat" => "46.1988027", "data-lng" => "5.1748288", "data-title" => Sibu::DEFAULT_TEXT}
312
+ defaults = {"data-lat" => "46.1988027", "data-lng" => "5.1748288"}
262
313
  content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {"id" => elt}))
263
314
  html_opts.merge!({data: {id: elt_id(elt), type: "map"}}) if action_name != 'show'
264
- content_tag(:div, nil, content.merge(html_opts))
315
+ content_tag(:div, nil, content.merge(html_opts.stringify_keys))
265
316
  end
266
317
 
267
318
  def elt_id(elt)
@@ -1,31 +1,36 @@
1
1
  module Sibu
2
2
  class DynamicStyle
3
3
 
4
- attr_reader :site, :body, :env, :filename, :scss_file
4
+ attr_reader :site, :body, :env, :filename, :scss_file, :styles_changed
5
5
 
6
6
  def initialize(site_id)
7
7
  @site = Sibu::Site.find(site_id)
8
- @filename = "#{site_id}_#{Time.current.to_i}"
9
- @scss_file = File.new(scss_file_path, 'w')
10
- @body = ERB.new(File.read(template_file_path)).result(binding)
11
- @env = Rails.application.assets
8
+ @styles_changed = styles_changed?(@site.style_url)
9
+ if @styles_changed
10
+ @filename = "#{site_id}_#{Time.current.to_i}"
11
+ @scss_file = File.new(scss_file_path, 'w')
12
+ @body = ERB.new(File.read(template_file_path)).result(binding)
13
+ @env = Rails.application.assets
14
+ end
12
15
  end
13
16
 
14
17
  def compile
15
- find_or_create_scss
18
+ if @styles_changed
19
+ find_or_create_scss
16
20
 
17
- begin
18
- scss_file.write generate_css
19
- scss_file.flush
20
- scss_file.close
21
- css_file_path = scss_file_path.gsub('scss', 'css')
22
- File.rename(scss_file_path, css_file_path)
23
- site.update(style: File.new(css_file_path))
24
- rescue Exception => ex
25
- Rails.logger.error(ex)
26
- ensure
27
- File.delete(scss_file_path) if scss_file_path && File.exist?(scss_file_path)
28
- File.delete(css_file_path) if css_file_path && File.exist?(css_file_path)
21
+ begin
22
+ scss_file.write generate_css
23
+ scss_file.flush
24
+ scss_file.close
25
+ css_file_path = scss_file_path.gsub('scss', 'css')
26
+ File.rename(scss_file_path, css_file_path)
27
+ site.update(style: File.new(css_file_path))
28
+ rescue Exception => ex
29
+ Rails.logger.error(ex)
30
+ ensure
31
+ File.delete(scss_file_path) if scss_file_path && File.exist?(scss_file_path)
32
+ File.delete(css_file_path) if css_file_path && File.exist?(css_file_path)
33
+ end
29
34
  end
30
35
  end
31
36
 
@@ -73,5 +78,16 @@ module Sibu
73
78
  env.load(asset.uri).source
74
79
  end
75
80
  end
81
+
82
+ def styles_changed?(site_style_url)
83
+ templates_styles_path = File.join(Rails.root, 'app', 'assets', 'stylesheets', 'templates', '**/*')
84
+ style_updated_at = File.new(File.join(Rails.root, 'public', site_style_url)).mtime
85
+ Dir.glob(templates_styles_path) do |style_file|
86
+ if File.new(style_file).mtime > style_updated_at
87
+ return true
88
+ end
89
+ end
90
+ false
91
+ end
76
92
  end
77
93
  end
@@ -62,5 +62,9 @@ module Sibu
62
62
  save
63
63
  end
64
64
  end
65
+
66
+ def home?
67
+ is_home == 'true' || is_home == '1'
68
+ end
65
69
  end
66
70
  end
@@ -51,13 +51,6 @@ module Sibu
51
51
  pages.where(id: page_id).select(:id, :path).first
52
52
  end
53
53
 
54
- def update_paths
55
- pages.each do |p|
56
- p.update_path(true)
57
- p.save
58
- end
59
- end
60
-
61
54
  def save_and_init
62
55
  if valid?
63
56
  self.sections = site_template.sections
@@ -2,17 +2,20 @@
2
2
  <html>
3
3
  <head>
4
4
  <title><%= conf[:title] %></title>
5
+ <%= stylesheet_link_tag 'sibu/sibu', media: 'all' %>
6
+ <%= stylesheet_link_tag "#{conf[:stylesheet]}-edit", media: 'all' %>
5
7
  <% if @site %>
6
8
  <%= stylesheet_link_tag (conf[:custom_styles] ? @site.style_url : @site.site_template.path), media: "all" %>
9
+ <% end %>
10
+
11
+ <% if @site %>
7
12
  <%= javascript_include_tag @site.site_template.path %>
8
13
  <% end %>
9
- <%= stylesheet_link_tag 'sibu/sibu', media: 'all' %>
10
- <%= stylesheet_link_tag "#{conf[:stylesheet]}-edit", media: 'all' %>
11
14
  <%= javascript_include_tag "#{conf[:javascript]}-edit" %>
12
15
  <%= csrf_meta_tags %>
13
16
  <%= yield :styles %>
14
17
  </head>
15
- <body>
18
+ <body class="sibu_edit_content">
16
19
  <% [:top_panel, :side_panel, :content_panel, :bottom_panel].each do |panel| %>
17
20
  <% unless conf[panel].blank? %>
18
21
  <div class="<%= panel == :content_panel ? 'sibu_content_panel' : 'sibu_panel' %>">
@@ -43,6 +46,8 @@
43
46
  <% end %>
44
47
  <%= javascript_include_tag 'sibu/sibu' %>
45
48
  <script>
49
+ var sectionsState = {};
50
+
46
51
  document.addEventListener("DOMContentLoaded", function() {
47
52
  initOverlays("<%= @edit_section || '' %>");
48
53
  sibuCallback("editContent");
@@ -74,7 +79,8 @@
74
79
  editMode.querySelector("#new_section_after").style.display = "block";
75
80
  editMode.querySelector("#delete_section").style.display = "block";
76
81
  }
77
- window.scrollTo(0, top);
82
+ var topPadding = top <= 120 ? 60 : 120;
83
+ window.scrollTo(0, top - topPadding);
78
84
  section.classList.add('sb-editing');
79
85
  initInnerOverlays(section);
80
86
  document.querySelector("#edit_overlays").innerHTML = "";
@@ -207,25 +213,29 @@
207
213
  }
208
214
 
209
215
  function initInnerOverlays(section) {
210
- var editables = section.querySelectorAll("[data-type]");
211
- for (var i = 0; i < editables.length; i++) {
212
- if (editables[i].getAttribute("data-type") !== 'group' || editables[i].getAttribute("data-repeat") === 'true' || editables[i].getAttribute("data-children") === 'true') {
213
- editables[i].addEventListener("mouseenter", function(evt) {
214
- evt.stopPropagation();
215
- evt.currentTarget.classList.add("sb-editable");
216
- });
217
- editables[i].addEventListener("mouseleave", function(evt) {
218
- evt.currentTarget.classList.remove("sb-editable");
219
- });
220
- editables[i].addEventListener("click", function(evt) {
221
- evt.stopPropagation();
222
- evt.preventDefault();
223
- var elt = evt.currentTarget, eltId = elt.getAttribute("data-id"), repeat = elt.getAttribute("data-repeat"),
224
- type = elt.getAttribute("data-type"), size = elt.getAttribute("data-size"), children = elt.getAttribute("data-children");
225
- var sectionId = section.getAttribute("data-sb-id"), entity = section.getAttribute("data-sb-entity");
226
- editContent(eltId, sectionId, entity, repeat, type, size, children);
227
- });
216
+ var sectionId = section.getAttribute('data-sb-id');
217
+ if (!sectionsState[sectionId]) {
218
+ var editables = section.querySelectorAll("[data-type]");
219
+ for (var i = 0; i < editables.length; i++) {
220
+ if (editables[i].getAttribute("data-type") !== 'group' || editables[i].getAttribute("data-repeat") === 'true' || editables[i].getAttribute("data-children") === 'true') {
221
+ editables[i].addEventListener("mouseenter", function(evt) {
222
+ evt.stopPropagation();
223
+ evt.currentTarget.classList.add("sb-editable");
224
+ });
225
+ editables[i].addEventListener("mouseleave", function(evt) {
226
+ evt.currentTarget.classList.remove("sb-editable");
227
+ });
228
+ editables[i].addEventListener("click", function(evt) {
229
+ evt.stopPropagation();
230
+ evt.preventDefault();
231
+ var elt = evt.currentTarget, eltId = elt.getAttribute("data-id"), repeat = elt.getAttribute("data-repeat"),
232
+ type = elt.getAttribute("data-type"), size = elt.getAttribute("data-size"), children = elt.getAttribute("data-children");
233
+ var sectionId = section.getAttribute("data-sb-id"), entity = section.getAttribute("data-sb-entity");
234
+ editContent(eltId, sectionId, entity, repeat, type, size, children);
235
+ });
236
+ }
228
237
  }
238
+ sectionsState[sectionId] = 'ready';
229
239
  }
230
240
  }
231
241
 
@@ -235,8 +245,8 @@
235
245
  container.innerHTML = "";
236
246
 
237
247
  for (var i = 0; i < sections.length; i++) {
238
- var sectionBox = sections[i].getBoundingClientRect();
239
- var yOffset = sectionBox.top - document.querySelector(".sibu_content_panel").getBoundingClientRect().top;
248
+ var sectionBox = eltBox(sections[i]);
249
+ var yOffset = sectionBox.top;
240
250
  var width = sections[i].offsetWidth, height = (sections[i].offsetHeight === 0 ? childrenHeight(sections[i]) : sections[i].offsetHeight);
241
251
  var overlay = document.createElement("div");
242
252
  overlay.setAttribute("data-sb-overlay", sections[i].getAttribute("data-sb-id"));
@@ -252,12 +262,31 @@
252
262
  };
253
263
  })(sections[i], sectionBox.left, yOffset, width, height));
254
264
  }
255
- if (activeSection) {
265
+ if (activeSection && document.querySelector("[data-sb-overlay='" + activeSection + "']")) {
256
266
  document.querySelector("[data-sb-overlay='" + activeSection + "']").click();
257
267
  }
258
268
  }, 800);
259
269
  }
260
270
 
271
+ function eltBox(elt) {
272
+ var x, y, w, h, bbox = elt.getBoundingClientRect();
273
+ if (isIE()) {
274
+ x = bbox.left + window.scrollX;
275
+ y = bbox.top + window.scrollY;
276
+ } else {
277
+ x = bbox.x + window.scrollX;
278
+ y = bbox.y + window.scrollY;
279
+ }
280
+ w = bbox.width;
281
+ h = bbox.height;
282
+ return {top: y, left: x, width: w, height: h}
283
+ }
284
+
285
+ function isIE() {
286
+ let ua = navigator.userAgent;
287
+ return ua.indexOf("MSIE ") > -1 || ua.indexOf("Trident/") > -1;
288
+ }
289
+
261
290
  function childrenHeight(parentElt) {
262
291
  var height = 0, children = parentElt.querySelectorAll("*");
263
292
  for (var i = 0; i < children.length; i++) {
@@ -5,7 +5,7 @@
5
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[code]', "Code d'intégration du contenu" %>
8
- <%= text_area_tag 'element[code]', @element["code"], placeholder: ' ex: <iframe src="..."></iframe>' %>
8
+ <%= text_area_tag 'element[code]', @element["code"], placeholder: 'ex: <iframe src="..."></iframe>' %>
9
9
  </div>
10
10
  <%= hidden_field_tag 'element[id]', @element["id"] %>
11
11
  <%= hidden_field_tag :element_id, @element_id %>
@@ -0,0 +1,24 @@
1
+ <h2>Modifier le champ de saisie</h2>
2
+ <div id="edit_msg"></div>
3
+ <%= render 'element_actions' %>
4
+ <div class="sibu_edit_form">
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
+ <div class="sibu_field">
7
+ <%= label_tag 'element[field_name]', 'Type de champ' %>
8
+ <%= select_tag 'element[field_name]', input_categories, prompt: 'Sélectionnez un type de champ' %>
9
+ </div>
10
+ <div class="sibu_field">
11
+ <%= label_tag 'element[placeholder]', "Texte d'aide (optionnel)" %>
12
+ <%= text_field_tag 'element[placeholder]', @element["placeholder"] %>
13
+ </div>
14
+
15
+ <%= hidden_field_tag 'element[id]', @element["id"] %>
16
+ <%= hidden_field_tag :element_id, @element_id %>
17
+ <%= hidden_field_tag :section_id, @section_id %>
18
+ <%= hidden_field_tag :entity, @entity_type %>
19
+ <div class="sibu_actions">
20
+ <%= submit_tag 'Valider' %>
21
+ <%= link_to 'Annuler', '#', onclick: 'cancelEdit(); return false;' %>
22
+ </div>
23
+ </form>
24
+ </div>
@@ -2,7 +2,7 @@
2
2
  <div class="actions">
3
3
  <%= link_to 'Retour', :back %>
4
4
  </div>
5
- <h2>Modifier une page</h2>
5
+ <h2>Réglages de la page</h2>
6
6
  <div class="sibu_form">
7
7
  <%= render 'form' %>
8
8
  </div>
@@ -18,6 +18,8 @@ editPanel.innerHTML = "";
18
18
  editPanel.innerHTML = "<%= j(render 'map_edit_panel') %>";
19
19
  <% when /^widget/ %>
20
20
  editPanel.innerHTML = "<%= j(render "shared/sibu/#{@content_type}_panel") %>";
21
+ <% when 'input' %>
22
+ editPanel.innerHTML = "<%= j(render 'input_edit_panel') %>";
21
23
  <% else %>
22
24
  editPanel.innerHTML = "<%= j(render 'error_panel') %>";
23
25
  <% end %>
@@ -43,7 +45,9 @@ setTimeout(function() {
43
45
  for (var i = 0; i < images.length; i++) {
44
46
  images[i].addEventListener("click", function(evt) {
45
47
  if(!evt.currentTarget.classList.contains('selected')) {
46
- evt.currentTarget.classList.remove('selected');
48
+ if (editPanel.querySelector('.sibu_image.selected')) {
49
+ editPanel.querySelector('.sibu_image.selected').classList.remove('selected');
50
+ }
47
51
  evt.currentTarget.classList.add('selected');
48
52
  var imgElt = evt.currentTarget.querySelector("img");
49
53
  document.querySelector("#element_src").value = imgElt.getAttribute("data-src");
@@ -52,7 +56,9 @@ setTimeout(function() {
52
56
  '<img src="' + $("#element_src").val() + '"/>' +
53
57
  '<div id="sibu_center_pos" style="display: none;">✕</div>' +
54
58
  '<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";
59
+ if (editPanel.querySelector(".sibu_selected_image > p:first-child")) {
60
+ editPanel.querySelector(".sibu_selected_image > p:first-child").style.display = "none";
61
+ }
56
62
  editPanel.querySelector(".sibu_selected_image .sibu_custom_center").style.display = "block";
57
63
  editPanel.querySelector(".sibu_selected_image .sibu_field").style.display = "";
58
64
  if(customCenter.checked) {
@@ -86,14 +92,14 @@ setTimeout(function() {
86
92
  document.querySelector("#clone_elt").style.display = "inline-block";
87
93
  document.querySelector("#duplicate_elt").style.display = "inline-block";
88
94
  <% else %>
89
- document.querySelector("#clone_elt").remove();
90
- document.querySelector("#duplicate_elt").remove();
95
+ if (document.querySelector("#clone_elt")) document.querySelector("#clone_elt").remove();
96
+ if (document.querySelector("#duplicate_elt")) document.querySelector("#duplicate_elt").remove();
91
97
  <% end %>
92
98
 
93
99
  <% if @children %>
94
100
  document.querySelector("#child_elt").style.display = "inline-block";
95
101
  <% else %>
96
- document.querySelector("#child_elt").remove();
102
+ if (document.querySelector("#child_elt")) document.querySelector("#child_elt").remove();
97
103
  <% end %>
98
104
  var formElt = document.querySelector("form.edit_element_form");
99
105
  if (formElt) {
@@ -1,6 +1,9 @@
1
1
  <div id="pages" class="sibu_view">
2
2
  <div class="actions">
3
- <%= link_to 'Créer une page', new_site_page_path(@site.id) %> <%= link_to 'Retour', :back %>
3
+ <%= link_to "Bibliothèque d'images", images_path %>
4
+ <%= link_to "Documents", documents_path %>
5
+ <%= link_to 'Créer une page', new_site_page_path(@site.id) %>
6
+ <%= link_to 'Retour', :back %>
4
7
  </div>
5
8
  <h2>Pages du site "<%= @site.name %>"</h2>
6
9
  <table>
@@ -24,7 +27,7 @@
24
27
  <%= link_to 'Voir', site_page_path(@site.id, p), target: '_blank' %> |
25
28
  <%= link_to 'Editer', site_page_edit_content_path(site_id: @site.id, page_id: p.id) %> |
26
29
  <%= link_to 'Copier', duplicate_site_page_path(@site.id, p), method: :post, data: {confirm: "Copier la page \"#{p.name}\" ?"} %> |
27
- <%= link_to 'Paramétrer', edit_site_page_path(@site.id, p) %> |
30
+ <%= link_to 'Paramétrer cette page', edit_site_page_path(@site.id, p) %> |
28
31
  <%= link_to 'Supprimer', site_page_path(@site.id, p), method: :delete, data: {confirm: "Supprimer la page \"#{p.name}\" ?"} %>
29
32
  </td>
30
33
  </tr>
@@ -20,9 +20,14 @@ if (sectionsPanel) {
20
20
  }
21
21
  });
22
22
  }
23
- if(typeof initSectionsForm === "function") {
24
- initSectionsForm();
23
+
24
+ var tabs = sectionsPanel.querySelectorAll(".sibu_sections a.tabs__link");
25
+ for (var j = 0; j < tabs.length; j++) {
26
+ tabs[j].addEventListener("click", function(evt) {
27
+ sibuCallback("selectSectionsTab", evt.currentTarget.getAttribute('aria-controls'));
28
+ });
25
29
  }
30
+
26
31
  document.body.style.overflow = "hidden";
27
32
  sibuCallback("newSection");
28
33
  }
@@ -16,8 +16,8 @@
16
16
  <div class="sibu_field">
17
17
  <%= f.label :site_template_id, 'Modèle' %>
18
18
  <div>
19
- <%= f.collection_select(:site_template_id, Sibu::SiteTemplate.all, :id, :name, {prompt: 'Sélectionnez un modèle de site'}, disabled: @site.persisted?) %>
20
- <small>Choisissez le gabarit qui servira de modèle pour votre site (non modifiable après création)</small>
19
+ <%= f.collection_select(:site_template_id, Sibu::SiteTemplate.all.order(:name), :id, :name, {prompt: 'Sélectionnez un modèle de site'}, disabled: @site.persisted?) %>
20
+ <small>Choisissez le gabarit qui servira de modèle pour votre site (voir exemples ci-dessous - non modifiable après création)</small>
21
21
  </div>
22
22
  </div>
23
23
  <div class="sibu_field">
@@ -24,7 +24,7 @@
24
24
  <td><%= l s.updated_at %></td>
25
25
  <td colspan="2">
26
26
  <%= link_to 'Pages', site_pages_path(s) %> |
27
- <%= link_to 'Paramétrer', edit_site_path(s) %> |
27
+ <%= link_to 'Réglages du site', edit_site_path(s) %> |
28
28
  <%= link_to 'Copier', duplicate_site_path(s), method: :post, data: {confirm: "Copier le site \"#{s.name}\" ?"} %> |
29
29
  <%= link_to 'Supprimer', site_path(s), method: :delete, data: {confirm: "Supprimer le site \"#{s.name}\" ?"} %>
30
30
  </td>
@@ -8,7 +8,7 @@
8
8
  </div>
9
9
  <h2>Aperçu des modèles</h2>
10
10
  <div>
11
- <% Sibu::SiteTemplate.all.each do |st| %>
11
+ <% Sibu::SiteTemplate.all.order(:name).each do |st| %>
12
12
  <div class="sibu_template">
13
13
  <h3><%= st.name %></h3>
14
14
  <%= image_tag "#{st.path}1.jpg" %>
@@ -1,3 +1,3 @@
1
1
  module Sibu
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.8'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sibu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Baptiste Vilain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-24 00:00:00.000000000 Z
11
+ date: 2020-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -143,6 +143,7 @@ files:
143
143
  - app/controllers/sibu/sites_controller.rb
144
144
  - app/helpers/sibu/application_helper.rb
145
145
  - app/helpers/sibu/documents_helper.rb
146
+ - app/helpers/sibu/extendable_helper.rb
146
147
  - app/helpers/sibu/images_helper.rb
147
148
  - app/helpers/sibu/pages_helper.rb
148
149
  - app/helpers/sibu/sites_helper.rb
@@ -177,6 +178,7 @@ files:
177
178
  - app/views/sibu/pages/_error_panel.html.erb
178
179
  - app/views/sibu/pages/_form.html.erb
179
180
  - app/views/sibu/pages/_group_edit_panel.html.erb
181
+ - app/views/sibu/pages/_input_edit_panel.html.erb
180
182
  - app/views/sibu/pages/_link_edit_panel.html.erb
181
183
  - app/views/sibu/pages/_map_edit_panel.html.erb
182
184
  - app/views/sibu/pages/_media_edit_panel.html.erb