ezdz-rails 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Dockerfile +37 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +62 -0
- data/Rakefile +23 -0
- data/ezdz-rails.gemspec +25 -0
- data/lib/ezdz-rails.rb +9 -0
- data/lib/ezdz-rails/version.rb +5 -0
- data/make_new_release.sh +38 -0
- data/vendor/assets/javascripts/jquery.ezdz.js +339 -0
- data/vendor/assets/stylesheets/jquery.ezdz.css +85 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 013b8a965d58d22120e8af0a4d77b99a0c0429da
|
4
|
+
data.tar.gz: d0e8efc95f7a7a01e81ca84cc4a9ca79e4e6b442
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a0306fd923cd419837fe46936c02e65ce678c9bc1370ebc6c92f4006bb08e6047d68ebf90f19a0ebe6caa26137219ffe1c077fbee072ff8224e0d0b5a0b62f94
|
7
|
+
data.tar.gz: c8fac63273c88fb5c4a36c957573672f848c411c32a2f24341b28ada0d1c39529a497ae537e13ad4c098ff157398cc38bf8b7f2653406e90603ccbb0cc99de83
|
data/.gitignore
ADDED
data/Dockerfile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# How to use it
|
2
|
+
# =============
|
3
|
+
#
|
4
|
+
# Visit http://blog.zedroot.org/using-docker-to-maintain-a-ruby-gem/
|
5
|
+
|
6
|
+
# ~~~~ Image base ~~~~
|
7
|
+
# Base image with the latest Ruby only
|
8
|
+
FROM ruby:2.3.0-slim
|
9
|
+
MAINTAINER Guillaume Hain zedtux@zedroot.org
|
10
|
+
|
11
|
+
|
12
|
+
# ~~~~ Set up the environment ~~~~
|
13
|
+
ENV DEBIAN_FRONTEND noninteractive
|
14
|
+
|
15
|
+
RUN mkdir -p /gem/
|
16
|
+
WORKDIR /gem/
|
17
|
+
ADD . /gem/
|
18
|
+
|
19
|
+
# ~~~~ OS Maintenance & Rails Preparation ~~~~
|
20
|
+
# Rubygems and Bundler
|
21
|
+
RUN apt-get update && \
|
22
|
+
apt-get install -y git build-essential && \
|
23
|
+
touch ~/.gemrc && \
|
24
|
+
echo "gem: --no-ri --no-rdoc" >> ~/.gemrc && \
|
25
|
+
gem install rubygems-update && \
|
26
|
+
update_rubygems && \
|
27
|
+
gem install bundler && \
|
28
|
+
bundle install && \
|
29
|
+
apt-get remove --purge -y build-essential && \
|
30
|
+
apt-get autoclean -y && \
|
31
|
+
apt-get clean
|
32
|
+
|
33
|
+
# Import the gem source code
|
34
|
+
VOLUME .:/gem/
|
35
|
+
|
36
|
+
ENTRYPOINT ["bundle", "exec"]
|
37
|
+
CMD ["rake", "-T"]
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Guillaume Hain
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Ezdz-Rails
|
2
|
+
|
3
|
+
This Gem integrates [Jay Salvat's Ezdz](https://github.com/seiyria/bootstrap-slider)
|
4
|
+
to the Rails assets pipeline.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'ezdz-rails'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install ezdz-rails
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
This gem uses a Rails Engine to make Ezdz's assets available to you.
|
23
|
+
|
24
|
+
Require the JavaScript files from your `application.js` or wherever needed using:
|
25
|
+
|
26
|
+
```
|
27
|
+
//= require jquery.ezdz
|
28
|
+
```
|
29
|
+
|
30
|
+
Require the CSS files from your `application.scss` or wherever needed using:
|
31
|
+
|
32
|
+
```
|
33
|
+
*= require jquery.ezdz
|
34
|
+
```
|
35
|
+
|
36
|
+
## Gem release
|
37
|
+
|
38
|
+
In the case you'd like to create a new release when [Jay Salvat](https://github.com/jaysalvat) release a new version of his ezdz library, you just need to run the following:
|
39
|
+
|
40
|
+
```
|
41
|
+
$ ./make_new_release.sh
|
42
|
+
Ensuring Docker image zedtux/bootstrap-slider-rails exists ...
|
43
|
+
Updating library code to version 5.3.3 ...
|
44
|
+
Downlading Bootstrap-slider 5.3.3 ...
|
45
|
+
% Total % Received % Xferd Average Speed Time Time Time Current
|
46
|
+
Dload Upload Total Spent Left Speed
|
47
|
+
100 51140 100 51140 0 0 124k 0 --:--:-- --:--:-- --:--:-- 124k
|
48
|
+
% Total % Received % Xferd Average Speed Time Time Time Current
|
49
|
+
Dload Upload Total Spent Left Speed
|
50
|
+
100 8238 100 8238 0 0 28698 0 --:--:-- --:--:-- --:--:-- 28703
|
51
|
+
Done!
|
52
|
+
Committing new version ...
|
53
|
+
Releasing gem ...
|
54
|
+
```
|
55
|
+
|
56
|
+
## Contributing
|
57
|
+
|
58
|
+
1. Fork it
|
59
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
60
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
61
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
62
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
desc 'Update the Ezdz Javascript and CSS files'
|
5
|
+
task :update do
|
6
|
+
def download(version)
|
7
|
+
base_url = 'https://raw.githubusercontent.com/jaysalvat/ezdz'
|
8
|
+
puts "Downlading ezdz-slider #{version} ..."
|
9
|
+
js = system("curl -fo vendor/assets/javascripts/jquery.ezdz.js " \
|
10
|
+
"#{base_url}/v#{version}/dist/jquery.ezdz.js")
|
11
|
+
css = system("curl -fo vendor/assets/stylesheets/jquery.ezdz.css " \
|
12
|
+
"#{base_url}/v#{version}/dist/jquery.ezdz.css")
|
13
|
+
|
14
|
+
puts 'ERROR: Unable to fetch the Javascript file !' unless js
|
15
|
+
puts 'ERROR: Unable to fetch the CSS file !' unless css
|
16
|
+
exit 1 unless js || css
|
17
|
+
end
|
18
|
+
|
19
|
+
FileUtils.mkdir_p('vendor/assets/javascripts')
|
20
|
+
FileUtils.mkdir_p('vendor/assets/stylesheets')
|
21
|
+
download(Ezdz::Rails::VERSION)
|
22
|
+
puts "\e[32mDone!\e[0m"
|
23
|
+
end
|
data/ezdz-rails.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ezdz-rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'ezdz-rails'
|
8
|
+
spec.version = Ezdz::Rails::VERSION
|
9
|
+
spec.authors = ['Pedr Browne']
|
10
|
+
spec.email = ['pedr.browne@gmail.com']
|
11
|
+
spec.description = "Make Jay Salvat's Ezdz [izy-dizy] available to Rails"
|
12
|
+
spec.summary = "This Gem integrates Jay Salvat's Ezdz [izy-dizy] " \
|
13
|
+
'with Rails, exposing its JavaScript and CSS ' \
|
14
|
+
'assets via a Rails Engine.'
|
15
|
+
spec.homepage = 'https://github.com/YourCursus/ezdz-rails'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split($RS)
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_dependency 'railties', '>= 3.2', '< 5.0'
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
end
|
data/lib/ezdz-rails.rb
ADDED
data/make_new_release.sh
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
DOCKER_IMAGE_NAME="$USER/ezdz-rails"
|
4
|
+
LIBRARY_NEW_VERSION=`cat lib/**/*.rb | grep VERSION | awk '{ print $3 }' | tr -d "'"`
|
5
|
+
|
6
|
+
LIBRARY_UPDATED=`git status --porcelain | grep -v "lib/ezdz-rails/version.rb"`
|
7
|
+
if [[ -n "$LIBRARY_UPDATED" ]]; then
|
8
|
+
echo "Your repository is not clean !"
|
9
|
+
exit 1
|
10
|
+
fi
|
11
|
+
|
12
|
+
echo "Ensuring Docker image $DOCKER_IMAGE_NAME exists ..."
|
13
|
+
EXISTING_DOCKER_IMAGE=`docker images | grep "$DOCKER_IMAGE_NAME"`
|
14
|
+
if [[ -z "$EXISTING_DOCKER_IMAGE" ]]; then
|
15
|
+
echo "Building the Docker image ..."
|
16
|
+
docker build -t "$DOCKER_IMAGE_NAME" .
|
17
|
+
fi
|
18
|
+
|
19
|
+
echo "Updating library code to version $LIBRARY_NEW_VERSION ..."
|
20
|
+
docker run --rm -v `pwd`:/gem/ "$DOCKER_IMAGE_NAME" rake update
|
21
|
+
|
22
|
+
LIBRARY_UPDATED=`git status --porcelain | grep -v make_new_release.sh`
|
23
|
+
if [[ -z "$LIBRARY_UPDATED" ]]; then
|
24
|
+
echo "No update found, stopping release creation."
|
25
|
+
exit 1
|
26
|
+
elif [[ "$LIBRARY_UPDATED" == " M lib/ezdz-rails/version.rb" ]]; then
|
27
|
+
echo "None of the JS or CSS files have been updated."
|
28
|
+
exit 1
|
29
|
+
fi
|
30
|
+
|
31
|
+
echo "Committing new version ..."
|
32
|
+
git commit -am "Import version $LIBRARY_NEW_VERSION"
|
33
|
+
|
34
|
+
echo "Releasing gem ..."
|
35
|
+
docker run --rm -v ~/.gitconfig:/root/.gitconfig \
|
36
|
+
-v ~/.ssh/:/root/.ssh/ \
|
37
|
+
-v ~/.gem/:/root/.gem/ \
|
38
|
+
-v `pwd`:/gem/ "$DOCKER_IMAGE_NAME" rake release
|
@@ -0,0 +1,339 @@
|
|
1
|
+
/* ----------------------------------------------------------------------------
|
2
|
+
// Ezdz [izy-dizy] jQuery plugin
|
3
|
+
// v0.2.0 - released 2013-10-16 00:14
|
4
|
+
// Licensed under the MIT license.
|
5
|
+
// https://github.com/jaysalvat/ezdz
|
6
|
+
// ----------------------------------------------------------------------------
|
7
|
+
// Copyright (C) 2013 Jay Salvat
|
8
|
+
// http://jaysalvat.com/
|
9
|
+
// ---------------------------------------------------------------------------*/
|
10
|
+
|
11
|
+
(function($) {
|
12
|
+
// Default settings
|
13
|
+
var defaults = {
|
14
|
+
className: '',
|
15
|
+
text: 'Drop a file',
|
16
|
+
previewImage: true,
|
17
|
+
value: null,
|
18
|
+
classes: {
|
19
|
+
main: 'ezdz-dropzone',
|
20
|
+
enter: 'ezdz-enter',
|
21
|
+
reject: 'ezdz-reject',
|
22
|
+
accept: 'ezdz-accept',
|
23
|
+
focus: 'ezdz-focus'
|
24
|
+
},
|
25
|
+
validators: {
|
26
|
+
maxSize: null,
|
27
|
+
width: null,
|
28
|
+
maxWidth: null,
|
29
|
+
minWidth: null,
|
30
|
+
height: null,
|
31
|
+
maxHeight: null,
|
32
|
+
minHeight: null
|
33
|
+
},
|
34
|
+
init: function() {},
|
35
|
+
enter: function() {},
|
36
|
+
leave: function() {},
|
37
|
+
reject: function() {},
|
38
|
+
accept: function() {},
|
39
|
+
format: function(filename) {
|
40
|
+
return filename;
|
41
|
+
}
|
42
|
+
};
|
43
|
+
|
44
|
+
// Main plugin
|
45
|
+
$.ezdz = function(element, options) {
|
46
|
+
var self = this,
|
47
|
+
settings = $.extend(true, {}, defaults, $.ezdz.defaults, options),
|
48
|
+
$input = $(element);
|
49
|
+
|
50
|
+
if (!$input.is('input[type="file"]')) {
|
51
|
+
$.error('Ezdz error - Must be apply to inputs type file.');
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
|
55
|
+
// Stop if not compatible with HTML5 file API
|
56
|
+
if (!(window.File && window.FileList && window.FileReader)) {
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
|
60
|
+
// Public: Inject a file or image in the preview
|
61
|
+
self.preview = function(path, callback) {
|
62
|
+
var basename = path.replace(/\\/g,'/').replace( /.*\//, ''),
|
63
|
+
formatted = settings.format(basename),
|
64
|
+
$ezdz = $input.parent('.' + settings.classes.main);
|
65
|
+
|
66
|
+
var img = new Image();
|
67
|
+
img.src = path;
|
68
|
+
|
69
|
+
// Is an image
|
70
|
+
img.onload = function() {
|
71
|
+
$ezdz.find('div').html($(img).fadeIn());
|
72
|
+
|
73
|
+
if ($.isFunction(callback)) {
|
74
|
+
callback.apply(this);
|
75
|
+
}
|
76
|
+
};
|
77
|
+
|
78
|
+
// Is not an image
|
79
|
+
img.onerror = function() {
|
80
|
+
$ezdz.find('div').html('<span>' + formatted + '</span>');
|
81
|
+
|
82
|
+
if ($.isFunction(callback)) {
|
83
|
+
callback.apply(this);
|
84
|
+
}
|
85
|
+
};
|
86
|
+
|
87
|
+
$ezdz.addClass(settings.classes.accept);
|
88
|
+
};
|
89
|
+
|
90
|
+
// Public: Destroy ezdz
|
91
|
+
self.destroy = function() {
|
92
|
+
$input.parent('.' + settings.classes.main).replaceWith($input);
|
93
|
+
$input.off('*.ezdz');
|
94
|
+
$input.data('ezdz', '');
|
95
|
+
};
|
96
|
+
|
97
|
+
// Public: Extend settings
|
98
|
+
self.options = function(values) {
|
99
|
+
$.extend(true, settings, values);
|
100
|
+
};
|
101
|
+
|
102
|
+
// private: Init the plugin
|
103
|
+
var init = function() {
|
104
|
+
var $ezdz, $container, value;
|
105
|
+
|
106
|
+
// Build the container
|
107
|
+
$container = $('<div class="' + settings.classes.main + '" />')
|
108
|
+
|
109
|
+
.on('dragover.ezdz', function() {
|
110
|
+
$(this).addClass(settings.classes.enter);
|
111
|
+
|
112
|
+
if ($.isFunction(settings.enter)) {
|
113
|
+
settings.enter.apply(this);
|
114
|
+
}
|
115
|
+
})
|
116
|
+
|
117
|
+
.on('dragleave.ezdz', function() {
|
118
|
+
$(this).removeClass(settings.classes.enter);
|
119
|
+
|
120
|
+
if ($.isFunction(settings.leaved)) {
|
121
|
+
settings.leaved.apply(this);
|
122
|
+
}
|
123
|
+
})
|
124
|
+
|
125
|
+
.addClass(settings.className);
|
126
|
+
|
127
|
+
// Build the whole dropzone
|
128
|
+
$input
|
129
|
+
.wrap($container)
|
130
|
+
.before('<div>' + settings.text + '</div>');
|
131
|
+
|
132
|
+
$ezdz = $input.parent('.' + settings.classes.main);
|
133
|
+
|
134
|
+
// Preview a file at start if it's defined
|
135
|
+
value = settings.value || $input.data('value');
|
136
|
+
|
137
|
+
if (value) {
|
138
|
+
self.preview(value);
|
139
|
+
}
|
140
|
+
|
141
|
+
// Trigger the init callback
|
142
|
+
if ($.isFunction(settings.init)) {
|
143
|
+
settings.init.apply($ezdz, [ value ]);
|
144
|
+
}
|
145
|
+
|
146
|
+
// Events on the input
|
147
|
+
$input
|
148
|
+
|
149
|
+
.on('focus.ezdz', function() {
|
150
|
+
$ezdz.addClass(settings.classes.focus);
|
151
|
+
})
|
152
|
+
|
153
|
+
.on('blur.ezdz', function() {
|
154
|
+
$ezdz.removeClass(settings.classes.focus);
|
155
|
+
})
|
156
|
+
|
157
|
+
.on('change.ezdz', function() {
|
158
|
+
var file = this.files[0];
|
159
|
+
|
160
|
+
// No file, so user has cancelled
|
161
|
+
if (!file) {
|
162
|
+
return;
|
163
|
+
}
|
164
|
+
|
165
|
+
// Info about the dropped or selected file
|
166
|
+
var basename = file.name.replace(/\\/g,'/').replace( /.*\//, ''),
|
167
|
+
extension = file.name.split('.').pop(),
|
168
|
+
formatted = settings.format(basename);
|
169
|
+
|
170
|
+
file.extension = extension;
|
171
|
+
|
172
|
+
// Mime-Types
|
173
|
+
var allowed = $input.attr('accept'),
|
174
|
+
accepted = false;
|
175
|
+
valid = true;
|
176
|
+
errors = {
|
177
|
+
'mimeType': false,
|
178
|
+
'maxSize': false,
|
179
|
+
'width': false,
|
180
|
+
'minWidth': false,
|
181
|
+
'maxWidth': false,
|
182
|
+
'height': false,
|
183
|
+
'minHeight': false,
|
184
|
+
'maxHeight': false
|
185
|
+
};
|
186
|
+
|
187
|
+
// Check the accepted Mime-Types from the input file
|
188
|
+
if (allowed) {
|
189
|
+
var types = allowed.split(/[,|]/);
|
190
|
+
|
191
|
+
$.each(types, function(i, type) {
|
192
|
+
type = $.trim(type);
|
193
|
+
|
194
|
+
if (file.type == type) {
|
195
|
+
accepted = true;
|
196
|
+
return false;
|
197
|
+
}
|
198
|
+
|
199
|
+
// Mime-Type with wildcards ex. image/*
|
200
|
+
if (type.indexOf('/*') !== false) {
|
201
|
+
var a = type.replace('/*', ''),
|
202
|
+
b = file.type.replace(/(\/.*)$/g, '');
|
203
|
+
|
204
|
+
if (a === b) {
|
205
|
+
accepted = true;
|
206
|
+
return false;
|
207
|
+
}
|
208
|
+
}
|
209
|
+
});
|
210
|
+
|
211
|
+
if (accepted === false) {
|
212
|
+
errors.mimeType = true;
|
213
|
+
}
|
214
|
+
} else {
|
215
|
+
accepted = true;
|
216
|
+
}
|
217
|
+
|
218
|
+
// Reset the accepted / rejected classes
|
219
|
+
$ezdz.removeClass(settings.classes.reject + ' ' + settings.classes.accept);
|
220
|
+
|
221
|
+
// If the Mime-Type is not accepted
|
222
|
+
if (accepted !== true) {
|
223
|
+
$input.val('');
|
224
|
+
|
225
|
+
$ezdz.addClass(settings.classes.reject);
|
226
|
+
|
227
|
+
// Trigger the reject callback
|
228
|
+
if ($.isFunction(settings.reject)) {
|
229
|
+
settings.reject.apply($ezdz, [ file, errors ]);
|
230
|
+
}
|
231
|
+
return false;
|
232
|
+
}
|
233
|
+
|
234
|
+
// Read the added file
|
235
|
+
var reader = new FileReader(file),
|
236
|
+
img = new Image();
|
237
|
+
|
238
|
+
reader.readAsDataURL(file);
|
239
|
+
|
240
|
+
reader.onload = function(e) {
|
241
|
+
file.data = e.target.result;
|
242
|
+
img.src = file.data;
|
243
|
+
|
244
|
+
var isImage = (img.width && img.height);
|
245
|
+
|
246
|
+
// Validator
|
247
|
+
if (settings.validators.maxSize && file.size > settings.validators.maxSize) {
|
248
|
+
valid = false;
|
249
|
+
errors.maxSize = true;
|
250
|
+
}
|
251
|
+
|
252
|
+
if (isImage) {
|
253
|
+
file.width = img.width;
|
254
|
+
file.height = img.height;
|
255
|
+
|
256
|
+
if (settings.validators.width && img.width != settings.validators.width) {
|
257
|
+
valid = false;
|
258
|
+
errors.width = true;
|
259
|
+
}
|
260
|
+
|
261
|
+
if (settings.validators.maxWidth && img.width > settings.validators.maxWidth) {
|
262
|
+
valid = false;
|
263
|
+
errors.maxWidth = true;
|
264
|
+
}
|
265
|
+
|
266
|
+
if (settings.validators.minWidth && img.width < settings.validators.minWidth) {
|
267
|
+
valid = false;
|
268
|
+
errors.minWidth = true;
|
269
|
+
}
|
270
|
+
|
271
|
+
if (settings.validators.height && img.height != settings.validators.height) {
|
272
|
+
valid = false;
|
273
|
+
errors.height = true;
|
274
|
+
}
|
275
|
+
|
276
|
+
if (settings.validators.maxHeight && img.height > settings.validators.maxHeight) {
|
277
|
+
valid = false;
|
278
|
+
errors.maxHeight = true;
|
279
|
+
}
|
280
|
+
|
281
|
+
if (settings.validators.minHeight && img.height < settings.validators.minHeight) {
|
282
|
+
valid = false;
|
283
|
+
errors.minHeight = true;
|
284
|
+
}
|
285
|
+
}
|
286
|
+
|
287
|
+
// The file is validated, so added to input
|
288
|
+
if (valid === true) {
|
289
|
+
$ezdz.find('img').remove();
|
290
|
+
|
291
|
+
if (isImage && settings.previewImage === true) {
|
292
|
+
$ezdz.find('div').html($(img).fadeIn());
|
293
|
+
} else {
|
294
|
+
$ezdz.find('div').html('<span>' + formatted + '</span>');
|
295
|
+
}
|
296
|
+
|
297
|
+
$ezdz.addClass(settings.classes.accept);
|
298
|
+
|
299
|
+
// Trigger the accept callback
|
300
|
+
if ($.isFunction(settings.accept)) {
|
301
|
+
settings.accept.apply($ezdz, [ file ]);
|
302
|
+
}
|
303
|
+
// The file is invalidated, so rejected
|
304
|
+
} else {
|
305
|
+
$input.val('');
|
306
|
+
|
307
|
+
$ezdz.addClass(settings.classes.reject);
|
308
|
+
|
309
|
+
// Trigger the reject callback
|
310
|
+
if ($.isFunction(settings.reject)) {
|
311
|
+
settings.reject.apply($ezdz, [ file, errors ]);
|
312
|
+
}
|
313
|
+
}
|
314
|
+
};
|
315
|
+
});
|
316
|
+
};
|
317
|
+
|
318
|
+
init();
|
319
|
+
};
|
320
|
+
|
321
|
+
$.fn.ezdz = function(options) {
|
322
|
+
var args = arguments;
|
323
|
+
|
324
|
+
return this.each(function() {
|
325
|
+
var plugin = $(this).data('ezdz');
|
326
|
+
|
327
|
+
if (!plugin) {
|
328
|
+
return $(this).data('ezdz', new $.ezdz(this, options));
|
329
|
+
} if (plugin[options]) {
|
330
|
+
return plugin[options].apply(this, Array.prototype.slice.call(args, 1));
|
331
|
+
} else {
|
332
|
+
$.error('Ezdz error - Method ' + options + ' does not exist.');
|
333
|
+
}
|
334
|
+
});
|
335
|
+
};
|
336
|
+
|
337
|
+
$.ezdz.defaults = defaults;
|
338
|
+
|
339
|
+
})(jQuery);
|
@@ -0,0 +1,85 @@
|
|
1
|
+
/* ----------------------------------------------------------------------------
|
2
|
+
// Ezdz [izy-dizy] jQuery plugin
|
3
|
+
// v0.2.0 - released 2013-10-16 00:14
|
4
|
+
// Licensed under the MIT license.
|
5
|
+
// https://github.com/jaysalvat/ezdz
|
6
|
+
// ----------------------------------------------------------------------------
|
7
|
+
// Copyright (C) 2013 Jay Salvat
|
8
|
+
// http://jaysalvat.com/
|
9
|
+
// ---------------------------------------------------------------------------*/
|
10
|
+
|
11
|
+
.ezdz-dropzone {
|
12
|
+
position: relative;
|
13
|
+
border-radius: 20px;
|
14
|
+
font: bold 24px arial;
|
15
|
+
text-align: center;
|
16
|
+
width: 250px;
|
17
|
+
height: 200px;
|
18
|
+
line-height: 200px;
|
19
|
+
border: 10px dotted lightgray;
|
20
|
+
color: lightgray;
|
21
|
+
overflow: hidden;
|
22
|
+
}
|
23
|
+
|
24
|
+
.ezdz-dropzone div {
|
25
|
+
/* */
|
26
|
+
}
|
27
|
+
|
28
|
+
.ezdz-dropzone span {
|
29
|
+
border-radius: 20px;
|
30
|
+
background: black;
|
31
|
+
background: rgba(0,0,0,0.7);
|
32
|
+
color: white;
|
33
|
+
font-size: 13px;
|
34
|
+
font-weight: normal;
|
35
|
+
max-width: 90%;
|
36
|
+
vertical-align: middle;
|
37
|
+
padding: 4%;
|
38
|
+
line-height: 10px;
|
39
|
+
display: inline-block;
|
40
|
+
text-overflow: ellipsis;
|
41
|
+
white-space: nowrap;
|
42
|
+
overflow: hidden;
|
43
|
+
}
|
44
|
+
|
45
|
+
.ezdz-dropzone img {
|
46
|
+
border-radius: 5px;
|
47
|
+
max-width: 95%;
|
48
|
+
max-height: 95%;
|
49
|
+
margin-top: -3px;
|
50
|
+
vertical-align: middle;
|
51
|
+
}
|
52
|
+
|
53
|
+
.ezdz-dropzone [type="file"] {
|
54
|
+
cursor: pointer;
|
55
|
+
position: absolute;
|
56
|
+
width: 100%;
|
57
|
+
height: 100%;
|
58
|
+
opacity: 0;
|
59
|
+
margin: 0;
|
60
|
+
padding: 0;
|
61
|
+
top: 0;
|
62
|
+
right: 0;
|
63
|
+
bottom: 0;
|
64
|
+
left: 0;
|
65
|
+
}
|
66
|
+
|
67
|
+
.ezdz-focus {
|
68
|
+
border: 10px dotted darkgray;
|
69
|
+
color: darkgray;
|
70
|
+
}
|
71
|
+
|
72
|
+
.ezdz-enter {
|
73
|
+
border: 10px solid black;
|
74
|
+
color: black;
|
75
|
+
}
|
76
|
+
|
77
|
+
.ezdz-accept {
|
78
|
+
border: 10px solid gray;
|
79
|
+
color: gray;
|
80
|
+
}
|
81
|
+
|
82
|
+
.ezdz-reject {
|
83
|
+
border: 10px solid darkred;
|
84
|
+
color: darkred;
|
85
|
+
}
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ezdz-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pedr Browne
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bundler
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.3'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.3'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
description: Make Jay Salvat's Ezdz [izy-dizy] available to Rails
|
62
|
+
email:
|
63
|
+
- pedr.browne@gmail.com
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- ".gitignore"
|
69
|
+
- Dockerfile
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- ezdz-rails.gemspec
|
75
|
+
- lib/ezdz-rails.rb
|
76
|
+
- lib/ezdz-rails/version.rb
|
77
|
+
- make_new_release.sh
|
78
|
+
- vendor/assets/javascripts/jquery.ezdz.js
|
79
|
+
- vendor/assets/stylesheets/jquery.ezdz.css
|
80
|
+
homepage: https://github.com/YourCursus/ezdz-rails
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.6.3
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: This Gem integrates Jay Salvat's Ezdz [izy-dizy] with Rails, exposing its
|
104
|
+
JavaScript and CSS assets via a Rails Engine.
|
105
|
+
test_files: []
|