mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-13 05:01:43 +00:00
check file size before uploading, show msg returned by addtoclipboard
This commit is contained in:
parent
3590b0859e
commit
ae848f209b
|
@ -448,12 +448,11 @@ function onAddClipboard(ev) {
|
||||||
$.get('../op/op.Ajax.php',
|
$.get('../op/op.Ajax.php',
|
||||||
{ command: 'addtoclipboard', type: source_type, id: source_id },
|
{ command: 'addtoclipboard', type: source_type, id: source_id },
|
||||||
function(data) {
|
function(data) {
|
||||||
console.log(data);
|
|
||||||
if(data.success) {
|
if(data.success) {
|
||||||
$("#main-clipboard").html('Loading').load('../op/op.Ajax.php?command=view&view=mainclipboard')
|
$("#main-clipboard").html('Loading').load('../op/op.Ajax.php?command=view&view=mainclipboard')
|
||||||
$("#menu-clipboard").html('Loading').load('../op/op.Ajax.php?command=view&view=menuclipboard')
|
$("#menu-clipboard").html('Loading').load('../op/op.Ajax.php?command=view&view=menuclipboard')
|
||||||
noty({
|
noty({
|
||||||
text: attr_msg,
|
text: data.message,
|
||||||
type: 'success',
|
type: 'success',
|
||||||
dismissQueue: true,
|
dismissQueue: true,
|
||||||
layout: 'topRight',
|
layout: 'topRight',
|
||||||
|
@ -480,22 +479,32 @@ function onAddClipboard(ev) {
|
||||||
|
|
||||||
(function( SeedDMSUpload, $, undefined ) {
|
(function( SeedDMSUpload, $, undefined ) {
|
||||||
var ajaxurl = "../op/op.Ajax.php";
|
var ajaxurl = "../op/op.Ajax.php";
|
||||||
var successMsg = "File uploaded";
|
var editBtnLabel = "Edit";
|
||||||
var editBtnLabel = "Edit document";
|
var abortBtnLabel = "Abort";
|
||||||
|
var maxFileSize = 100000;
|
||||||
|
var maxFileSizeMsg = 'File too large';
|
||||||
var rowCount=0;
|
var rowCount=0;
|
||||||
|
|
||||||
SeedDMSUpload.setUrl = function(url) {
|
SeedDMSUpload.setUrl = function(url) {
|
||||||
ajaxurl = url;
|
ajaxurl = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
SeedDMSUpload.setSuccessMsg = function(msg) {
|
SeedDMSUpload.setAbortBtnLabel = function(label) {
|
||||||
successMsg = msg;
|
abortBtnLabel = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
SeedDMSUpload.setEditBtnLabel = function(label) {
|
SeedDMSUpload.setEditBtnLabel = function(label) {
|
||||||
editBtnLabel = label;
|
editBtnLabel = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SeedDMSUpload.setMaxFileSize = function(size) {
|
||||||
|
maxFileSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
SeedDMSUpload.setMaxFileSizeMsg = function(msg) {
|
||||||
|
maxFileSizeMsg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
function sendFileToServer(formData,status) {
|
function sendFileToServer(formData,status) {
|
||||||
formData.append('command', 'uploaddocument');
|
formData.append('command', 'uploaddocument');
|
||||||
var uploadURL = ajaxurl; //Upload URL
|
var uploadURL = ajaxurl; //Upload URL
|
||||||
|
@ -562,7 +571,7 @@ function onAddClipboard(ev) {
|
||||||
this.filename = $("<div class='filename'></div>").appendTo(this.statusbar);
|
this.filename = $("<div class='filename'></div>").appendTo(this.statusbar);
|
||||||
this.size = $("<div class='filesize'></div>").appendTo(this.statusbar);
|
this.size = $("<div class='filesize'></div>").appendTo(this.statusbar);
|
||||||
this.progressBar = $("<div class='progress'><div class='bar bar-success'></div></div>").appendTo(this.statusbar);
|
this.progressBar = $("<div class='progress'><div class='bar bar-success'></div></div>").appendTo(this.statusbar);
|
||||||
this.abort = $("<div class='btn btn-danger'>Abort</div>").appendTo(this.statusbar);
|
this.abort = $("<div class='btn btn-mini btn-danger'>" + abortBtnLabel + "</div>").appendTo(this.statusbar);
|
||||||
// $('.statusbar').empty();
|
// $('.statusbar').empty();
|
||||||
obj.after(this.statusbar);
|
obj.after(this.statusbar);
|
||||||
this.setFileNameSize = function(name,size) {
|
this.setFileNameSize = function(name,size) {
|
||||||
|
@ -598,14 +607,25 @@ function onAddClipboard(ev) {
|
||||||
var target = obj.data('target');
|
var target = obj.data('target');
|
||||||
if(target) {
|
if(target) {
|
||||||
for (var i = 0; i < files.length; i++) {
|
for (var i = 0; i < files.length; i++) {
|
||||||
var fd = new FormData();
|
if(files[i].size <= maxFileSize) {
|
||||||
fd.append('folderid', target);
|
var fd = new FormData();
|
||||||
fd.append('formtoken', obj.data('formtoken'));
|
fd.append('folderid', target);
|
||||||
fd.append('userfile', files[i]);
|
fd.append('formtoken', obj.data('formtoken'));
|
||||||
|
fd.append('userfile', files[i]);
|
||||||
|
|
||||||
var status = new createStatusbar(obj); //Using this we can set progress.
|
var status = new createStatusbar(obj);
|
||||||
status.setFileNameSize(files[i].name,files[i].size);
|
status.setFileNameSize(files[i].name,files[i].size);
|
||||||
sendFileToServer(fd,status);
|
sendFileToServer(fd,status);
|
||||||
|
} else {
|
||||||
|
noty({
|
||||||
|
text: maxFileSizeMsg + '<br /><em>' + files[i].name + ' (' + files[i].size + ' Bytes)</em>',
|
||||||
|
type: 'error',
|
||||||
|
dismissQueue: true,
|
||||||
|
layout: 'topRight',
|
||||||
|
theme: 'defaultTheme',
|
||||||
|
timeout: 5000,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user