From 90e3d8dbc707760aefad9ea1004ccdeaadd56351 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 9 Apr 2014 14:40:41 +0200 Subject: [PATCH 1/1] =?utf8?q?Upload=20par=20drag=20&=20drop=20des=20fichi?= =?utf8?q?ers=20dans=20l'=C3=A9diteur.=20Premier=20jet=20(encore=20des=20b?= =?utf8?q?ugs).?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/ckeditor/plugins/plinn_image/plugin.js | 169 +++++++++++++++++++ 1 file changed, 169 insertions(+) diff --git a/skins/ckeditor/plugins/plinn_image/plugin.js b/skins/ckeditor/plugins/plinn_image/plugin.js index ebce6a9..149de7f 100644 --- a/skins/ckeditor/plugins/plinn_image/plugin.js +++ b/skins/ckeditor/plugins/plinn_image/plugin.js @@ -3,6 +3,171 @@ (function(){ +var reImage = /^image\//; + +var PlinnCKDDUploader = function(editor) { + this.editor = editor; + this.uploadUrl = editor.config.baseHref + 'attachments/put_upload'; + this.uploadQueue = []; + this._uploadQueueRunning = false; + var self = this; + editor.document.on('dragenter', function(e) {self.dragenter(e);}); + editor.document.on('dragover', function(e) {self.dragover(e);}); + editor.document.on('drop', function(e) {self.drop(e);}); +}; + +// Drag and drop +PlinnCKDDUploader.prototype.dragenter = function(e) { + evt = e.data.$; + disableDefault(evt); + disablePropagation(evt); +}; + +PlinnCKDDUploader.prototype.dragover = function(e) { + evt = e.data.$; + disableDefault(evt); + disablePropagation(evt); + evt = getEventObject(evt); + var dt = evt.dataTransfer; + dt.dropEffect = 'copy'; +}; + +PlinnCKDDUploader.prototype.drop = function(e) { + evt = e.data.$; + disableDefault(evt); + disablePropagation(evt); + getEventObject(evt); + var dt = evt.dataTransfer; + dt.dropEffect = 'copy'; + this.handleFiles(dt.files); +}; + +PlinnCKDDUploader.prototype.createFileProxy = function(file) { + var container = new CKEDITOR.dom.element('span'); + var rel = CKEDITOR.dom.element.createFromHtml(''); + container.append(rel); + var progressBar = CKEDITOR.dom.element.createFromHtml('') + rel.append(progressBar); + var link = new CKEDITOR.dom.element('a'); + link.setAttribute('href', '#'); + link.appendText(file.name); + container.append(link); + + var proxy = new Object(); + proxy.file = file; + proxy.container = container; + proxy.progressBar = progressBar; + proxy.link = link; + return proxy; +}; + +// Methods about upload +PlinnCKDDUploader.prototype.handleFiles = function(files) { + var file, i, proxy; + for (i=0 ; i