sibu 0.1.15 → 0.1.16

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: 1a3645e4994b5e3506134df59486cae37c4d1b1e
4
- data.tar.gz: 64698eca039fff001046d5b317f022aa1fbc7027
3
+ metadata.gz: d011e2389e6f92f5a6058c7ad75604e1d7871b67
4
+ data.tar.gz: e0cf4f17e0405ba1b2ebdd4511ad97eb9fcf18c5
5
5
  SHA512:
6
- metadata.gz: 4fa0cce6ff2674f8929000aa63a1dad931020a65c03d82ec2407d6a2e70476e6f20bd1482163bd378ef9ccd4d512ec0f31862b75b508b20ec6b36d1e4fc9fccd
7
- data.tar.gz: 351b29a13dd3460008c7b33ce0d2cee70b7b5e35421d82ecd6b097cdac42b9739de3081a28ce202454a9b93a6c2f51cf6c8c4f3495a7c595921d9071c671592e
6
+ metadata.gz: 3814575a898d0e48a307392c60b9478af5e027aafbdbbc36d3be9fcb59f51a32bbab60bde845b80e427693aeef6e96264110d8bbfa354fe5ad8840bd9ee30426
7
+ data.tar.gz: 8036525bf448ef2f53fcde1a0ac067f102735f3287ebece966629035ab53298a9e881403806487bc41fc61049130593bda08a07f43f908313c3a67375f9428ce
@@ -81,6 +81,10 @@
81
81
  background-color: white;
82
82
  }
83
83
 
84
+ #element_actions {
85
+ display: none;
86
+ }
87
+
84
88
  #edit_overlays > * {
85
89
  position: absolute;
86
90
  z-index: 999;
@@ -73,6 +73,7 @@ module Sibu
73
73
  @content_type = params[:content_type]
74
74
  @links = @site.pages_path_by_id if @site
75
75
  @element = @entity.element(*@section_id.split('|'), *@element_id.split('|'))
76
+ @repeat = params[:repeat]
76
77
  end
77
78
 
78
79
  def update_element
@@ -98,9 +98,10 @@ module Sibu
98
98
 
99
99
  def img(elt, opts = {})
100
100
  wrapper = opts.delete(:wrapper)
101
+ repeat = opts.delete(:repeat)
101
102
  defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "src" => "/default.jpg"}
102
103
  content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
103
- opts.merge!({class: "sb-img #{opts[:class]}", data: {id: elt_id(elt)}}) if action_name != 'show'
104
+ opts.merge!({class: "sb-img #{opts[:class]}", data: {id: elt_id(elt), repeat: repeat}}) if action_name != 'show'
104
105
  wrapper ? content_tag(wrapper, content_tag(:img, nil, content.except("id")), opts) : content_tag(:img, nil, content.except("id").merge(opts))
105
106
  end
106
107
 
@@ -175,9 +176,10 @@ module Sibu
175
176
  # end
176
177
 
177
178
  def link(elt, html_opts = {}, &block)
178
- defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "value" => "", "text" => "Nouveau lien"}
179
+ repeat = html_opts.delete(:repeat)
180
+ defaults = {"id" => elt_id(elt), "value" => "", "text" => "Nouveau lien"}
179
181
  content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
180
- html_opts.merge!({class: "sb-link #{html_opts[:class]}", data: {id: elt_id(elt)}}) if action_name != 'show'
182
+ html_opts.merge!({class: "sb-link #{html_opts[:class]}", data: {id: elt_id(elt), repeat: repeat}}) if action_name != 'show'
181
183
  val = content["value"] || ""
182
184
  if val.to_s.include?('http')
183
185
  href = val
@@ -20,6 +20,10 @@ module Sibu
20
20
  s
21
21
  elsif ids.length == 2
22
22
  subsection(*ids)
23
+ elsif ids.length == 3
24
+ sub = subsection(*ids[0..1])
25
+ elt_idx = sub.index {|elt| elt["id"] == ids.last}
26
+ sub[elt_idx]["elements"]
23
27
  end
24
28
  end
25
29
 
@@ -48,6 +48,8 @@
48
48
  const IMG_TAGS = ['img'];
49
49
  const LINK_TAGS = ['a'];
50
50
 
51
+ var rootElt = $('html, body');
52
+
51
53
  $(function () {
52
54
  initOverlays();
53
55
  });
@@ -72,7 +74,7 @@
72
74
  editMode.find("#clone_section").show();
73
75
  editMode.find("#delete_section").show();
74
76
  }
75
- window.scrollTo(0, top);
77
+ rootElt.animate({scrollTop: top}, 500);
76
78
  section.addClass('sb-editing');
77
79
  initInnerOverlays(section);
78
80
  $("#edit_overlays").html("");
@@ -83,6 +85,9 @@
83
85
  cancelEdit();
84
86
  $(".sb-editing").removeClass("sb-editing");
85
87
  initOverlays();
88
+ if(typeof editCancelledCallback === "function") {
89
+ editCancelledCallback();
90
+ }
86
91
  }
87
92
 
88
93
  function cloneSection() {
@@ -113,11 +118,39 @@
113
118
  }
114
119
  }
115
120
 
121
+ function cloneElement(entity, sectionId, elementId) {
122
+ if (window.confirm("Dupliquer l'élément ?")) {
123
+ $.ajax({
124
+ url: "<%= clone_element_site_page_path(@site.id, @page.id) %>",
125
+ method: "POST",
126
+ data: {
127
+ section_id: sectionId,
128
+ element_id: elementId,
129
+ entity: entity
130
+ }
131
+ })
132
+ }
133
+ }
134
+
135
+ function deleteElement(entity, sectionId, elementId) {
136
+ if (window.confirm("Supprimer l'élément ?")) {
137
+ $.ajax({
138
+ url: "<%= delete_element_site_page_path(@site.id, @page.id) %>",
139
+ method: "DELETE",
140
+ data: {
141
+ section_id: sectionId,
142
+ element_id: elementId,
143
+ entity: entity
144
+ }
145
+ })
146
+ }
147
+ }
148
+
116
149
  function cancelEdit() {
117
150
  $("#edit_panel").slideUp("fast");
118
151
  }
119
152
 
120
- function editContent(eltId, sectionId, entity, contentType) {
153
+ function editContent(eltId, sectionId, entity, repeat, contentType) {
121
154
  $.ajax({
122
155
  url: "<%= edit_element_site_page_path(@site.id, @page.id) %>",
123
156
  method: "GET",
@@ -125,6 +158,7 @@
125
158
  element_id: eltId,
126
159
  section_id: sectionId,
127
160
  entity: entity,
161
+ repeat: repeat,
128
162
  content_type: contentType
129
163
  }
130
164
  })
@@ -140,14 +174,14 @@
140
174
  });
141
175
  editables.click(function(evt) {
142
176
  evt.preventDefault();
143
- var elt = $(this), tag = elt.prop("tagName").toLowerCase();
144
- var eltId = elt.data("id"), sectionId = section.data("sb-id"), entity = section.data("sb-entity");
177
+ var elt = $(this), tag = elt.prop("tagName").toLowerCase(), eltId = elt.data("id"), repeat = elt.data("repeat");
178
+ var sectionId = section.data("sb-id"), entity = section.data("sb-entity");
145
179
  if (TEXT_TAGS.indexOf(tag) !== -1) {
146
- editContent(eltId, sectionId, entity, 'text');
180
+ editContent(eltId, sectionId, entity, repeat, 'text');
147
181
  } else if (IMG_TAGS.indexOf(tag) !== -1 || elt.hasClass('sb-img')) {
148
- editContent(eltId, sectionId, entity, 'media');
182
+ editContent(eltId, sectionId, entity, repeat, 'media');
149
183
  } else if (LINK_TAGS.indexOf(tag) !== -1) {
150
- editContent(eltId, sectionId, entity, 'link');
184
+ editContent(eltId, sectionId, entity, repeat, 'link');
151
185
  } else {
152
186
  console.log('Sibu - Unsupported tag type : ' + tag);
153
187
  }
@@ -0,0 +1,4 @@
1
+ <div id="element_actions">
2
+ <button onclick="cloneElement('<%= @entity_type %>', '<%= @section_id %>', '<%= @element_id %>')">Dupliquer</button>
3
+ <button onclick="deleteElement('<%= @entity_type %>', '<%= @section_id %>', '<%= @element_id %>')">Supprimer</button>
4
+ </div>
@@ -1,5 +1,6 @@
1
1
  <h2>Modifier le lien</h2>
2
2
  <div id="edit_msg"></div>
3
+ <%= render 'element_actions' %>
3
4
  <div class="sibu_edit_form">
4
5
  <%= form_tag(update_element_site_page_path(@site.id, @page.id), method: :patch, remote: true) do |f| %>
5
6
  <div class="sibu_field">
@@ -1,6 +1,6 @@
1
1
  <h2>Modifier l'image</h2>
2
-
3
2
  <div id="edit_msg"></div>
3
+ <%= render 'element_actions' %>
4
4
  <div class="sibu_edit_form">
5
5
  <%= form_tag(update_element_site_page_path(@site.id, @page.id), method: :patch, remote: true) do |f| %>
6
6
  <div class="sibu_select_images sibu_field">
@@ -1,5 +1,6 @@
1
1
  <h2>Modifier le texte</h2>
2
2
  <div id="edit_msg"></div>
3
+ <%= render 'element_actions' %>
3
4
  <div class="sibu_edit_form">
4
5
  <%= form_tag(update_element_site_page_path(@site.id, @page.id), method: :patch, remote: true) do |f| %>
5
6
  <%= trix_editor_tag 'element[text]', '', input: 'element_text' %>
@@ -6,4 +6,5 @@ var clonedElt = $("[data-sb-id='<%= @section_id %>']").find("[data-id='<%= @elem
6
6
  var newElt = clonedElt.clone();
7
7
  newElt.data("id", "<%= @cloned["id"] %>");
8
8
  clonedElt.after(newElt);
9
+ cancelEditMode();
9
10
  <% end %>
@@ -0,0 +1,7 @@
1
+ <% if @deleted %>
2
+ $("[data-sb-id='<%= @section_id %>']").find("[data-id='<%= @element_id %>']").first().remove();
3
+ cancelEditMode();
4
+ <% else %>
5
+ $("#edit_section_msg").text("Une erreur s'est produite lors de la suppression.");
6
+ <% end %>
7
+
@@ -18,5 +18,9 @@ editPanel.html("");
18
18
  <% elsif @content_type == 'link' %>
19
19
  editPanel.html("<%= j(render 'link_edit_panel') %>");
20
20
  <% end %>
21
-
21
+ <% if @repeat %>
22
+ $("#element_actions").show();
23
+ <% else %>
24
+ $("#element_actions").hide();
25
+ <% end %>
22
26
  editPanel.slideDown("fast");
@@ -1,3 +1,3 @@
1
1
  module Sibu
2
- VERSION = '0.1.15'
2
+ VERSION = '0.1.16'
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.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Baptiste Vilain
@@ -148,12 +148,14 @@ files:
148
148
  - app/views/sibu/images/new.html.erb
149
149
  - app/views/sibu/images/show.html.erb
150
150
  - app/views/sibu/pages/_custom_styles.html.erb
151
+ - app/views/sibu/pages/_element_actions.html.erb
151
152
  - app/views/sibu/pages/_form.html.erb
152
153
  - app/views/sibu/pages/_link_edit_panel.html.erb
153
154
  - app/views/sibu/pages/_media_edit_panel.html.erb
154
155
  - app/views/sibu/pages/_text_edit_panel.html.erb
155
156
  - app/views/sibu/pages/clone_element.js.erb
156
157
  - app/views/sibu/pages/clone_section.js.erb
158
+ - app/views/sibu/pages/delete_element.js.erb
157
159
  - app/views/sibu/pages/delete_section.js.erb
158
160
  - app/views/sibu/pages/destroy.html.erb
159
161
  - app/views/sibu/pages/edit.html.erb