Skip to content

Commit

Permalink
Setting a different previewsContainer is possible now.
Browse files Browse the repository at this point in the history
Closes #16
  • Loading branch information
enyo committed Feb 26, 2013
1 parent de3f266 commit 97c21b2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions downloads/css/stylus/basic.styl
Expand Up @@ -2,6 +2,8 @@

.dropzone
.dropzone *
.dropzone-previews
.dropzone-previews *
box-sizing border-box


Expand Down Expand Up @@ -29,6 +31,8 @@
.message
display none

.dropzone
.dropzone-previews
.preview
background rgba(255, 255, 255, 0.8)
position relative
Expand Down
3 changes: 3 additions & 0 deletions downloads/css/stylus/dropzone.styl
Expand Up @@ -50,6 +50,9 @@
opacity 0 // Rather fade out nicely


.dropzone
.dropzone-previews

.preview
box-shadow 1px 1px 4px rgba(0, 0, 0, 0.16)
font-size 14px
Expand Down
13 changes: 6 additions & 7 deletions src/dropzone.coffee
Expand Up @@ -108,10 +108,7 @@ class Dropzone extends Em

# Can be a jQuery or HTML element that will hold the file previews
# If null, the dropzone element will be used
#
# Not implemented yet.
#
# previewsContainer: null
previewsContainer: null

# If `done()` is called without argument the file is accepted
# If you call it with an error message, the file is rejected
Expand Down Expand Up @@ -150,7 +147,7 @@ class Dropzone extends Em

# Called whenever files are dropped or selected
selectedfiles: (files) ->
@element.addClass "started"
@element.addClass "started" if @element.is @previewsContainer

# Called whenever there are no files left in the dropzone anymore, and the
# dropzone should be displayed as if in the initial state.
Expand All @@ -161,7 +158,7 @@ class Dropzone extends Em
# Receives `file`
addedfile: (file) ->
file.previewTemplate = o @options.previewTemplate
@element.append file.previewTemplate
@previewsContainer.append file.previewTemplate
file.previewTemplate.find(".filename span").text file.name
file.previewTemplate.find(".details").append o """<div class="size">#{@filesize file.size}</div>"""

Expand Down Expand Up @@ -255,6 +252,8 @@ class Dropzone extends Em

throw new Error "No URL provided." unless @options.url

@previewsContainer = if @options.previewsContainer then o @options.previewsContainer else @element

@init()


Expand All @@ -265,7 +264,7 @@ class Dropzone extends Em
if @elementTagName == "form" and @element.attr("enctype") != "multipart/form-data"
@element.attr "enctype", "multipart/form-data"

if @element.find(".message").length == 0
if @element.hasClass("dropzone") and @element.find(".message").length == 0
@element.append o """<div class="default message"><span>Drop files here to upload</span></div>"""

capableBrowser = yes
Expand Down

0 comments on commit 97c21b2

Please sign in to comment.