ack_rails_admin_jcrop 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13e72edc6e6ed63c6cd118009e26c277dac8fe6c
4
- data.tar.gz: 966e0bc8e5c40c4ec6b45412cd0039b66d48e6eb
3
+ metadata.gz: e6be68f7add71d4fa568ceaade4035e7422e705a
4
+ data.tar.gz: fa922ff3e42d6bf637ab383c7520b483745b398a
5
5
  SHA512:
6
- metadata.gz: ca19b55f93ff61844c28db8f8d62e2151e74b9724af7f407cbbc3127488ac4850c7f5c730ec1fd5c2071cc4976e1ace2fa97e57dd8cda9f33791c229cfe38ca9
7
- data.tar.gz: 47905ee8778fdd1bb5d6a0924c7d422d6c80081b21606ae2bdc3df60526ba7f98f12ba2008efde6961dad1ebbfafff7313cc72fd1ca610a98ee016fb3d57cfc3
6
+ metadata.gz: 88b8d78a2f9271f0d28c40f9a6d59dd155ef770cb7438de716b74f6e98abb7e30ea7b864596a529c16e892b1b04ff86e06093271fea367fe59e4e4c2d1a63402
7
+ data.tar.gz: 95a535e8ecd264493415a8b5eefb41b67a1e28319232c71d3915a049cc5beedd59507ca644c1ecc6b900826e7bf81eea3d282b670ab8d7bf277006b5f70cec48
@@ -5,11 +5,37 @@
5
5
  var widget = this;
6
6
  var dom_widget = widget.element;
7
7
 
8
- var thumbnailLink = dom_widget.find('.jcrop_data_value');
8
+ var thumbnailLink = dom_widget.find('.jcrop_data_value .preview');
9
9
  thumbnailLink.unbind().bind("click", function(e){
10
10
  widget._bindModalOpening(e, dom_widget.find('a.jcrop_handle').data('link'));
11
11
  return false;
12
12
  });
13
+ dom_widget.find('[data-fileupload]').unbind("change").bind("change", function() {
14
+ var input = this;
15
+ var image_container = $("#" + input.id).parent().children(".preview");
16
+ if (image_container.length > 0) {
17
+ if (image_container[0].tagName != "img") {
18
+ image_container.parent().removeClass("jcrop_data_value");
19
+ image_container.remove();
20
+ }
21
+ image_container = $("#" + input.id).parent().children(".preview");
22
+ }
23
+ if (image_container.length == 0) {
24
+ image_container = $("#" + input.id).parent().prepend($('<img />').addClass('preview')).find('img.preview');
25
+ image_container.parent().find('img:not(.preview)').hide();
26
+ ext = $("#" + input.id).val().split('.').pop().toLowerCase();
27
+ }
28
+ if (input.files && input.files[0] && $.inArray(ext, ['gif', 'png', 'jpg', 'jpeg', 'bmp']) != -1) {
29
+ reader = new FileReader();
30
+ reader.onload = function (e) {
31
+ image_container.attr("src", e.target.result);
32
+ };
33
+ reader.readAsDataURL(input.files[0]);
34
+ image_container.show();
35
+ } else {
36
+ image_container.hide();
37
+ }
38
+ })
13
39
  },
14
40
 
15
41
  _bindModalOpening: function(e, url) {
@@ -49,6 +75,7 @@
49
75
 
50
76
  var jcrop_options = $.extend({
51
77
  bgColor: 'white',
78
+ bgOpacity: 0.4,
52
79
  keySupport: false,
53
80
  onSelect: widget.updateCoordinates
54
81
  }, widget.element.find('input[data-rails-admin-jcrop-options]').data('rails-admin-jcrop-options'));
@@ -130,7 +157,7 @@
130
157
  show: true
131
158
  })
132
159
  .on('hidden.bs.modal', function(){
133
- $(document).unbind("keyup")
160
+ $(document).unbind("keyup");
134
161
  widget.dialog.remove(); // We don't want to reuse closed modals
135
162
  widget.dialog = null;
136
163
  });
@@ -1,11 +1,13 @@
1
1
  .jcrop_data_value
2
2
  cursor: pointer
3
3
  display: inline-block
4
- &:hover
5
- font-weight: bold
6
- &:active
7
- .title_link_hint
8
- color: black
4
+ .preview
5
+ &:hover
6
+ .title_link_hint
7
+ font-weight: bold
8
+ &:active
9
+ .title_link_hint
10
+ color: black
9
11
  .title_link_hint
10
12
  color: blue
11
13
  display: inline-block
@@ -18,3 +20,7 @@
18
20
 
19
21
  .jcrop-holder, .jcrop-subject
20
22
  max-width: 960px !important
23
+
24
+ .jcrop-holder
25
+ border: 1px solid black
26
+ margin: 0px auto
@@ -14,11 +14,12 @@
14
14
 
15
15
  - file = form.object.send(field.method_name).presence
16
16
 
17
- .toggle{style=('display:none;' if file and field.delete_method and form.object.send(field.delete_method) == '1')}
17
+ - _add_class = field.pretty_value ? "jcrop_data_value" : ""
18
+ .toggle{class="#{_add_class}" style=('display:none;' if file and field.delete_method and form.object.send(field.delete_method) == '1')}
18
19
  - if value = field.pretty_value
19
- .jcrop_data_value
20
+ .preview
20
21
  .title_link_hint= "Обрезать"
21
- div
22
+ .image_block
22
23
  = value
23
24
  = form.file_field(field.name, field.html_attributes.reverse_merge({data: {fileupload: true, rails_admin_jcrop_options: rails_admin_jcrop_options } }))
24
25
 
@@ -1,3 +1,3 @@
1
1
  module RailsAdminJcrop
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ack_rails_admin_jcrop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ack43
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-05 00:00:00.000000000 Z
12
+ date: 2015-06-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails