mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 14:18:27 +01:00
Enhanced file upload handling.
This commit is contained in:
parent
ceb2c634fe
commit
684ec2dcb0
@ -109,8 +109,14 @@ humhub.module('file', function(module, require, $) {
|
||||
};
|
||||
|
||||
Upload.prototype.initPreview = function() {
|
||||
this.preview = Preview.instance(this.$.data('upload-preview'));
|
||||
this.preview.source = this;
|
||||
if(this.$.data('upload-preview')) {
|
||||
this.preview = Preview.instance(this.$.data('upload-preview'));
|
||||
if(this.preview.setSource) {
|
||||
this.preview.setSource(this);
|
||||
} else {
|
||||
this.preview.source;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Upload.prototype.initProgress = function() {
|
||||
@ -128,6 +134,7 @@ humhub.module('file', function(module, require, $) {
|
||||
start: this.options.start,
|
||||
progressall: this.options.progressall,
|
||||
done: this.options.done,
|
||||
error: this.options.error,
|
||||
stop: this.options.stop
|
||||
};
|
||||
|
||||
@ -135,11 +142,16 @@ humhub.module('file', function(module, require, $) {
|
||||
start: $.proxy(this.start, this),
|
||||
progressall: $.proxy(this.updateProgress, this),
|
||||
done: $.proxy(this.done, this),
|
||||
error: $.proxy(this.error, this),
|
||||
stop: $.proxy(this.finish, this)
|
||||
});
|
||||
|
||||
this.$.fileupload(this.options);
|
||||
};
|
||||
|
||||
Upload.prototype.error = function(e) {
|
||||
module.log.error(e, true);
|
||||
};
|
||||
|
||||
Upload.prototype.start = function(e, data) {
|
||||
if(this.progress) {
|
||||
@ -161,15 +173,17 @@ humhub.module('file', function(module, require, $) {
|
||||
}
|
||||
};
|
||||
|
||||
Upload.prototype.done = function(e, data) {
|
||||
Upload.prototype.done = function(e, response) {
|
||||
var that = this;
|
||||
$.each(data.result.files, function(index, file) {
|
||||
$.each(response.result.files, function(index, file) {
|
||||
that.handleFileResponse(file);
|
||||
});
|
||||
|
||||
|
||||
if(this.callbacks.done) {
|
||||
this.callbacks.done(e, data);
|
||||
this.callbacks.done(e, response);
|
||||
}
|
||||
|
||||
this.fire('humhub:file:upload', [response]);
|
||||
};
|
||||
|
||||
Upload.prototype.handleFileResponse = function(file) {
|
||||
|
@ -12,18 +12,34 @@ use Yii;
|
||||
*/
|
||||
class UploadButton extends UploadInput
|
||||
{
|
||||
/**
|
||||
* Additional button html options.
|
||||
* @var array
|
||||
*/
|
||||
public $buttonOptions = [];
|
||||
|
||||
/**
|
||||
* Show button tooltip on mousover.
|
||||
* @var boolean
|
||||
*/
|
||||
public $tooltip = true;
|
||||
|
||||
/**
|
||||
* Tooltip position.
|
||||
* @var string
|
||||
*/
|
||||
public $tooltipPosition = 'bottom';
|
||||
|
||||
/**
|
||||
* Draws the Upload Button output.
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$defaultButtonOptions = [
|
||||
'class' => 'btn btn-default fileinput-button tt',
|
||||
'class' => ($this->tooltip) ? 'btn btn-default fileinput-button tt' : 'btn btn-default fileinput-button',
|
||||
'title' => Yii::t('FileModule.widgets_views_fileUploadButton', 'Upload files'),
|
||||
'data' => [
|
||||
'placement' => "bottom",
|
||||
'placement' => $this->tooltipPosition,
|
||||
'action-click' => "file.upload",
|
||||
'action-target' => '#'.$this->id
|
||||
]
|
||||
@ -36,7 +52,4 @@ class UploadButton extends UploadInput
|
||||
'options' => $options
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
@ -157,7 +157,7 @@ class SpaceController extends \humhub\modules\content\components\ContentContaine
|
||||
$title = Yii::t('SpaceModule.base', '<strong>Space</strong> followers');
|
||||
return $this->renderAjaxContent(UserListBox::widget(['query' => $query, 'title' => $title]));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -56,7 +56,7 @@ class CoreJsConfig extends Widget
|
||||
],
|
||||
'text' => [
|
||||
'error.upload' => Yii::t('base', 'Some files could not be uploaded:'),
|
||||
'success.delete' => Yii::t('base', 'The file has been deleted.'),
|
||||
'success.delete' => Yii::t('base', 'The file has been deleted.')
|
||||
]
|
||||
],
|
||||
'action' => [
|
||||
@ -73,6 +73,8 @@ class CoreJsConfig extends Widget
|
||||
'ui.widget' => [
|
||||
'text' => [
|
||||
'error.unknown' => Yii::t('base', 'No error information given.'),
|
||||
'info.title' => Yii::t('base', 'Info:'),
|
||||
'error.title' => Yii::t('base', 'Error:')
|
||||
]
|
||||
],
|
||||
'ui.richtext' => [
|
||||
|
@ -136,7 +136,7 @@ humhub.module('ui.widget', function(module, require, $) {
|
||||
};
|
||||
|
||||
Widget.prototype.statusError = function(title) {
|
||||
var msg = title || 'Error:';
|
||||
var msg = title || module.text('error.title');;
|
||||
msg += '<br /><br /><ul style="list-style:none;">';
|
||||
|
||||
$.each(this.errors, function(i, error) {
|
||||
@ -153,6 +153,24 @@ humhub.module('ui.widget', function(module, require, $) {
|
||||
module.log.error(msg, true);
|
||||
this.errors = [];
|
||||
};
|
||||
|
||||
Widget.prototype.statusInfo = function(infos, title) {
|
||||
var msg = title || module.text('info.title');
|
||||
msg += '<br /><br /><ul style="list-style:none;">';
|
||||
|
||||
$.each(infos, function(i, error) {
|
||||
if(error && !object.isArray(error)) {
|
||||
msg += '<li>' + error + '</li>';
|
||||
} else if(!error[0]) {
|
||||
msg += '<li>' + module.text('error.unknown') + '</li>';
|
||||
} else {
|
||||
msg += '<li>' + error[0] + '</li>';
|
||||
}
|
||||
});
|
||||
|
||||
msg += '</ul>';
|
||||
module.log.info(msg, true);
|
||||
};
|
||||
|
||||
Widget.prototype.show = function() {
|
||||
this.$.show();
|
||||
|
@ -65,7 +65,7 @@ humhub.module('util', function(module, require, $) {
|
||||
handlers.forEach(function(handler) {
|
||||
handler.apply(thisObj, _arguments);
|
||||
});
|
||||
}
|
||||
};
|
||||
},
|
||||
inherits: function(Sub, Parent) {
|
||||
for(var i in Parent) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user