sibu 1.0.10 → 1.0.11

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: 81b1a892357b7809824ea579fe32219a9cc864c1
4
- data.tar.gz: 121e9d7cec8dd2790bafc8d152aeff2f667d2014
3
+ metadata.gz: ddad9d6305d71605c692e8dbdafadb0c6cce1d7a
4
+ data.tar.gz: 91539711c089a4d111dede2965a554051c590dc5
5
5
  SHA512:
6
- metadata.gz: 481e3ce5022276de19aa596d15da11c99638a3b06fb9cb1eeac5ad8e38699810ece60c46a1cfeff01725dd2f5a5e5bd24dc1965d343325af161b1f1b76e1133d
7
- data.tar.gz: c6dcd079e5672c7a702db7d9e117aa87cb90cc687171ad6d2110f51ba1fb6b5d8de4cdff7f1c3cb884da391bb64653910067b75998c3a7631804065cf31c3a0a
6
+ metadata.gz: e025dc9b575fedeb91471848f78487b4ba1e3e7fbb19e81822bc31576aae2cd764326ce75bd6e39dd2d2b9ea0901d30f5b33bcef1a26a354a62f90f3d3d74a05
7
+ data.tar.gz: cb43b5c568dcd4c9323944645c2ab6935f81988d8a95fe3c47902115db8070bf8e2f10253174d8eaa73074f63348bce2acb724e0c69171e1ff8540355a8db827
@@ -118,6 +118,13 @@ module Sibu
118
118
  nested_elts.map {|e| e.merge({"data-id" => join_tokens(element_id_tokens[1..-1], e['id'])})}
119
119
  end
120
120
 
121
+ def each_element(elt_or_id)
122
+ element_id = elt_id(elt_or_id)
123
+ @sb_section = (@sb_section + element_id.split("|")).uniq unless element_id.blank?
124
+ (@sb_entity.elements(*@sb_section) || []).map {|el| yield(el)}
125
+ @sb_section -= [element_id] unless element_id.blank?
126
+ end
127
+
121
128
  def select_element(id)
122
129
  @sb_entity.element(*@sb_section, id)
123
130
  end
@@ -146,6 +153,22 @@ module Sibu
146
153
  html_output
147
154
  end
148
155
 
156
+ def svg_image(elt, opts = {})
157
+ size = opts.delete(:size)
158
+ t_id = elt.is_a?(Hash) ? elt["id"] : elt
159
+ defaults = {"id" => t_id, "xlink:href" => Sibu::DEFAULT_IMG}
160
+ content = defaults.merge((elt.is_a?(Hash) ? elt : (select_element(elt) || {})).transform_keys {|k| k == 'src' ? 'xlink:href' : k})
161
+ @sb_section = (@sb_section || []) + [t_id]
162
+ if action_name == 'show'
163
+ content["xlink:href"] = ("/#{conf[:deployment_path]}" + content["xlink:href"]) if @online && conf[:deployment_path]
164
+ else
165
+ opts.merge!({data: {id: @sb_section[1..-1].join('|'), type: "media", repeat: false, size: size}})
166
+ end
167
+ html_output = content_tag(:image, nil, content.except("id").merge(opts.stringify_keys) {|k, old, new| k == 'class' ? [old, new].join(' ') : new})
168
+ @sb_section -= [t_id]
169
+ html_output
170
+ end
171
+
149
172
  def grp(elt, opts = {}, &block)
150
173
  wrapper = opts.delete(:wrapper) || :div
151
174
  repeat = opts.delete(:repeat)
@@ -242,16 +265,17 @@ module Sibu
242
265
 
243
266
  alias site sb_site
244
267
 
245
- def render_page_section(s)
268
+ def render_page_section(s, set_id = false)
246
269
  @sb_section = [s['id']]
247
270
  @sb_entity = @page
248
271
  render partial: "shared/#{@site.section_template(s)}",
249
- locals: {sibu: self, sibu_section: s, sibu_attrs: sibu_attributes(s).html_safe}
272
+ locals: {sibu: self, sibu_section: s, sibu_attrs: sibu_attributes(s, set_id).html_safe}
250
273
  end
251
274
 
252
275
  # Page sections attrs
253
- def sibu_attributes(section)
254
- action_name != 'show' ? ('data-sb-id="' + section['id'] + '" data-sb-entity="page"') : ''
276
+ def sibu_attributes(section, set_id)
277
+ attrs = set_id ? ('id="' + section['id'] + '" ') : ''
278
+ attrs + (action_name != 'show' ? ('data-sb-id="' + section['id'] + '" data-sb-entity="page"') : '')
255
279
  end
256
280
 
257
281
  # Site sections attrs
@@ -65,7 +65,7 @@
65
65
  rightOverlay.style.height = height + "px";
66
66
  rightOverlay.style.left = left + width + "px";
67
67
  rightOverlay.style.top = top + "px";
68
- editModeActions.style.top = (top <= 120 ? (top + height) : (top - 40 - 20)) + "px";
68
+ editModeActions.style.top = (top + height) + "px";
69
69
  editModeActions.style.left = left + "px";
70
70
  editModeActions.style.width = width + "px";
71
71
  editMode.querySelector("#edit_section_msg").innerText = "Modifier la section";
@@ -79,8 +79,6 @@
79
79
  editMode.querySelector("#new_section_after").style.display = "block";
80
80
  editMode.querySelector("#delete_section").style.display = "block";
81
81
  }
82
- var topPadding = top <= 120 ? 60 : 120;
83
- window.scrollTo(0, top - topPadding);
84
82
  section.classList.add('sb-editing');
85
83
  initInnerOverlays(section);
86
84
  document.querySelector("#edit_overlays").innerHTML = "";
@@ -49,11 +49,11 @@ setTimeout(function() {
49
49
  editPanel.querySelector('.sibu_image.selected').classList.remove('selected');
50
50
  }
51
51
  evt.currentTarget.classList.add('selected');
52
- var imgElt = evt.currentTarget.querySelector("img");
53
- document.querySelector("#element_src").value = imgElt.getAttribute("data-src");
52
+ var imgElt = evt.currentTarget.querySelector("img"), eltSrc = document.querySelector("#element_src");
53
+ eltSrc.value = imgElt.getAttribute("data-src");
54
54
  document.querySelector("#element_alt").value = imgElt.getAttribute("data-alt");
55
55
  editPanel.querySelector(".sibu_center").innerHTML =
56
- '<img src="' + $("#element_src").val() + '"/>' +
56
+ '<img src="' + eltSrc.value + '"/>' +
57
57
  '<div id="sibu_center_pos" style="display: none;">✕</div>' +
58
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>';
59
59
  if (editPanel.querySelector(".sibu_selected_image > p:first-child")) {
@@ -1,3 +1,3 @@
1
1
  module Sibu
2
- VERSION = '1.0.10'
2
+ VERSION = '1.0.11'
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.10
4
+ version: 1.0.11
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-09-08 00:00:00.000000000 Z
11
+ date: 2020-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails