cropimage_riffpad 0.1.0 → 0.1.1
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.
- data/VERSION +1 -1
- data/app/helpers/cropimage_riffpad/crop_image_helper.rb +59 -61
- data/cropimage_riffpad.gemspec +1 -1
- data/lib/cropimage_riffpad.rb +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -1,65 +1,63 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
});
|
1
|
+
module CropimageRiffpad::CropImageHelper
|
2
|
+
def crop_image_helper(model_name, attachment_name, style)
|
3
|
+
@object = ActiveSupport::Inflector.constantize(ActiveSupport::Inflector.classify(model_name)).find(params[:id])
|
4
|
+
html = [javascript_tag(%Q{
|
5
|
+
$(function() {
|
6
|
+
$('#cropbox').Jcrop({
|
7
|
+
onChange: update_crop,
|
8
|
+
onSelect: update_crop,
|
9
|
+
setSelect: [10, 10, 100, 100],
|
10
|
+
aspectRatio: 1
|
11
|
+
});
|
12
|
+
});
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
14
|
+
function update_crop(coords) {
|
15
|
+
var rx = 100/coords.w;
|
16
|
+
var ry = 100/coords.h;
|
17
|
+
$('#preview').css({
|
18
|
+
width: Math.round(rx * #{@object.send("#{attachment_name}_geometry", style).width}) + 'px',
|
19
|
+
height: Math.round(ry * #{@object.send("#{attachment_name}_geometry", style).height}) + 'px',
|
20
|
+
marginLeft: '-' + Math.round(rx * coords.x) + 'px',
|
21
|
+
marginTop: '-' + Math.round(ry * coords.y) + 'px'
|
22
|
+
});
|
23
|
+
var ratio = #{@object.send("#{attachment_name}_geometry", :original).width} / #{@object.send("#{attachment_name}_geometry", style).width};
|
24
|
+
$("#crop_x").val(Math.round(coords.x * ratio));
|
25
|
+
$("#crop_y").val(Math.round(coords.y * ratio));
|
26
|
+
$("#crop_w").val(Math.round(coords.w * ratio));
|
27
|
+
$("#crop_h").val(Math.round(coords.h * ratio));
|
28
|
+
}
|
29
|
+
}
|
30
|
+
)]
|
31
|
+
html << content_tag(:div, id: "content") do
|
32
|
+
content_tag(:div, class: "form_show") do
|
33
|
+
[content_tag(:div, class: "fs-header") do
|
34
|
+
content_tag(:p, "Edit Your Profile Photo", class: "fs-title")
|
35
|
+
end,
|
36
|
+
content_tag(:div, class: "fs-content") do
|
37
|
+
[content_tag(:p, "Position or align your photo by resizing the square below.", class: "fs-c-h1"),
|
38
|
+
content_tag(:p, "You can see how these changes will appear in your profile in the image on the right.", class: "fs-c-h2")].join.html_safe
|
39
|
+
end,
|
40
|
+
content_tag(:div, class: "image_2") do
|
41
|
+
image_tag(@object.send("#{attachment_name}").url(style), id: "preview",)
|
42
|
+
end,
|
43
|
+
content_tag(:div, class: "clr") do end,
|
44
|
+
content_tag(:div, class: "border-1") do end,
|
45
|
+
content_tag(:div, class: "image_1") do
|
46
|
+
image_tag(@object.send("#{attachment_name}").url(style), id: "cropbox")
|
47
|
+
end,
|
48
|
+
content_tag(:div, class: "border-1") do end,
|
49
|
+
(form_for @object do |f|
|
50
|
+
fields_array = []
|
51
|
+
fields_array << hidden_field_tag("crop", true)
|
52
|
+
for attribute in [:crop_x, :crop_y, :crop_w, :crop_h]
|
53
|
+
fields_array << f.hidden_field(attribute, :id => attribute)
|
54
|
+
end
|
55
|
+
fields_array << f.submit("Save", class: "button_submit")
|
56
|
+
fields_array.join.html_safe
|
57
|
+
end)].join.html_safe
|
60
58
|
end
|
61
|
-
|
62
|
-
html.join.html_safe
|
63
59
|
end
|
60
|
+
|
61
|
+
html.join.html_safe
|
64
62
|
end
|
65
|
-
end
|
63
|
+
end
|
data/cropimage_riffpad.gemspec
CHANGED
data/lib/cropimage_riffpad.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'cropimage_riffpad/crop_image_controller'
|
2
2
|
require 'cropimage_riffpad/crop_image_model'
|
3
3
|
require 'cropimage_riffpad/paperclip_processors/cropper'
|
4
|
-
require 'cropimage_riffpad/crop_image_helper'
|
4
|
+
# require 'cropimage_riffpad/crop_image_helper'
|
5
5
|
require 'new_responds_to_parent'
|
6
6
|
|
7
7
|
module CropImageRiffpad
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cropimage_riffpad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -168,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
168
168
|
version: '0'
|
169
169
|
segments:
|
170
170
|
- 0
|
171
|
-
hash:
|
171
|
+
hash: 2345849181653491245
|
172
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
173
|
none: false
|
174
174
|
requirements:
|