sibu 0.6.9 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/sibu/sibu.js.erb +53 -24
- data/app/assets/stylesheets/sibu/defaults.scss +13 -0
- data/app/assets/stylesheets/sibu/sibu.css +0 -1
- data/app/helpers/sibu/pages_helper.rb +3 -2
- data/app/models/concerns/sibu/image_uploader.rb +1 -3
- data/app/models/sibu/image.rb +4 -0
- data/app/views/sibu/pages/_media_edit_panel.html.erb +6 -5
- data/app/views/sibu/pages/edit_element.js.erb +14 -14
- data/lib/sibu/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9ddba74b9a3e07f92b235acc1e3e55296b4a089
|
4
|
+
data.tar.gz: 3bf94af416c1228aa9f9f2f364ff1ebfafdba401
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9feac3ec7a28165c73edb37cd9c2c3dc47e2a81b8b7efbfab5253fc87e3fc12c3f44fa19f1ba0f653e2e93dc7ce7521ddce3b3153ae8091019809a958acfb9b6
|
7
|
+
data.tar.gz: 24c55a51899aa8c68b7fda529dfa50b469a14a072df6a86329c8adfffd633bd83271fc407b9a7239c9639d76ca59dfba41b6cfaa81b26f7a810fa912b6911b20
|
@@ -2,7 +2,6 @@
|
|
2
2
|
//= require jquery_ujs
|
3
3
|
//= require sibu/common
|
4
4
|
//= require ../quill/quill
|
5
|
-
//= require ../cropper/cropper
|
6
5
|
//= require_self
|
7
6
|
|
8
7
|
var Inline = Quill.import('blots/inline');
|
@@ -110,31 +109,61 @@ function initQuillEditor(container) {
|
|
110
109
|
return quill;
|
111
110
|
}
|
112
111
|
|
113
|
-
function
|
114
|
-
var wrapper = $(".
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
}
|
112
|
+
function initCustomCenter() {
|
113
|
+
var wrapper = $(".sibu_center > img"), centerPos = $(".sibu_center > #sibu_center_pos");
|
114
|
+
displayCurrentCenter(wrapper[0], centerPos);
|
115
|
+
wrapper.click(function(e) {
|
116
|
+
var rect = e.target.getBoundingClientRect();
|
117
|
+
var x = e.clientX - rect.left;
|
118
|
+
var y = e.clientY - rect.top;
|
119
|
+
console.log('x : ' + x + ' - y : ' + y);
|
120
|
+
centerPos.css("top", y + "px");
|
121
|
+
centerPos.css("left", x + "px");
|
122
|
+
$("#element_class").val(`posx_${Math.floor((x / rect.width) * 10) * 10} posy_${Math.floor((y / rect.height) * 10) * 10}`);
|
123
|
+
})
|
124
|
+
}
|
125
|
+
|
126
|
+
function displayCurrentCenter(img, centerPos) {
|
127
|
+
var val = $("#element_class").val();
|
128
|
+
var rect = img.getBoundingClientRect();
|
129
|
+
if (val && val.indexOf('posx') !== -1 && val.indexOf('posy') !== -1) {
|
130
|
+
var xpos = val.slice(val.indexOf("posx_") + 5, val.indexOf("posx_") + 7);
|
131
|
+
var ypos = val.slice(val.indexOf("posy_") + 5, val.indexOf("posy_") + 7);
|
132
|
+
centerPos.css("top", Math.round(+ypos * (rect.height / 100)) + "px");
|
133
|
+
centerPos.css("left", Math.round(+xpos * (rect.width / 100)) + "px");
|
134
|
+
} else {
|
135
|
+
centerPos.css("top", (Math.round(rect.height / 2) - 15) + "px");
|
136
|
+
centerPos.css("left", (Math.round(rect.width / 2) - 7) + "px");
|
137
|
+
}
|
138
|
+
centerPos.show();
|
136
139
|
}
|
137
140
|
|
141
|
+
|
142
|
+
//function initCropper(imgId) {
|
143
|
+
// var wrapper = $(".sibu_crop").first();
|
144
|
+
// var srcImg = $("#content_panel").find(".sb-editing img[data-id='" + imgId + "']").first();
|
145
|
+
// var srcContainer = srcImg.parent();
|
146
|
+
// var ratio = parseFloat(srcContainer.css("width")) / parseFloat(wrapper.css("width"));
|
147
|
+
// var wrapperHeight = Math.min(320, parseFloat(srcContainer.css("height")) / ratio) + "px";
|
148
|
+
// wrapper.css("height", wrapperHeight);
|
149
|
+
// return new Cropper(wrapper.find("img")[0], {
|
150
|
+
// crop: function(event) {
|
151
|
+
// var data = event.detail;
|
152
|
+
// var cropper = this.cropper;
|
153
|
+
// var imageData = cropper.getImageData();
|
154
|
+
// var previewWidth = parseFloat(srcContainer.css("width"));
|
155
|
+
// var imageScaledRatio = data.width / previewWidth;
|
156
|
+
// var width = imageData.naturalWidth / imageScaledRatio + 'px';
|
157
|
+
// var height = imageData.naturalHeight / imageScaledRatio + 'px';
|
158
|
+
// var marginLeft = -data.x / imageScaledRatio + 'px';
|
159
|
+
// var marginTop = -data.y / imageScaledRatio + 'px';
|
160
|
+
// // console.log("crop detail : " + JSON.stringify(data));
|
161
|
+
// // console.log('img data : ' + JSON.stringify(imageData));
|
162
|
+
// $("#element_style").val("width: " + width + "; height: " + height + "; margin-left: " + marginLeft + "; margin-top: " + marginTop +"; max-width: none; max-height: none;");
|
163
|
+
// }
|
164
|
+
// });
|
165
|
+
//}
|
166
|
+
|
138
167
|
function refreshAfterEdit(reload, sectionId) {
|
139
168
|
var baseUrl = window.location.href.split('?')[0];
|
140
169
|
if (reload) {
|
@@ -207,6 +207,19 @@ $sibu-color3 : #333 !default;
|
|
207
207
|
font-weight: bold;
|
208
208
|
}
|
209
209
|
}
|
210
|
+
|
211
|
+
.sibu_center {
|
212
|
+
position: relative;
|
213
|
+
|
214
|
+
#sibu_center_pos {
|
215
|
+
position: absolute;
|
216
|
+
z-index: 3;
|
217
|
+
font-size: 20px;
|
218
|
+
font-weight: bold;
|
219
|
+
color: white;
|
220
|
+
text-shadow: 0 2px grey;
|
221
|
+
}
|
222
|
+
}
|
210
223
|
}
|
211
224
|
|
212
225
|
#editor-container .ql-editor {
|
@@ -74,9 +74,10 @@ module Sibu
|
|
74
74
|
if action_name == 'show'
|
75
75
|
content["src"] = ("/#{conf[:deployment_path]}" + content["src"]) if @online && conf[:deployment_path]
|
76
76
|
else
|
77
|
-
opts.merge!({data: {id: elt_id(elt), type: "media", repeat: repeat, size: size}})
|
77
|
+
opts.merge!({data: {id: elt_id(elt), type: "media", repeat: repeat, size: size}})
|
78
78
|
end
|
79
|
-
wrapper ? content_tag(wrapper, content_tag(:img, nil, content.except("id")), opts)
|
79
|
+
wrapper ? content_tag(wrapper, content_tag(:img, nil, content.except("id")), opts)
|
80
|
+
: content_tag(:img, nil, content.except("id").merge(opts.stringify_keys) {|k, old, new| k == 'class' ? [old, new].join(' ') : new})
|
80
81
|
end
|
81
82
|
|
82
83
|
def grp(elt, opts = {}, &block)
|
@@ -11,10 +11,8 @@ class Sibu::ImageUploader < Shrine
|
|
11
11
|
images_config = Rails.application.config.sibu[:images]
|
12
12
|
image_type = io.mime_type
|
13
13
|
|
14
|
-
if image_type == "image/svg+xml"
|
15
|
-
|
14
|
+
if image_type == "image/svg+xml" || io.metadata['filename'].end_with?('.svg')
|
16
15
|
{original: io, large: io.download, medium: io.download, small: io.download}
|
17
|
-
|
18
16
|
else
|
19
17
|
large = resize_to_limit!(original, images_config[:large], images_config[:large]) {|cmd| cmd.auto_orient}
|
20
18
|
medium = resize_to_limit(large, images_config[:medium], images_config[:medium])
|
data/app/models/sibu/image.rb
CHANGED
@@ -17,3 +17,7 @@ module Sibu
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
# ['beds-green.svg', 'camp-white.svg', 'doc-green.svg', 'doc-white.svg', 'earth-white.svg', 'family-sec_blue.svg',
|
22
|
+
# 'family-white.svg', 'flag.svg', 'hands-green.svg', 'home-green.svg', 'house-white.svg', 'marker.svg', 'men-green.svg',
|
23
|
+
# 'money-blue.svg', 'money-green.svg', 'quotes.svg', 'tel-green.svg', 'tel-white.svg', 'tv-green.svg']
|
@@ -19,12 +19,13 @@
|
|
19
19
|
<% if @element["src"] == DEFAULT_IMG || @element["src"].blank? %>
|
20
20
|
<p>Veuillez sélectionner une image.</p>
|
21
21
|
<% end %>
|
22
|
-
<div class="
|
23
|
-
<%= check_box_tag('
|
24
|
-
<%= label_tag '
|
22
|
+
<div class="sibu_custom_center" style="display: <%= (@element["src"] == DEFAULT_IMG || @element["src"].blank?) ? 'none' : 'block' %>">
|
23
|
+
<%= check_box_tag('custom_center', true, !@element["class"].blank?, id: 'custom_center', class: 'checkbox') %>
|
24
|
+
<%= label_tag 'custom_center', "Recentrer l'image" %>
|
25
25
|
</div>
|
26
|
-
<div class="
|
26
|
+
<div class="sibu_center">
|
27
27
|
<%= image_tag(@element["src"]) unless @element["src"] == DEFAULT_IMG || @element["src"].blank? %>
|
28
|
+
<div id="sibu_center_pos" style="display: none;">✕</div>
|
28
29
|
</div>
|
29
30
|
<div class="sibu_field" style="display: <%= (@element["src"] == DEFAULT_IMG || @element["src"].blank?) ? 'none' : 'block' %>">
|
30
31
|
<%= label_tag 'element[alt]', 'Légende / texte alternatif' %>
|
@@ -34,7 +35,7 @@
|
|
34
35
|
</div>
|
35
36
|
<%= hidden_field_tag 'element[id]', @element["id"] %>
|
36
37
|
<%= hidden_field_tag 'element[src]', @element["src"] %>
|
37
|
-
<%= hidden_field_tag 'element[
|
38
|
+
<%= hidden_field_tag 'element[class]', @element["class"] %>
|
38
39
|
<%= hidden_field_tag :element_id, @element_id %>
|
39
40
|
<%= hidden_field_tag :section_id, @section_id %>
|
40
41
|
<%= hidden_field_tag :entity, @entity_type %>
|
@@ -39,36 +39,36 @@ editPanel.slideDown("fast", function() {
|
|
39
39
|
});
|
40
40
|
<% when 'media' %>
|
41
41
|
var images = editPanel.find(".sibu_image img");
|
42
|
-
var
|
42
|
+
var customCenter = $("#custom_center"), customCtr;
|
43
43
|
images.click(function() {
|
44
44
|
if(!$(this).hasClass('selected')) {
|
45
45
|
images.removeClass('selected');
|
46
46
|
$(this).addClass('selected');
|
47
47
|
$("#element_src").val($(this).data("src"));
|
48
48
|
$("#element_alt").val($(this).data("alt"));
|
49
|
-
editPanel.find(".
|
49
|
+
editPanel.find(".sibu_center").html('<img src="' + $("#element_src").val() + '"/>');
|
50
50
|
editPanel.find(".sibu_selected_image > p:first-child").hide();
|
51
|
-
editPanel.find(".sibu_selected_image").find(".
|
51
|
+
editPanel.find(".sibu_selected_image").find(".sibu_custom_center").show();
|
52
52
|
editPanel.find(".sibu_selected_image").find(".sibu_field").show();
|
53
|
-
if(
|
54
|
-
|
53
|
+
if(customCenter.is(":checked")) {
|
54
|
+
customCtr = initCustomCenter();
|
55
55
|
}
|
56
56
|
}
|
57
57
|
});
|
58
|
-
if(editPanel.find(".
|
59
|
-
if(
|
60
|
-
|
58
|
+
if(editPanel.find(".sibu_center img").size() > 0) {
|
59
|
+
if(customCenter.is(":checked")) {
|
60
|
+
customCtr = initCustomCenter("<%= @element_id %>");
|
61
61
|
}
|
62
62
|
}
|
63
|
-
|
63
|
+
customCenter.change(function() {
|
64
64
|
if($(this).is(":checked")) {
|
65
|
-
|
65
|
+
customCtr = initCustomCenter("<%= @element_id %>");
|
66
66
|
} else {
|
67
67
|
$("#element_style").val("");
|
68
|
-
$(".
|
69
|
-
if(cropper) {
|
70
|
-
cropper.destroy();
|
71
|
-
}
|
68
|
+
$(".sibu_center").attr("style", "");
|
69
|
+
// if(cropper) {
|
70
|
+
// cropper.destroy();
|
71
|
+
// }
|
72
72
|
}
|
73
73
|
});
|
74
74
|
<% when 'link' %>
|
data/lib/sibu/version.rb
CHANGED
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: 0.
|
4
|
+
version: 0.7.0
|
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: 2018-12-
|
11
|
+
date: 2018-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|