Skip to content

Commit

Permalink
fixed added new files
Browse files Browse the repository at this point in the history
  • Loading branch information
Fafnur committed Feb 17, 2016
1 parent 4c79e61 commit f69824a
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 22 deletions.
8 changes: 3 additions & 5 deletions Form/Type/DropzoneType.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public function buildView(FormView $view, FormInterface $form, array $options)

$view->vars['requestId'] = $options['requestId'];
$view->vars['views'] = $options['views' ];
$view->vars['thumbnailOptions'] = $options['thumbnailOptions'];
$view->vars['type'] = $context;
$view->vars['files'] = $files;
// $view->vars['previewImg'] = $options['previewImg'];
Expand All @@ -127,7 +126,6 @@ public function buildView(FormView $view, FormInterface $form, array $options)
'requestId' => $options['requestId'],
'dropzoneContainer' => '#js-gwu-dropzone_' . $options['requestId'],
'previewShow' => $view->vars['previewShow'],
'thumbnailOptions' => $view->vars['thumbnailOptions'],
'uploadDir' => $uploadDir,
'countFiles' => $files->count(),
'maxFiles' => $view->vars['dropzoneOptions']['maxFiles'],
Expand All @@ -153,7 +151,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
'showLabel' => true,
'thumbnailOptions' => array(
'width' => 200,
'height' => 150,
'height' => 200,
),
'views' => array(
// 'form' => 'path/to/view',
Expand Down Expand Up @@ -202,8 +200,8 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
'clickable' => null,
'maxFilesize' => 2,
'maxFiles' => 20,
'thumbnailWidth' => 250,
'thumbnailHeight' => 150,
'thumbnailWidth' => 350,
'thumbnailHeight' => 350,
'parallelUploads' => 20,
'autoQueue' => true,
'autoProcessQueue' => true,
Expand Down
64 changes: 64 additions & 0 deletions Resources/public/css/gwu.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
.gwu.gwu-dropzone .gwu-previews {
min-height: inherit;
overflow: hidden;
border: none;
-webkit-border-radius: 0;
-webkit-background-clip: padding-box;
-moz-border-radius: 0;
-moz-background-clip: padding;
border-radius: 0;
background-clip: padding-box;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
margin: 30px -15px 0 -15px;
padding: 0;
}
.gwu.gwu-dropzone .gwu-preview {
display: block;
float: left;
margin: 0 0 30px 0;
width: 100%;
padding: 0 15px;
}
.gwu.gwu-dropzone .gwu-preview__image {
width: 100%;
height: 100%;
-webkit-border-radius: 8px;
-webkit-background-clip: padding-box;
-moz-border-radius: 8px;
-moz-background-clip: padding;
border-radius: 8px;
background-clip: padding-box;
}
.gwu.gwu-dropzone .gwu-preview__details {
padding: 30px;
}
.gwu.gwu-dropzone .gwu-preview-img {
max-width: 100%;
}
@media (min-width: 480px) {
.gwu.gwu-dropzone .gwu-preview {
width: 50%;
}
}
@media (min-width: 768px) {
.gwu.gwu-dropzone .gwu-preview {
width: 33.3%;
}
}
@media (min-width: 992px) {
.gwu.gwu-dropzone .gwu-preview {
width: 25%;
}
}
@media (min-width: 1200px) {
.gwu.gwu-dropzone .gwu-preview {
width: 20%;
}
}
@media (min-width: 1600px) {
.gwu.gwu-dropzone .gwu-preview {
width: 16.6%;
}
}
19 changes: 14 additions & 5 deletions Resources/public/js/glavwebUploaderDropzone.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(function ($) {

Dropzone.autoDiscover = false;

var isDebug = true,
_log = function (message) {
if (window.console && isDebug) {
Expand All @@ -24,6 +26,7 @@
if(uploader.uploaderOptions.popup) {
$(uploader.uploaderOptions.popupContainer).plainModal();
}
methods.bindEvents();
_log('init');
_log(dropzone);
return this;
Expand All @@ -48,8 +51,12 @@
/**
* Добавляем mock файлы в dropzone
*/
addFile: function ( name, id, src) {
var mockFile = { name: name, size: 0, accepted: true};
addFile: function ( name, id, src, size) {
var mockFile = {
name: name,
size: size,
accepted: true
};
dropzone.emit('addedfile', mockFile);

if (uploader.uploaderOptions.isThumbnail) {
Expand All @@ -62,6 +69,7 @@

$mockFileTpl.data('id', id);
$mockFileTpl.data('src', src);
$mockFileTpl.addClass('dz-complete');
$mockFileTpl.attr('id', 'dz-preview-' + id);

mockFile.response = {
Expand Down Expand Up @@ -151,12 +159,13 @@
*/
bindEvents: function () {

$dropzone.on("sending", function (file, xhr, formData) {
dropzone.on("sending", function (file, xhr, formData) {
$(uploader.uploaderOptions.preloader).removeClass('hidden');
formData.append('_glavweb_uploader_request_id', uploader.uploaderOptions.requestId);
});

$dropzone.on("success", function (file, response) {
dropzone.on("success", function (file, response) {
//console.log(response);
file.response = response;
var $template = $(file.previewTemplate);
$template.data('id', response.id);
Expand All @@ -167,7 +176,7 @@
methods.hideErrors();
});

$dropzone.on("removedfile", function (file) {
dropzone.on("removedfile", function (file) {
var id = file.response.id;

if (id !== undefined) {
Expand Down
62 changes: 62 additions & 0 deletions Resources/public/less/gwu.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.gwu.gwu-dropzone {

.gwu-previews {
min-height: inherit;
overflow: hidden;
border: none;
.border-radius(0);
.box-shadow(none);
margin: 30px -15px 0 -15px;
padding: 0;
}

.gwu-preview {
display: block;
float: left;
margin: 0 0 30px 0;
width: 100%;
padding: 0 15px;

&__image {
width: 100%;
height: 100%;

.border-radius(8px);
}

&__details {
padding: 30px;
}
}

.gwu-preview-img {
max-width: 100%;
}

@media (min-width: @screen-xs-min) {
.gwu-preview {
width: 50%;
}
}
@media (min-width: @screen-sm-min) {
.gwu-preview {
width: 33.3%;
}
}
@media (min-width: @screen-md-min) {
.gwu-preview {
width: 25%;
}
}
@media (min-width: @screen-lg-min) {
.gwu-preview {
width: 20%;
}
}
@media (min-width: 1600px) {
.gwu-preview {
width: 16.6%;
}
}
}

12 changes: 4 additions & 8 deletions Resources/views/Form/fields.html.twig
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{% block glavweb_uploader_dropzone_widget %}
<div class="dz dropzone gwu-dropzone {{ uploaderOptions.uploaderClass }}">
<div class="gwu gwu-dropzone {{ uploaderOptions.uploaderClass }}">
<input type="hidden" name="_glavweb_uploader_request_id" value="{{ requestId }}">
{#<input type="hidden" name="_glavweb_uploader_sorted_array[{{ type }}]" id = "dz-sorted-array" value="">#}
<input type="hidden" name="_glavweb_uploader_sorted_array[{{ uploaderOptions.type }}]" id = "dz-sorted-array" value="">

<div id="{{ uploaderOptions.dropzoneContainer[1:] }}" class="js-gwu-dropzone">
{% include 'GlavwebUploaderBundle:Form/form:' ~ uploaderOptions.formViewType ~ '.html.twig' %}
</div>


{% include 'GlavwebUploaderBundle:Form/item:base.html.twig' %}

{#<div class="js-reached-limit-message {% if countFiles < maxFiles %}js-file-upload-hide{% endif %}">#}
Expand All @@ -18,10 +17,7 @@
{#</div>#}


<div id="{{ dropzoneOptions.previewsContainer[1:] }}" class="previews">
{#{% include uploadedFilesTpl with {'files': files} %}#}
</div>

<div id="{{ dropzoneOptions.previewsContainer[1:] }}" class="dropzone previews gwu-previews"></div>
</div>

{% block glavweb_uploader_dropzone_widget__madal %}
Expand Down Expand Up @@ -138,7 +134,7 @@
{% for media in files %}
{% set imgSrc = media|glavweb_uploader_thumbnail %}
$uploader.glavwebUploaderDropzone('addFile','{{ media.name }}', {{ media.id }}, '{{ imgSrc }}');
$uploader.glavwebUploaderDropzone('addFile','{{ media.name }}', {{ media.id }}, '{{ imgSrc }}', {{ media.contentSize }} );
{% endfor %}
});
})(jQuery);
Expand Down
8 changes: 4 additions & 4 deletions Resources/views/Form/item/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@

{% block glavweb_uploader_preview_image %}
<div class="dz-image gwu-preview__image">
<div class="gwu-preview-image">
<div class="gwu-preview-image__box">
<img class="glavweb-img" data-dz-thumbnail>
<div class="gwu-table">
<div class="gwu-table-cell">
<img class="gwu-preview-img" data-dz-thumbnail alt=""/>
</div>
</div>
</div>
{% endblock %}

{% block glavweb_uploader_preview_details %}
{% if previewShow.isDetails %}
<div class="dz-details gwu-preview-details">
<div class="dz-details gwu-preview__details">
{% if previewShow.isSize %}
<div class="dz-size gwu-preview-details__size">
<span data-dz-size=""></span>
Expand Down

0 comments on commit f69824a

Please sign in to comment.