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 CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -1,65 +1,63 @@
1
- module CropImageRiffpad
2
- module CropImageHelper
3
- def crop_image_helper(model_name, attachment_name, style)
4
- @object = ActiveSupport::Inflector.constantize(ActiveSupport::Inflector.classify(model_name)).find(params[:id])
5
- html = [javascript_tag(%Q{
6
- $(function() {
7
- $('#cropbox').Jcrop({
8
- onChange: update_crop,
9
- onSelect: update_crop,
10
- setSelect: [10, 10, 100, 100],
11
- aspectRatio: 1
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
- function update_crop(coords) {
16
- var rx = 100/coords.w;
17
- var ry = 100/coords.h;
18
- $('#preview').css({
19
- width: Math.round(rx * #{@object.send("#{attachment_name}_geometry", style).width}) + 'px',
20
- height: Math.round(ry * #{@object.send("#{attachment_name}_geometry", style).height}) + 'px',
21
- marginLeft: '-' + Math.round(rx * coords.x) + 'px',
22
- marginTop: '-' + Math.round(ry * coords.y) + 'px'
23
- });
24
- var ratio = #{@object.send("#{attachment_name}_geometry", :original).width} / #{@object.send("#{attachment_name}_geometry", style).width};
25
- $("#crop_x").val(Math.round(coords.x * ratio));
26
- $("#crop_y").val(Math.round(coords.y * ratio));
27
- $("#crop_w").val(Math.round(coords.w * ratio));
28
- $("#crop_h").val(Math.round(coords.h * ratio));
29
- }
30
- }
31
- )]
32
- html << content_tag(:div, id: "content") do
33
- content_tag(:div, class: "form_show") do
34
- [content_tag(:div, class: "fs-header") do
35
- content_tag(:p, "Edit Your Profile Photo", class: "fs-title")
36
- end,
37
- content_tag(:div, class: "fs-content") do
38
- [content_tag(:p, "Position or align your photo by resizing the square below.", class: "fs-c-h1"),
39
- 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
40
- end,
41
- content_tag(:div, class: "image_2") do
42
- image_tag(@object.send("#{attachment_name}").url(style), id: "preview",)
43
- end,
44
- content_tag(:div, class: "clr") do end,
45
- content_tag(:div, class: "border-1") do end,
46
- content_tag(:div, class: "image_1") do
47
- image_tag(@object.send("#{attachment_name}").url(style), id: "cropbox")
48
- end,
49
- content_tag(:div, class: "border-1") do end,
50
- (form_for @object do |f|
51
- fields_array = []
52
- fields_array << hidden_field_tag("crop", true)
53
- for attribute in [:crop_x, :crop_y, :crop_w, :crop_h]
54
- fields_array << f.hidden_field(attribute, :id => attribute)
55
- end
56
- fields_array << f.submit("Save", class: "button_submit")
57
- fields_array.join.html_safe
58
- end)].join.html_safe
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "cropimage_riffpad"
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["thanh tuan"]
@@ -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.0
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: 235356320116763177
171
+ hash: 2345849181653491245
172
172
  required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  none: false
174
174
  requirements: