effective_assets 1.4.3 → 1.4.4

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: 44f1e683151eec235827918b34aa5e7838c9f34c
4
- data.tar.gz: 6c56629f8ffd2f21fd0ea90ab3700c442e064ec7
3
+ metadata.gz: 13e90b35a299db09418e02d1c372631beb2b4360
4
+ data.tar.gz: 024fda44ceeca5d6b56c0d18974a3dbffeda030f
5
5
  SHA512:
6
- metadata.gz: 2aa8570ae9ea214a33570d69df27c4e57eb2be191a21913c5e90007b6a3cd24b7cfdf5695336898afd9520d874115f6ea17960b057f3a443bafa07d940a4addb
7
- data.tar.gz: 437d63f81b740e9aec43256bc547db4c41bc4cee56ea808e4659e2d0699113c006cd4667430af4f7981bbcf7c1730b459fa51cf70d732eeb5106d5b603f4f0e5
6
+ metadata.gz: e4c98bfc63977679f27e210f05d3d18b092de03bc240f0caadc363409ad7959856cebaab34e1ef2fc83096181b482260ccf02adbc08b847867e4435a85b9842a
7
+ data.tar.gz: 89218d7e52c5ab43cadeb1f90a7aaee039a046974f5672edd9ddd577e40e8cd4298e5dd695159ad9475d362432535fc97db715a832ca82dc88fa00f85c6faf6a
@@ -30,6 +30,23 @@ $.fn.S3Uploader = (options) ->
30
30
  url: settings.url
31
31
 
32
32
  add: (e, data) ->
33
+ # Ensure correct $uploadForm is being used
34
+ $uploadForms = $('.asset-box-uploader')
35
+ return false if $uploadForms.index($uploadForm) == -1
36
+
37
+ # Make sure the user isn't over the upload limit
38
+ $asset_box = $uploadForm.closest('.asset-box-input')
39
+ limit = $asset_box.data('limit')
40
+ if typeof limit == 'number'
41
+ count = parseInt($asset_box.attr('data-attachment-count'), 10)
42
+ if count >= limit
43
+ alert("Unable to add file(s). You have exceeded the limit of #{limit} uploads.") unless $asset_box.data('over-limit-alerted')
44
+ $asset_box.data('over-limit-alerted', true)
45
+ return false
46
+ else
47
+ $asset_box.attr('data-attachment-count', count + 1)
48
+
49
+ # Add the file to the upload
33
50
  file = data.files[0]
34
51
 
35
52
  # Check File Type
@@ -263,10 +280,16 @@ $.fn.S3Uploader = (options) ->
263
280
  else
264
281
  bits.toFixed(2) + ' bit/s'
265
282
 
283
+ resetOverLimitAlert = (event) ->
284
+ $assetBox = $(event.target).closest('.asset-box-input')
285
+ $assetBox.data('over-limit-alerted', false)
286
+
266
287
  #public methods
267
288
  @initialize = ->
268
289
  # Save key for IE9 Fix
269
290
  $uploadForm.data("key", $uploadForm.find("input[name='key']").val())
291
+ $uploadForm.data("fileCount", 0)
292
+ $(document).on 'drop', '.asset-box-uploader', resetOverLimitAlert
270
293
  setUploadForm()
271
294
  this
272
295
 
@@ -42,6 +42,8 @@ module Inputs
42
42
  data-attachment-style='#{@options[:attachment_style]}'
43
43
  data-attachment-add-to='#{@options[:attachment_add_to]}'
44
44
  data-attachment-actions='#{@options[:attachment_actions].to_json()}'
45
+ data-attachment-count='#{attachments.length}'
46
+ data-over-limit-alerted='false'
45
47
  data-aws-acl='#{@options[:aws_acl]}'
46
48
  >".html_safe
47
49
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveAssets
2
- VERSION = '1.4.3'.freeze
2
+ VERSION = '1.4.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-08 00:00:00.000000000 Z
11
+ date: 2015-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails