crimagify 0.0.4.0 → 0.0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,8 @@ $(function(){
15
15
  $new_fieldset.find(".parent").attr('name',$this.data('parentobject')+'['+$this.data('parent')+'_attributes]['+i+'][parent]');
16
16
  $new_fieldset.find(".parent_id").attr('name',$this.data('parentobject')+'['+$this.data('parent')+'_attributes]['+i+'][parent_id]');
17
17
  $new_fieldset.find(".id_images").attr('name',$this.data('parentobject')+'['+$this.data('parent')+'_attributes]['+i+'][id_images]');
18
+ // $new_fieldset.find(".remove").attr('name',$this.data('parentobject')+'['+$this.data('parent')+'_attributes]['+i+'][_destroy]');
19
+ // $fieldset.find(".remove").removeAttr("id");
18
20
  var imagesTemporal = $new_fieldset.find(".image_temporal");
19
21
  for(var j = 0; j<imagesTemporal.length;j++){
20
22
  var $inputImage = $(imagesTemporal[j]);
@@ -37,6 +39,8 @@ $(function(){
37
39
  $fieldset.find(".parent").attr('name',$this.data('parentobject')+'['+$this.data('parent')+'_attributes]['+time+'][parent]');
38
40
  $fieldset.find(".parent_id").attr('name',$this.data('parentobject')+'['+$this.data('parent')+'_attributes]['+time+'][parent_id]');
39
41
  $fieldset.find(".id_images").attr('name',$this.data('parentobject')+'['+$this.data('parent')+'_attributes]['+time+'][id_images]');
42
+ // $fieldset.find(".remove").attr('name',$this.data('parentobject')+'['+$this.data('parent')+'_attributes]['+time+'][_destroy]');
43
+ // $fieldset.find(".remove").removeAttr("id");
40
44
  var imagesTemporal = $fieldset.find(".image_temporal");
41
45
  for(var i = 0; i<imagesTemporal.length;i++){
42
46
  var $inputImage = $(imagesTemporal[i]);
@@ -61,10 +65,14 @@ function getTime(){
61
65
 
62
66
  function setAttributesNames($form){
63
67
  var $fieldset = $form.find(".fieldset_crimagify_nested");
68
+ // var $remove = $fieldset.find(".remove")
69
+ // for(var r = 0; r)
64
70
  $fieldset.attr("id","nested_0");
65
71
  $fieldset.find(".parent").attr("name",$form.data("parentobject")+"["+$form.data("parent")+"_attributes]["+0+"][parent]");
66
72
  $fieldset.find(".parent_id").attr("name",$form.data("parentobject")+"["+$form.data("parent")+"_attributes]["+0+"][parent_id]");
67
73
  $fieldset.find(".id_images").attr("name",$form.data("parentobject")+"["+$form.data("parent")+"_attributes]["+0+"][id_images]");
74
+ // $fieldset.find(".remove").attr("name",$form.data("parentobject")+"["+$form.data("parent")+"_attributes]["+0+"][_destroy]");
75
+ // $fieldset.find(".remove").removeAttr("id");
68
76
  var imagesTemporal = $fieldset.find(".image_temporal");
69
77
  for(var i = 0; i<imagesTemporal.length;i++){
70
78
  var $inputImage = $(imagesTemporal[i]);
@@ -27,4 +27,12 @@
27
27
  <div class="crimagify_clear"></div>
28
28
  </div>
29
29
  </div>
30
+
31
+ <!--<div class="control-group string">
32
+ <div class="rigth_element">
33
+ <%#= hidden_field :_destroy,nil, :class => "remove" %>
34
+ <%#= link_to "Remove this Product <i class='icon-remove'></i>".html_safe, '#', class: "remove_fields btn btn-danger" %>
35
+ </div>
36
+ <div class="clear"></div>
37
+ </div>-->
30
38
  </div>
@@ -79,7 +79,7 @@ module Crimagify
79
79
 
80
80
  save_parent_values["#{object.class.name.underscore}_id"] = object.id
81
81
  parent_class = parent.constantize
82
- if parent_id = ''
82
+ if parent_id == ''
83
83
  save_parent = parent_class.new(save_parent_values)
84
84
  if save_parent.save
85
85
  if id_array != []
@@ -114,41 +114,44 @@ module Crimagify
114
114
  end
115
115
  end
116
116
  else
117
- save_parent = parent_class.find(parent_id)
118
- if save_parent.update_attributes(save_parent_values)
119
- if id_array != []
120
- id_array.map { |image_name|
121
- path = value["image_temporal_#{image_name}"]
122
- if path.to_s != "" && File.exist?(path.to_s)
123
- image = save_parent.crimagify_images.where("image_name=?", image_name)
124
- if image != []
125
- image.map { |img|
126
- img.update_attributes(:image => File.open(path.to_s),
127
- :crop_x => value["#{image_name}_crop_x"],
128
- :crop_y => value["#{image_name}_crop_y"],
129
- :crop_w => value["#{image_name}_crop_w"],
130
- :crop_h => value["#{image_name}_crop_h"])
117
+ object_parent_image = parent_class.find(parent_id)
118
+ if value[:_destroy]
119
+ object_parent_image.destroy
120
+ else
121
+ if object_parent_image.update_attributes(save_parent_values)
122
+ if id_array != []
123
+ id_array.map { |image_name|
124
+ path = value["image_temporal_#{image_name}"]
125
+ if path.to_s != "" && File.exist?(path.to_s)
126
+ image = object_parent_image.crimagify_images.where("image_name=?", image_name)
127
+ if image != []
128
+ image.map { |img|
129
+ img.update_attributes(:image => File.open(path.to_s),
130
+ :crop_x => value["#{image_name}_crop_x"],
131
+ :crop_y => value["#{image_name}_crop_y"],
132
+ :crop_w => value["#{image_name}_crop_w"],
133
+ :crop_h => value["#{image_name}_crop_h"])
134
+ img.crop_avatar_real
135
+ }
136
+ else
137
+ img = save_new_image(path,
138
+ value["#{image_name}_crop_x"],
139
+ value["#{image_name}_crop_y"],
140
+ value["#{image_name}_crop_w"],
141
+ value["#{image_name}_crop_h"],
142
+ object_parent_image.class.name,
143
+ object_parent_image.id,
144
+ image_name,
145
+ false)
146
+ img.save!
131
147
  img.crop_avatar_real
132
- }
133
- else
134
- img = save_new_image(path,
135
- value["#{image_name}_crop_x"],
136
- value["#{image_name}_crop_y"],
137
- value["#{image_name}_crop_w"],
138
- value["#{image_name}_crop_h"],
139
- save_parent.class.name,
140
- save_parent.id,
141
- image_name,
142
- false)
143
- img.save!
144
- img.crop_avatar_real
148
+ end
145
149
  end
146
- end
147
- }
148
- end
149
- end
150
- end
151
-
150
+ }
151
+ end
152
+ end
153
+ end
154
+ end
152
155
  end
153
156
  else
154
157
  if params[:id_images] != ""
@@ -1,3 +1,3 @@
1
1
  module Crimagify
2
- VERSION = "0.0.4.0"
2
+ VERSION = "0.0.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crimagify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.0
4
+ version: 0.0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-08 00:00:00.000000000 Z
12
+ date: 2013-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -189,7 +189,6 @@ files:
189
189
  - test/dummy/config/locales/en.yml
190
190
  - test/dummy/config/routes.rb
191
191
  - test/dummy/config.ru
192
- - test/dummy/db/development.sqlite3
193
192
  - test/dummy/db/migrate/20130423160421_create_crimagify_images.crimagify.rb
194
193
  - test/dummy/db/migrate/20130423164431_create_users.rb
195
194
  - test/dummy/db/migrate/20130424155649_create_products.rb
@@ -288,7 +287,6 @@ test_files:
288
287
  - test/dummy/config/locales/en.yml
289
288
  - test/dummy/config/routes.rb
290
289
  - test/dummy/config.ru
291
- - test/dummy/db/development.sqlite3
292
290
  - test/dummy/db/migrate/20130423160421_create_crimagify_images.crimagify.rb
293
291
  - test/dummy/db/migrate/20130423164431_create_users.rb
294
292
  - test/dummy/db/migrate/20130424155649_create_products.rb
Binary file