rails-uploader 0.5.4 → 0.5.5

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
  SHA256:
3
- metadata.gz: 566c841fcb9d098a1b256c3aff94e01950cdbb0ace03d1c657e8d9fa3c114314
4
- data.tar.gz: 4ac9416e87c31176a81392e1a958fc90e65f3cc5c70d7faf72e37fdadcb21053
3
+ metadata.gz: 288f1b049430d69fe720b17b8db0888f196987f632c366150cb25b9ebada7081
4
+ data.tar.gz: 9dba7c65c0dab4ccebde808be6e867470c8c879133cf65461373c8f235311521
5
5
  SHA512:
6
- metadata.gz: d535a4a9a2c9e40d24826c586f6ebf006934f3194f4600390e783659eadbe37955474b8430a1843ed8db6841afc13998cbaf46e2b935a88bc651fccf8806f33c
7
- data.tar.gz: 1ddd6948b2fd9c202b1a1bfeb9ce491964823bd7a3b861a33f2ad34b7c7e09fd6b452c1b5da312344ccdc9f9de1c6b8f8e42c45a2bcd40489f872f4fedf2e322
6
+ metadata.gz: 25ae58b3c31a0c2d9144b0c201bc5357ed42abef4e5cf3dad8323c1a11cbff3ba519f467efc7bf79754a4d978f39264d350e897458956be373e9db454238236b
7
+ data.tar.gz: 67e803051409302b8c64b81ed8a020dbd75373d19ab7432292a9b38d0e808b8f35d1a2e210a1c20225d8f32d206bf7dcdb7a8d5a2b5629d12cf3ac0f3c96af29
@@ -0,0 +1,87 @@
1
+ (function() {
2
+ var $, UploaderWidget;
3
+
4
+ $ = jQuery;
5
+
6
+ $.fn.uploaderWidget = function(options) {
7
+ if (options == null) {
8
+ options = {};
9
+ }
10
+ return this.each(function() {
11
+ var $this, data;
12
+ $this = $(this);
13
+ data = $this.data('uploaderWidget');
14
+ if (!data) {
15
+ $this.data('uploaderWidget', new UploaderWidget(this, options));
16
+ }
17
+ if (typeof options === 'string') {
18
+ return data[options]();
19
+ }
20
+ });
21
+ };
22
+
23
+ UploaderWidget = (function() {
24
+ function UploaderWidget(dom_id, options) {
25
+ var defaults;
26
+ this.dom_id = dom_id;
27
+ if (options == null) {
28
+ options = {};
29
+ }
30
+ defaults = {
31
+ dataType: 'json',
32
+ autoUpload: true,
33
+ paramName: 'asset[data]',
34
+ formData: function(form) {
35
+ return [];
36
+ },
37
+ namespace: 'uploader',
38
+ uploadTemplateId: 'template-upload-',
39
+ downloadTemplateId: 'template-download-'
40
+ };
41
+ this.options = $.extend(defaults, options);
42
+ this._setup();
43
+ }
44
+
45
+ UploaderWidget.prototype._setup = function() {
46
+ this.element = $(this.dom_id);
47
+ this.container = this.element.find('.uploader-files');
48
+ this.template = this.element.data('tpml');
49
+ this.input = this.element.find('input[type="file"]:eq(0)');
50
+ this.options['dropZone'] = this.element;
51
+ this.options['filesContainer'] = this.container;
52
+ this.options['uploadTemplateId'] += this.template;
53
+ this.options['downloadTemplateId'] += this.template;
54
+ this.options.singular = !this.input.prop('multiple');
55
+ return this._initFileupload();
56
+ };
57
+
58
+ UploaderWidget.prototype._initFileupload = function() {
59
+ this.input.fileupload(this.options);
60
+ this.uploader = this.input.data('blueimp-fileupload') || this.input.data('fileupload');
61
+ if (this.element.data('exists')) {
62
+ return this._load();
63
+ }
64
+ };
65
+
66
+ UploaderWidget.prototype._load = function() {
67
+ return $.ajax({
68
+ url: this.input.data('url'),
69
+ dataType: 'json',
70
+ method: 'GET',
71
+ success: (function(_this) {
72
+ return function(data) {
73
+ if (data['files'] != null) {
74
+ return _this.render(data['files']);
75
+ }
76
+ };
77
+ })(this)
78
+ });
79
+ };
80
+
81
+ UploaderWidget.prototype.render = function(files) {
82
+ return this.uploader._renderDownload(files).appendTo(this.container);
83
+ };
84
+
85
+ return UploaderWidget;
86
+ })();
87
+ }).call(this);
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uploader
4
- VERSION = '0.5.4'
4
+ VERSION = '0.5.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-uploader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Galeta
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-01-19 00:00:00.000000000 Z
12
+ date: 2022-01-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: carrierwave
@@ -64,7 +64,7 @@ files:
64
64
  - README.md
65
65
  - Rakefile
66
66
  - app/assets/javascripts/uploader/application.js
67
- - app/assets/javascripts/uploader/jquery.uploader.js.coffee
67
+ - app/assets/javascripts/uploader/jquery.uploader.js
68
68
  - app/assets/stylesheets/uploader/application.css
69
69
  - app/controllers/uploader/attachments_controller.rb
70
70
  - app/views/uploader/default/_container.html.erb
@@ -1,59 +0,0 @@
1
- $ = jQuery
2
-
3
- $.fn.uploaderWidget = (options = {}) ->
4
- @each ->
5
- $this = $(this)
6
- data = $this.data('uploaderWidget')
7
- if (!data)
8
- $this.data('uploaderWidget', new UploaderWidget(this, options))
9
- if (typeof options is 'string')
10
- data[options]()
11
-
12
- class UploaderWidget
13
- constructor: (@dom_id, options = {}) ->
14
- defaults =
15
- dataType: 'json'
16
- autoUpload: true
17
- paramName: 'asset[data]'
18
- formData: (form) -> return []
19
- namespace: 'uploader'
20
- uploadTemplateId: 'template-upload-'
21
- downloadTemplateId: 'template-download-'
22
-
23
- @options = $.extend defaults, options
24
-
25
- this._setup()
26
-
27
- _setup: ->
28
- @element = $(@dom_id)
29
- @container = @element.find('.uploader-files')
30
- @template = @element.data('tpml')
31
- @input = @element.find('input[type="file"]:eq(0)')
32
-
33
- @options['dropZone'] = @element
34
- @options['filesContainer'] = @container
35
- @options['uploadTemplateId'] += @template
36
- @options['downloadTemplateId'] += @template
37
- @options.singular = !@input.prop('multiple')
38
-
39
- this._initFileupload()
40
-
41
- _initFileupload: ->
42
- @input.fileupload(@options)
43
-
44
- @uploader = (@input.data('blueimp-fileupload') || @input.data('fileupload'))
45
-
46
- this._load() if @element.data('exists')
47
-
48
- _load: ->
49
- $.ajax(
50
- url: @input.data('url')
51
- dataType: 'json'
52
- method: 'GET'
53
- success: (data) =>
54
- if data['files']?
55
- this.render(data['files'])
56
- )
57
-
58
- render: (files) ->
59
- @uploader._renderDownload(files).appendTo(@container)