active_admin_jcrop 0.0.7 → 0.0.9
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/active_admin_jcrop/crop_modal.js.coffee +32 -2
- data/app/assets/stylesheets/active_admin_jcrop/crop_modal.css +3 -0
- data/app/views/active_admin_jcrop/_jcrop_modal.html.erb +2 -1
- data/lib/active_admin_jcrop/version.rb +1 -1
- data/lib/formtastic/inputs/jcrop_input.rb +21 -6
- data/spec/dummy/log/test.log +0 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b03393f55f2e7881e3168b565fb83aedeb07594
|
4
|
+
data.tar.gz: 2ad93b59eb75b9e5d5a85625873b0506a2bb2ad6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3740f7f1e85f17c8a25691a8918882897c6752422f0cd3746ed2f2d4c76103729d1a4777bf279cee1d9dd585d0ea5339f5b749f9544155fa9c2f6aca4c4d9645
|
7
|
+
data.tar.gz: 10ba7db5c5eaaaf992a4754477aa4acc89fe9adc2318fb20ebfd4b853cacaaf15bd41d3301fe65e9a4788da689d19439d517e0c8abd77cbb499d0c3d98ec5e90
|
@@ -44,14 +44,44 @@ window.active_admin_jcrop =
|
|
44
44
|
|
45
45
|
}
|
46
46
|
]
|
47
|
-
|
48
|
-
|
47
|
+
options = $.extend {}, image.data('jcropOptions')
|
48
|
+
options.onSelect = (coords) ->
|
49
|
+
update_cropper(coords)
|
50
|
+
if image.data('jcropOptions').showDimensions
|
51
|
+
content.find('.crop_modal_dimensions').first().text("#{coords.w}x#{coords.h}")
|
52
|
+
if fn = image.data('jcropOptions').onSelect
|
53
|
+
if typeof fn is 'string'
|
54
|
+
window[fn] coords
|
55
|
+
else if typeof fn is 'function'
|
56
|
+
fn coords
|
57
|
+
return
|
58
|
+
options.onChange = (coords) ->
|
59
|
+
update_cropper(coords)
|
60
|
+
if image.data('jcropOptions').showDimensions
|
61
|
+
content.find('.crop_modal_dimensions').first().text("#{coords.w}x#{coords.h}")
|
62
|
+
if fn = image.data('jcropOptions').onChange
|
63
|
+
if typeof fn is 'string'
|
64
|
+
window[fn] coords
|
65
|
+
else if typeof fn is 'function'
|
66
|
+
fn coords
|
67
|
+
return
|
68
|
+
options.onRelease = ->
|
69
|
+
if fn = image.data('jcropOptions').onRelease
|
70
|
+
if typeof fn is 'string'
|
71
|
+
window[fn] coords
|
72
|
+
else if typeof fn is 'function'
|
73
|
+
fn coords
|
74
|
+
return
|
75
|
+
image.Jcrop(options)
|
76
|
+
return
|
49
77
|
|
50
78
|
update_cropper = (coords) ->
|
51
79
|
active_admin_jcrop.cropper.crop_x = coords.x
|
52
80
|
active_admin_jcrop.cropper.crop_y = coords.y
|
53
81
|
active_admin_jcrop.cropper.crop_w = coords.w
|
54
82
|
active_admin_jcrop.cropper.crop_h = coords.h
|
83
|
+
return
|
84
|
+
return
|
55
85
|
|
56
86
|
$ ->
|
57
87
|
active_admin_jcrop.start()
|
@@ -2,11 +2,12 @@
|
|
2
2
|
|
3
3
|
<%= content_tag :div, class: "crop_modal_content" do %>
|
4
4
|
<center>
|
5
|
+
<div class="crop_modal_dimensions"></div>
|
5
6
|
<%= image_tag object.send(field).url, class: 'cropping_image', data: {
|
6
7
|
object_class: object.class.to_s.underscore,
|
7
8
|
object_id: object.id,
|
8
9
|
crop_field: field,
|
9
|
-
|
10
|
+
jcropper_url: send("jcropper_#{ActiveAdmin.application.default_namespace.to_s}_#{object.class.to_s.demodulize.underscore}_path", object),
|
10
11
|
translate_save_cropped_image: I18n.t("active_admin.crop.save_cropped_image").titleize,
|
11
12
|
translate_cancel: I18n.t("active_admin.crop.cancel").titleize,
|
12
13
|
jcrop_options: jcrop_options.to_json
|
@@ -2,31 +2,46 @@ module Formtastic
|
|
2
2
|
module Inputs
|
3
3
|
class JcropableInput < ::Formtastic::Inputs::FileInput
|
4
4
|
include Base
|
5
|
-
|
5
|
+
|
6
|
+
VALID_OPTIONS = %i(
|
7
|
+
aspectRatio
|
8
|
+
minSize
|
9
|
+
maxSize
|
10
|
+
setSelect
|
11
|
+
bgColor
|
12
|
+
bgOpacity
|
13
|
+
boxWidth
|
14
|
+
boxHeight
|
15
|
+
onSelect
|
16
|
+
onChange
|
17
|
+
onRelease
|
18
|
+
showDimensions
|
19
|
+
)
|
20
|
+
|
6
21
|
def to_html
|
7
22
|
input_wrapping do
|
8
23
|
label_html <<
|
9
24
|
builder.file_field(method, input_html_options) <<
|
10
25
|
jcrop_feature
|
11
26
|
end
|
12
|
-
end
|
27
|
+
end
|
13
28
|
|
14
29
|
private
|
15
30
|
|
16
31
|
def jcrop_feature
|
17
32
|
if @object.send(method).present?
|
18
|
-
template.render(partial: "active_admin_jcrop/jcrop_modal", locals: {field: method, object: @object, jcrop_options: jcrop_options})
|
19
|
-
else
|
33
|
+
template.render(partial: "active_admin_jcrop/jcrop_modal", locals: {field: method, object: @object, jcrop_options: jcrop_options})
|
34
|
+
else
|
20
35
|
''
|
21
36
|
end
|
22
37
|
end
|
23
38
|
|
24
39
|
def jcrop_options
|
25
40
|
options[:jcrop_options] ||= {}
|
26
|
-
options[:jcrop_options].assert_valid_keys(
|
41
|
+
options[:jcrop_options].assert_valid_keys(*VALID_OPTIONS)
|
27
42
|
options[:jcrop_options].reverse_merge!(setSelect: [0,0,100,100])
|
28
43
|
end
|
29
44
|
|
30
45
|
end
|
31
46
|
end
|
32
|
-
end
|
47
|
+
end
|
data/spec/dummy/log/test.log
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_admin_jcrop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Nacif
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -311,7 +311,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
311
311
|
version: '0'
|
312
312
|
requirements: []
|
313
313
|
rubyforge_project:
|
314
|
-
rubygems_version: 2.
|
314
|
+
rubygems_version: 2.4.5
|
315
315
|
signing_key:
|
316
316
|
specification_version: 4
|
317
317
|
summary: Jcrop plugin for ActiveAdmin, enable image cropping solution on image fields
|