sibu 0.1.19 → 0.1.20

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: 8f39c1e6272a79e2e8411ec2c7f36cd8a4803ffd
4
- data.tar.gz: 42a4ea2c163c8b7b4283cf799603158521a4afba
3
+ metadata.gz: 4506dd1c2b0f1f720045ba1bddd840a03ec19945
4
+ data.tar.gz: 2e028cfdf5c22480d37186397402d1dc7b3551b8
5
5
  SHA512:
6
- metadata.gz: 2931fd1c14fde78303a6f987a8d237726126f3d1da78060998b61dd6ba22f752b32296cac2d20db18ec49b6bb3d8c70f0e90d64ecca26b5bf4afb508e1fe9f7a
7
- data.tar.gz: cae5fec21675c2fdf8dc84964a6e46d689d3b0d646d965cd2b4b396453d4faef69f36a22ec7da9d8bc86727770d76fae50339e703c35ab60dc81f2eb9ea20ba3
6
+ metadata.gz: b38dbbe585fd82607bcb2d459b7262fb6b1302a104f06101d547038af567dda790dbeab16d2fc1fc8546653ebc4607c6c5d353a50d02dd3ed3d64b5d0772f53a
7
+ data.tar.gz: a03b06e0164de60a92a0e3c24071c1a4bb126260ab25fbb288951372884354e539108d666bb9110592707d5bc289e0ef25b5317f47669a027cc3538f7496a8ae
@@ -74,6 +74,7 @@ module Sibu
74
74
  @links = @site.pages_path_by_id if @site
75
75
  @element = @entity.element(*@section_id.split('|'), *@element_id.split('|'))
76
76
  @repeat = params[:repeat]
77
+ @size = params[:size].blank? ? :medium : params[:size].to_sym
77
78
  end
78
79
 
79
80
  def update_element
@@ -58,9 +58,10 @@ module Sibu
58
58
  def img(elt, opts = {})
59
59
  wrapper = opts.delete(:wrapper)
60
60
  repeat = opts.delete(:repeat)
61
+ size = opts.delete(:size)
61
62
  defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "src" => "/default.jpg"}
62
63
  content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
63
- opts.merge!({data: {id: elt_id(elt), type: "media", repeat: repeat}}) if action_name != 'show'
64
+ opts.merge!({data: {id: elt_id(elt), type: "media", repeat: repeat, size: size}}) if action_name != 'show'
64
65
  wrapper ? content_tag(wrapper, content_tag(:img, nil, content.except("id")), opts) : content_tag(:img, nil, content.except("id").merge(opts))
65
66
  end
66
67
 
@@ -51,11 +51,7 @@
51
51
  });
52
52
 
53
53
  function setEditMode(section, overlay, left, top, width, height) {
54
- // var offset = elt.offset();
55
- // var width = elt.width(), height = elt.height();
56
54
  var editMode = $("#edit_mode_overlay");
57
- // var yPosition = offset.top - $(".sibu_content_panel").offset().top;
58
- // var section = elt.parents("sb-edit").first();
59
55
  editMode.find(".overlay_top").css("height", top);
60
56
  editMode.find(".overlay_bottom").css("top", top + height);
61
57
  editMode.find(".overlay_left").css({"height": height, "width": left, "top": top});
@@ -146,7 +142,7 @@
146
142
  $("#edit_panel").slideUp("fast");
147
143
  }
148
144
 
149
- function editContent(eltId, sectionId, entity, repeat, contentType) {
145
+ function editContent(eltId, sectionId, entity, repeat, contentType, size) {
150
146
  $.ajax({
151
147
  url: "<%= edit_element_site_page_path(@site.id, @page.id) %>",
152
148
  method: "GET",
@@ -155,7 +151,8 @@
155
151
  section_id: sectionId,
156
152
  entity: entity,
157
153
  repeat: repeat,
158
- content_type: contentType
154
+ content_type: contentType,
155
+ size: size
159
156
  }
160
157
  })
161
158
  }
@@ -170,32 +167,13 @@
170
167
  });
171
168
  editables.click(function(evt) {
172
169
  evt.preventDefault();
173
- var elt = $(this), eltId = elt.data("id"), repeat = elt.data("repeat"), type = elt.data("type");
170
+ var elt = $(this), eltId = elt.data("id"), repeat = elt.data("repeat"), type = elt.data("type"), size = elt.data("size");
174
171
  var sectionId = section.data("sb-id"), entity = section.data("sb-entity");
175
- editContent(eltId, sectionId, entity, repeat, type);
172
+ editContent(eltId, sectionId, entity, repeat, type, size);
176
173
  })
177
174
  }
178
175
 
179
176
  function initOverlays() {
180
- // $("div.sb-overlay").remove();
181
- // $("sb-edit").each(function() {
182
- // var elt = $(this);
183
- // elt.prepend("<div class='sb-overlay'><a>Modifier</a></div>");
184
- // var overlay = elt.find(".sb-overlay");
185
- // var dimensions = overlayDimensions(overlay, elt);
186
- // overlay.width(dimensions.width);
187
- // overlay.height(dimensions.height);
188
- //
189
- // elt.hover(function() {
190
- // overlay.css("opacity", 1);
191
- // }, function() {
192
- // overlay.css("opacity", 0);
193
- // });
194
- //
195
- // overlay.click(function() {
196
- // setEditMode($(this));
197
- // })
198
- // });
199
177
  var container = $("#edit_overlays");
200
178
  container.html("");
201
179
  $("[data-sb-id]").each(function() {
@@ -227,17 +205,6 @@
227
205
  });
228
206
  return height;
229
207
  }
230
-
231
- function overlayDimensions(overlay, element) {
232
- var children = element.find("> *:not(.sb-overlay)");
233
- var width = - +children.first().css("margin-left").replace("px", ""), height = - +children.first().css("margin-top").replace("px", "");
234
- var maxWidth = element.parent().outerWidth(true), maxHeight = element.parent().outerHeight(true);
235
- element.find("> *:not(.sb-overlay)").each(function() {
236
- width = width + $(this).outerWidth(true);
237
- height = height + $(this).outerHeight(true);
238
- });
239
- return {width: Math.min(width, maxWidth), height: Math.min(height, maxHeight)};
240
- }
241
208
  </script>
242
209
  <%= yield :scripts %>
243
210
  </body>
@@ -7,7 +7,7 @@
7
7
  <p>Sélectionnez ou <%= link_to 'téléchargez', new_site_image_path(@site.id, page_id: @page.id) %> une image</p>
8
8
  <% site_images.each do |image| %>
9
9
  <div class="sibu_image" data-img-id="<%= image.id %>">
10
- <%= image_tag image.file_url(:medium), class: (@element["src"] == image.file_url(:medium) ? 'selected' : '') %>
10
+ <%= image_tag image.file_url(:small), class: (@element["src"] == image.file_url(@size) ? 'selected' : ''), data: {src: image.file_url(@size)} %>
11
11
  </div>
12
12
  <% end %>
13
13
  </div>
@@ -24,7 +24,7 @@ editPanel.html("");
24
24
  if(!$(this).hasClass('selected')) {
25
25
  images.removeClass('selected');
26
26
  $(this).addClass('selected');
27
- $("#element_src").val($(this).attr("src"));
27
+ $("#element_src").val($(this).data("src"));
28
28
  }
29
29
  });
30
30
  <% when 'link' %>
data/lib/sibu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sibu
2
- VERSION = '0.1.19'
2
+ VERSION = '0.1.20'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sibu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.19
4
+ version: 0.1.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Baptiste Vilain