diff --git a/styles/bootstrap/application.js b/styles/bootstrap/application.js index 0b42439fa..d2b36d647 100644 --- a/styles/bootstrap/application.js +++ b/styles/bootstrap/application.js @@ -442,8 +442,8 @@ function onDrop(ev) { function onAddClipboard(ev) { ev.preventDefault(); - source_type = ev.dataTransfer.getData("type"); - source_id = ev.dataTransfer.getData("id"); + source_type = ev.originalEvent.dataTransfer.getData("type"); + source_id = ev.originalEvent.dataTransfer.getData("id"); if(source_type == 'document' || source_type == 'folder') { $.get('../op/op.Ajax.php', { command: 'addtoclipboard', type: source_type, id: source_id }, @@ -477,3 +477,182 @@ function onAddClipboard(ev) { //document.location = url; } } + +(function( SeedDMSUpload, $, undefined ) { + var ajaxurl = "../op/op.Ajax.php"; + var successMsg = "File uploaded"; + var editBtnLabel = "Edit document"; + var rowCount=0; + + SeedDMSUpload.setUrl = function(url) { + ajaxurl = url; + } + + SeedDMSUpload.setSuccessMsg = function(msg) { + successMsg = msg; + } + + SeedDMSUpload.setEditBtnLabel = function(label) { + editBtnLabel = label; + } + + function sendFileToServer(formData,status) { + formData.append('command', 'uploaddocument'); + var uploadURL = ajaxurl; //Upload URL + var extraData ={}; //Extra Data. + var jqXHR=$.ajax({ + xhr: function() { + var xhrobj = $.ajaxSettings.xhr(); + if (xhrobj.upload) { + xhrobj.upload.addEventListener('progress', function(event) { + var percent = 0; + var position = event.loaded || event.position; + var total = event.total; + if (event.lengthComputable) { + percent = Math.ceil(position / total * 100); + } + //Set progress + status.setProgress(percent); + }, false); + } + return xhrobj; + }, + url: uploadURL, + type: "POST", + contentType: false, + dataType:"json", + processData: false, + cache: false, + data: formData, + success: function(data){ + status.setProgress(100); +// console.log(data); + if(data.success) { + noty({ + text: data.message, + type: 'success', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 1500, + }); + status.statusbar.after($('' + editBtnLabel + '')); + } else { + noty({ + text: data.message, + type: 'error', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 3500, + }); + } + } + }); + + status.setAbort(jqXHR); + } + + function createStatusbar(obj) { + rowCount++; + var row="odd"; + this.obj = obj; + if(rowCount %2 ==0) row ="even"; + this.statusbar = $("
"); + this.filename = $("").appendTo(this.statusbar); + this.size = $("").appendTo(this.statusbar); + this.progressBar = $("