Commit 2a4c38d3 authored by Henning Leutz's avatar Henning Leutz 🥋

Merge branch 'dev'

parents 9604c429 e93c1400
......@@ -61,9 +61,11 @@ define('controls/upload/File', [
],
options: {
phpfunc : '',
phponstart: '', // (optional) php function which called before the upload starts
params : {}
phpfunc : '',
phponstart : '', // (optional) php function which called before the upload starts
params : {},
pauseAllowed: true,
contextMenu : true
},
$File : false,
......@@ -104,7 +106,7 @@ define('controls/upload/File', [
this.$result = null;
this.$error = false;
this.$ContextMenu = null;
this.$slice_method = 'slice';
if ('mozSlice' in this.$File) {
......@@ -155,20 +157,26 @@ define('controls/upload/File', [
var self = this;
this.$Elm = new Element('div', {
html : '<div class="file-name">' + this.getFilename() + '</div>' +
html : '<div class="file-name">' + this.getFilename() + '</div>' +
'<div class="upload-time"></div>' +
'<div class="progress"></div>' +
'<div class="buttons"></div>',
'class': 'upload-manager-file box smooth'
'class' : 'upload-manager-file box smooth',
'data-file': this.getId()
});
this.$Elm.addEvents({
click : function () {
click: function () {
self.fireEvent('click', [self]);
},
contextmenu: function (event) {
event.stop();
if (!self.$ContextMenu) {
return;
}
self.$ContextMenu.setPosition(
event.page.x,
event.page.y
......@@ -186,7 +194,7 @@ define('controls/upload/File', [
var Buttons = this.$Elm.getElement('.buttons');
Buttons.set({
html : '<form action="" method=""">' +
html : '<form action="" method="">' +
'<input type="file" name="files" value="upload" />' +
'</form>',
styles: {
......@@ -276,28 +284,35 @@ define('controls/upload/File', [
this.$PauseResume.inject(Buttons);
// context menu
this.$ContextMenu = new QUIContextMenu({
title : this.getFilename(),
events: {
blur: function (Menu) {
Menu.hide();
}
}
});
this.$ContextMenu.appendChild(
new QUIContextmenuItem({
text : Locale.get(lg, 'file.upload.remove'),
File : this,
if (this.getAttribute('contextMenu')) {
this.$ContextMenu = new QUIContextMenu({
title : this.getFilename(),
events: {
onClick: function (Item) {
Item.getAttribute('File').getElm().destroy();
blur: function (Menu) {
Menu.hide();
}
}
})
);
});
this.$ContextMenu.appendChild(
new QUIContextmenuItem({
text : Locale.get(lg, 'file.upload.remove'),
File : this,
events: {
onClick: function (Item) {
Item.getAttribute('File').getElm().destroy();
}
}
})
);
this.$ContextMenu.inject(document.body);
}
this.$ContextMenu.inject(document.body);
// no pause button
if (this.getAttribute('pauseAllowed') === false) {
this.$PauseResume.hide();
}
// onerror, display it
this.addEvent('onError', function (Exception, File) {
......
......@@ -8,7 +8,7 @@
*
* @fires onAdd [this, File]
* @fires onBegin [this]
* @fires onCancel
* @fires onCancel [this, File]
* @fires onComplete [this]
* @fires onFinished [this]
* @fires onSubmit [Array, this]
......@@ -54,12 +54,15 @@ define('controls/upload/Form', [
multiple : false, // are multiple uploads allowed?
sendbutton : false, // insert a send button
cancelbutton: false, // insert a cancel button
styles : false
styles : false,
pauseAllowed: true,
contextMenu : true // context menu for the file upload
},
Binds: [
'$onFileUploadFinish',
'$onFileUploadRefresh',
'$onFileUploadCancel',
'$onError'
],
......@@ -700,10 +703,14 @@ define('controls/upload/Form', [
UploadManager.addEvents({
onFileComplete : self.$onFileUploadFinish,
onFileCancel : self.$onFileUploadCancel,
onFileUploadRefresh: self.$onFileUploadRefresh,
onError : self.$onError
});
UploadManager.setAttribute('pauseAllowed', self.getAttribute('pauseAllowed'));
UploadManager.setAttribute('contextMenu', self.getAttribute('contextMenu'));
self.$Elm.set('html', '');
self.createInfo().inject(self.$Elm);
......@@ -934,6 +941,11 @@ define('controls/upload/Form', [
},
$onFileUploadCancel: function (UploadManager, File) {
this.fireEvent('cancel', [this, File]);
},
/**
* Event on error
*
......
......@@ -5,15 +5,7 @@
* @module controls/upload/Manager
* @author www.pcsg.de (Henning Leutz)
*
* @require qui/QUI
* @require qui/controls/desktop/Panel
* @require qui/controls/utils/Progressbar
* @require qui/controls/windows/Alert
* @require controls/upload/File
* @require Ajax
* @require Locale
* @require css!controls/upload/Manager.css
*
* @event onFileCancel [ {self}, {File} ]
* @event onFileComplete [ {self}, {File} ]
* @event onFileUploadRefresh [ {self}, {Number} percent ]
*/
......@@ -55,7 +47,9 @@ define('controls/upload/Manager', [
],
options: {
icon: 'fa fa-upload'
icon : 'fa fa-upload',
pauseAllowed: true,
contextMenu : true
},
initialize: function (options) {
......@@ -260,6 +254,43 @@ define('controls/upload/Manager', [
this.$maxPercent = files.length * 100;
var onComplete = function (File) {
self.fireEvent('fileComplete', [self, File]);
if (File.getElm().getParent() === document.body) {
(function () {
moofx(File.getElm()).animate({
opacity: 0
}, {
duration: 200,
callback: function () {
File.getElm().destroy();
}
});
}).delay(1000);
}
};
var onRefresh = function (File, percent) {
self.$uploadPerCents[File.getId()] = percent;
self.$onFileUploadRefresh();
};
var onError = function (Exception) {
if ('error' in self.$events) {
self.fireEvent('error', [Exception]);
return;
}
QUI.getMessageHandler(function (MessageHandler) {
MessageHandler.add(Exception);
});
};
var onCancel = function (File) {
self.fireEvent('fileCancel', [self, File]);
};
for (i = 0, len = files.length; i < len; i++) {
file_params = Object.clone(params);
file_params.extract = false;
......@@ -275,42 +306,18 @@ define('controls/upload/Manager', [
}
var QUIFile = new UploadFile(files[i], {
phpfunc: rf,
params : file_params,
events : events
phpfunc : rf,
params : file_params,
events : events,
pauseAllowed: this.getAttribute('pauseAllowed'),
contextMenu : this.getAttribute('contextMenu')
});
QUIFile.addEvents({
onComplete: function (File) {
self.fireEvent('fileComplete', [self, File]);
if (File.getElm().getParent() == document.body) {
(function () {
moofx(File.getElm()).animate({
opacity: 0
}, {
duration: 200,
callback: function () {
File.getElm().destroy();
}
});
}).delay(1000);
}
},
onRefresh : function (File, percent) {
self.$uploadPerCents[File.getId()] = percent;
self.$onFileUploadRefresh();
},
onError : function (Exception) {
if ('error' in self.$events) {
self.fireEvent('error', [Exception]);
return;
}
QUI.getMessageHandler(function (MessageHandler) {
MessageHandler.add(Exception);
});
}
onComplete: onComplete,
onRefresh : onRefresh,
onError : onError,
onCancel : onCancel
});
if (file_params.phponstart) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment