sibu 0.1.15 → 0.1.16
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.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/sibu/sibu.css +4 -0
- data/app/controllers/sibu/pages_controller.rb +1 -0
- data/app/helpers/sibu/pages_helper.rb +5 -3
- data/app/models/concerns/sibu/sections_concern.rb +4 -0
- data/app/views/layouts/sibu/edit_content.html.erb +41 -7
- data/app/views/sibu/pages/_element_actions.html.erb +4 -0
- data/app/views/sibu/pages/_link_edit_panel.html.erb +1 -0
- data/app/views/sibu/pages/_media_edit_panel.html.erb +1 -1
- data/app/views/sibu/pages/_text_edit_panel.html.erb +1 -0
- data/app/views/sibu/pages/clone_element.js.erb +1 -0
- data/app/views/sibu/pages/delete_element.js.erb +7 -0
- data/app/views/sibu/pages/edit_element.js.erb +5 -1
- data/lib/sibu/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d011e2389e6f92f5a6058c7ad75604e1d7871b67
|
4
|
+
data.tar.gz: e0cf4f17e0405ba1b2ebdd4511ad97eb9fcf18c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3814575a898d0e48a307392c60b9478af5e027aafbdbbc36d3be9fcb59f51a32bbab60bde845b80e427693aeef6e96264110d8bbfa354fe5ad8840bd9ee30426
|
7
|
+
data.tar.gz: 8036525bf448ef2f53fcde1a0ac067f102735f3287ebece966629035ab53298a9e881403806487bc41fc61049130593bda08a07f43f908313c3a67375f9428ce
|
@@ -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
|
-
|
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
|
@@ -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
|
-
|
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
|
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,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' %>
|
@@ -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");
|
data/lib/sibu/version.rb
CHANGED
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.
|
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
|