// Add Drag and Drop to uploader helper

This commit is contained in:
Jerome Nadaud
2013-11-28 09:55:22 +01:00
parent 82022c337a
commit 510b71054a
3 changed files with 22 additions and 2 deletions
@@ -109,7 +109,8 @@
dataType: 'json',
autoUpload: false,
singleFileUploads: true,
maxFileSize: {$post_max_size},
{if isset($post_max_size)}maxFileSize: {$post_max_size},{/if}
{if isset($drop_zone)}dropZone: {$drop_zone},{/if}
start: function (e) {
{$id}_upload_button.start();
$('#{$id}-upload-button').unbind('click'); //Important as we bind it for every elements in add function
+3
View File
@@ -110,6 +110,9 @@ class UploaderCore
case 'k': $bytes *= 1024;
}
if ($bytes == '')
$bytes = null;
return $bytes;
}
+17 -1
View File
@@ -34,6 +34,7 @@ class HelperUploaderCore extends Uploader
const TYPE_FILE = 'file';
private $_context;
private $_drop_zone;
private $_id;
private $_files;
private $_name;
@@ -59,6 +60,20 @@ class HelperUploaderCore extends Uploader
return $this->_context;
}
public function setDropZone($value)
{
$this->_drop_zone = $value;
return $this;
}
public function getDropZone()
{
if (!isset($this->_drop_zone))
$this->setDropZone('$(document)');
return $this->_drop_zone;
}
public function setId($value)
{
$this->_id = (string)$value;
@@ -270,7 +285,8 @@ class HelperUploaderCore extends Uploader
'files' => $this->getFiles(),
'title' => $this->getTitle(),
'max_files' => $this->getMaxFiles(),
'post_max_size' => $this->getPostMaxSizeBytes()
'post_max_size' => $this->getPostMaxSizeBytes(),
'drop_zone' => $this->getDropZone()
));
$html .= $template->fetch();