Skip to content

Commit

Permalink
Initial the Dropzone project
Browse files Browse the repository at this point in the history
  • Loading branch information
spatil committed Jul 30, 2013
1 parent 3874bba commit 4e302a7
Show file tree
Hide file tree
Showing 24 changed files with 759 additions and 244 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
/public
1 change: 1 addition & 0 deletions .rvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rvm --create use "ruby-2.0.0@dropzone"
7 changes: 5 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ group :assets do
gem 'coffee-rails', '~> 3.2.1'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'therubyracer', :platforms => :ruby

gem 'uglifier', '>= 1.0.3'
end
Expand All @@ -41,4 +41,7 @@ gem "haml-rails"
gem "jquery-rails"
gem "bson_ext"
gem "mongoid", ">= 2.0.0.beta.19"
gem "rspec-rails", ">= 2.0.1", :group => [:development, :test]
gem "rspec-rails", ">= 2.0.1", :group => [:development, :test]
gem "cloudinary"
gem 'carrierwave-mongoid'
gem 'bootstrap-sass'
28 changes: 28 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,24 @@ GEM
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
aws_cf_signer (0.1.1)
bootstrap-sass (2.3.2.1)
sass (~> 3.2)
bson (1.9.1)
bson_ext (1.9.1)
bson (~> 1.9.1)
builder (3.0.4)
carrierwave (0.9.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
json (>= 1.7)
carrierwave-mongoid (0.6.1)
carrierwave (>= 0.8.0, < 0.10.0)
mongoid (>= 3.0, < 5.0)
mongoid-grid_fs (~> 1.3)
cloudinary (1.0.62)
aws_cf_signer
rest-client
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
Expand All @@ -58,6 +72,7 @@ GEM
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.0)
libv8 (3.11.8.17)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
Expand All @@ -68,6 +83,9 @@ GEM
moped (~> 1.4)
origin (~> 1.0)
tzinfo (~> 0.3.22)
mongoid-grid_fs (1.8.0)
mime-types (~> 1.19)
mongoid (~> 3.0)
moped (1.5.0)
multi_json (1.7.7)
origin (1.1.0)
Expand Down Expand Up @@ -97,6 +115,9 @@ GEM
rake (10.1.0)
rdoc (3.12.2)
json (~> 1.4)
ref (1.0.5)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec-core (2.14.4)
rspec-expectations (2.14.0)
diff-lcs (>= 1.1.3, < 2.0)
Expand All @@ -118,6 +139,9 @@ GEM
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
therubyracer (0.11.4)
libv8 (~> 3.11.8.12)
ref
thor (0.18.1)
tilt (1.4.1)
treetop (1.4.14)
Expand All @@ -132,7 +156,10 @@ PLATFORMS
ruby

DEPENDENCIES
bootstrap-sass
bson_ext
carrierwave-mongoid
cloudinary
coffee-rails (~> 3.2.1)
haml (>= 3.0.0)
haml-rails
Expand All @@ -141,4 +168,5 @@ DEPENDENCIES
rails (= 3.2.11)
rspec-rails (>= 2.0.1)
sass-rails (~> 3.2.3)
therubyracer
uglifier (>= 1.0.3)
Binary file added app/assets/images/spritemap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery.min
//= require jquery_ujs
//= require_tree .
26 changes: 26 additions & 0 deletions app/assets/javascripts/dropzone.min.js

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions app/assets/javascripts/home.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

$(document).ready ->

org_success = Dropzone.prototype.defaultOptions.success
org_removed = Dropzone.prototype.defaultOptions.removedfile

Dropzone.options.assetsDropzone = {
addRemoveLinks: true,
paramName: 'image',
previewTemplate: '<div class="dz-preview dz-file-preview"> <div class="dz-details"> <div class="dz-filename"><span data-dz-name></span></div> <div class="dz-size" data-dz-size></div> <img data-dz-thumbnail /> </div> <div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div> <div class="dz-success-mark"><span>✔</span></div> <div class="dz-error-mark"><span>✘</span></div> <div class="dz-error-message"><span data-dz-errormessage></span></div><div class="dz-primary-mark"></div><a class="dz-set-primary">Set Primary</a></div>',
removedfile: (file) ->
$.ajax({
url: "/#{file._id}/remove_image",
method: 'post'
})
org_removed(file)
,
success: (file, data) ->
index = $('#assets-dropzone').get(0).dropzone.files.indexOf(file)
$('#assets-dropzone').get(0).dropzone.files[index]["_id"] = data["asset_id"]
$('#assets-dropzone').get(0).dropzone.files[index].previewElement.id = data["asset_id"]
org_success(file)
}
Dropzone.autoDiscover = false

$('#assets-dropzone').on 'click', '.dz-set-primary', ->
$.ajax({
url: "/#{$(this).parent().attr('id')}/set_primary",
method: 'post'
})

if images?
$('#assets-dropzone').dropzone()

$.each images, (i, image) ->
$('#assets-dropzone').get(0).dropzone.addExistingFile(image)

primary_asset = images.filter((x) ->
x if x.is_primary is true
)[0]

$('#'+primary_asset._id).addClass('dz-primary') if primary_asset?
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@
*= require_self
*= require_tree .
*/

@import "bootstrap";

#assets-dropzone {
border-radius: 3px 3px 3px 3px;
box-shadow: 0 0 50px rgba(0, 0, 0, 0.13);
margin: 30px 0;
padding: 4px;
}
Loading

0 comments on commit 4e302a7

Please sign in to comment.