instant-upload 1.0.6 → 1.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3f59a9daabc53c2fecdfc404da75af9af990744
4
- data.tar.gz: 1f7598a779fef802e3f728b2f2c99bdc20e8308f
3
+ metadata.gz: 2f9159754dd8e297f07b7c7d6ab580946ffb6d95
4
+ data.tar.gz: 6bc6162cd19a1821e78b8fe0896c99b25578761c
5
5
  SHA512:
6
- metadata.gz: bbb16e632445148a0efe90577eb5b7d3f63271e092afa14bc7915a3d6b31de03375cf55851fcab25ac01b92fa6d37d78dfddfd912438835e8b4f42b4114c421a
7
- data.tar.gz: 16d04780ed932ac504317d1d4b58e94eafa41ac7dd78b573961649217c8b70f2eecff41bc21c5df73bf35ecc2957531aca496f85f151013a7397e31b7fe99cd5
6
+ metadata.gz: 5274617e2cb0f161b2d80247a5b79d119863c0169dab4f09fd646cafe467bf813029fec781708e72526bb9844ee51bf75e4ce6500f10791e87669b9afba0872c
7
+ data.tar.gz: 738c16d2c96d94bdad90372f435ffbfc159176042ed23fda9fedbb8d014eeb57334cc5f18803e1fd57c920600403e49e2a79ef045f58da5ac0a8b0b9275c6be8
@@ -2,3 +2,58 @@
2
2
 
3
3
  //= require instant_upload/single
4
4
  //= require instant_upload/multi
5
+
6
+ /**
7
+ * jQuery Unveil
8
+ * A very lightweight jQuery plugin to lazy load images
9
+ * http://luis-almeida.github.com/unveil
10
+ *
11
+ * Licensed under the MIT license.
12
+ * Copyright 2013 Luís Almeida
13
+ * https://github.com/luis-almeida
14
+ */
15
+
16
+ ;(function($) {
17
+
18
+ $.fn.unveil = function(threshold) {
19
+
20
+ var $w = $(window),
21
+ th = threshold || 0,
22
+ retina = window.devicePixelRatio > 1,
23
+ attrib = retina? "data-src-retina" : "data-src",
24
+ images = this,
25
+ loaded,
26
+ inview,
27
+ source;
28
+
29
+ this.one("unveil", function() {
30
+ source = this.getAttribute(attrib);
31
+ source = source || this.getAttribute("data-src");
32
+ if (source) this.setAttribute("src", source);
33
+ });
34
+
35
+ function unveil() {
36
+ inview = images.filter(function() {
37
+ var $e = $(this),
38
+ wt = $w.scrollTop(),
39
+ wb = wt + $w.height(),
40
+ et = $e.offset().top,
41
+ eb = et + $e.height();
42
+
43
+ return eb >= wt - th && et <= wb + th;
44
+ });
45
+
46
+ loaded = inview.trigger("unveil");
47
+ images = images.not(loaded);
48
+ }
49
+
50
+ $w.scroll(unveil);
51
+ $w.resize(unveil);
52
+
53
+ unveil();
54
+
55
+ return this;
56
+
57
+ };
58
+
59
+ })(jQuery);
@@ -33,9 +33,9 @@ app = angular.module('instantUpload', [])
33
33
  cursor: 'pointer'
34
34
  position: 'absolute'
35
35
  left: offset.left
36
- top: offset.top
36
+ top: $('.iu-multi-dropzone').outerHeight() / 2 + $selectFiles.outerHeight() / 2
37
37
  width: $selectFiles.width() + 10
38
- height: $selectFiles.height() + 10
38
+ height: $selectFiles.outerHeight() * 2
39
39
  'margin-left': -5
40
40
  'margin-top': -25
41
41
  'z-index': 2
@@ -151,6 +151,17 @@ app = angular.module('instantUpload', [])
151
151
  $this = $(this)
152
152
  $scope.files.push { path: $this.find('img').attr('src'), id: $this.data('id') }
153
153
 
154
- $ -> $scope.init($($element)) if !!window.FormData
154
+ $scope.remove = (index) ->
155
+ $scope.files.splice(index, 1)
156
+
157
+ file = $scope.files[index]
158
+
159
+ $.ajax
160
+ url: $($element).parents('form').attr('action')
161
+ method: 'POST'
162
+ data: {iu_remove: true, index: index, offer: { id: 'true' } }
163
+
164
+ $ ->
165
+ $scope.init($($element)) if !!window.FormData
155
166
 
156
167
  ]
@@ -4,17 +4,18 @@
4
4
  = file_field_tag "#{record.class.name.downcase}[#{field}_attributes][][#{options[:multi]}]", multiple: true
5
5
 
6
6
  .iu-multi-select
7
- drag & drop or
8
- = link_to 'select file from disk', '#', class: 'iu-multi-select-files'
7
+ = t 'instant_upload.drag_and_drop'
8
+ = link_to t('instant_upload.select_files'), '#', class: 'iu-multi-select-files'
9
9
 
10
10
  %ul.iu-multi-files-cache
11
11
  - record.send(field).each do |img|
12
12
  %li{ data: { id: img.id } }= image_tag img.send(options[:multi]).send(options[:version]).url
13
13
 
14
- .iu-alert Too much, only #{options[:limit]}
14
+ .alert.iu-alert= t 'instant_upload.too_much', limit: options[:limit]
15
15
 
16
16
  %ul.iu-multi-files
17
17
  %li{ 'ng-repeat' => 'file in files'}
18
18
  %img{ src: "{{ file.path }}" }
19
+ %a{ 'ng-click' => 'remove($index)'}= t 'instant_upload.remove'
19
20
 
20
21
 
@@ -0,0 +1,4 @@
1
+ pl:
2
+ instant_upload:
3
+ drag_and_drop: Upuść pliki tutaj lub
4
+ select_files: wybierz je z dysku.
@@ -5,7 +5,7 @@ module InstantUpload
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
- helper_method :handle_upload, :load_uploaded_files, :clear_uploaded_files
8
+ helper_method :handle_upload, :load_uploaded_files, :clear_uploaded_files, :remove_uploaded_file
9
9
  end
10
10
 
11
11
  def handle_upload(record, field, options ={})
@@ -23,7 +23,7 @@ module InstantUpload
23
23
  end
24
24
 
25
25
  session[sesssion_key] = [] if session[sesssion_key].blank?
26
- session[sesssion_key] << files.map { |f| f.id }
26
+ session[sesssion_key] = files.map { |f| f.id }
27
27
 
28
28
  render json: record.send(field)
29
29
  else
@@ -38,6 +38,10 @@ module InstantUpload
38
38
 
39
39
  return true
40
40
  else
41
+ if remove_uploaded_file(record, field)
42
+ render json: true
43
+ return true
44
+ end
41
45
  load_uploaded_files(record, field, options)
42
46
  end
43
47
 
@@ -66,6 +70,19 @@ module InstantUpload
66
70
  session.delete("#{record.class.name.downcase}_#{field}")
67
71
  end
68
72
 
73
+ def remove_uploaded_file(record, field)
74
+ sesssion_key = "#{record.class.name.downcase}_#{field}"
75
+
76
+ if params[:iu_remove].present?
77
+ logger.info 'remove media'
78
+ logger.info session[sesssion_key].inspect
79
+ session[sesssion_key].delete_at params[:index].to_i
80
+ return true
81
+ end
82
+
83
+ false
84
+ end
85
+
69
86
  end
70
87
 
71
88
  end
@@ -1,3 +1,3 @@
1
1
  module InstantUpload
2
- VERSION = '1.0.6'
2
+ VERSION = '1.0.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instant-upload
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mariusz Ołownia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-24 00:00:00.000000000 Z
11
+ date: 2013-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -283,6 +283,7 @@ files:
283
283
  - app/views/instant_upload/_multi.html.haml
284
284
  - app/views/instant_upload/_single.html.haml
285
285
  - app/views/layouts/instant_upload/application.html.erb
286
+ - config/locales/instant_upload.pl.yml
286
287
  - config/routes.rb
287
288
  - db/migrate/20130509140233_create_instant_upload_uploads.rb
288
289
  - lib/generators/instant_upload/install_generator.rb