X-Git-Url: https://scm.cri.mines-paristech.fr/git/ckeditor.git/blobdiff_plain/7c4f7ce0c90fd8b1413f4cc46eb5c84730d61e56..2d713e87d60560e07419d37004b0261fbd972baf:/skins/ckeditor/plugins/plinn_image/plugin.js
diff --git a/skins/ckeditor/plugins/plinn_image/plugin.js b/skins/ckeditor/plugins/plinn_image/plugin.js
index 7f8f3f2..631f9fa 100644
--- a/skins/ckeditor/plugins/plinn_image/plugin.js
+++ b/skins/ckeditor/plugins/plinn_image/plugin.js
@@ -1,20 +1,190 @@
-/* © Benoît Pin, MINES ParisTech */
+/* © 2011 Benoît Pin, MINES ParisTech */
(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) {
+ var evt = e.data.$;
+ disableDefault(evt);
+ disablePropagation(evt);
+};
+
+PlinnCKDDUploader.prototype.dragover = function(e) {
+ var evt = e.data.$;
+ disableDefault(evt);
+ disablePropagation(evt);
+ evt = getEventObject(evt);
+ var dt = evt.dataTransfer;
+ dt.dropEffect = 'copy';
+};
+
+PlinnCKDDUploader.prototype.drop = function(e) {
+ var 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.setStyle('opacity', 0.2);
+ link.appendText(file.name);
+ container.append(link);
+
+ var proxy = {};
+ 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