X-Git-Url: https://svn.cri.ensmp.fr/git/ckeditor.git/blobdiff_plain/015e0dd96227ff485466c52dfa6c3d8ee541cf54..35d32f35f43e33f068b39a4c7daf9eb16773cbe7:/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 c7ae5ec..046b7ad 100644
--- a/skins/ckeditor/plugins/plinn_image/plugin.js
+++ b/skins/ckeditor/plugins/plinn_image/plugin.js
@@ -4,12 +4,17 @@
(function(){
var reImage = /^image\//;
+var MAX_PREVIEW = 2;
var PlinnCKDDUploader = function(editor) {
this.editor = editor;
this.uploadUrl = editor.config.baseHref + 'attachments/put_upload';
this.uploadQueue = [];
this._uploadQueueRunning = false;
+ this.previewQueue = [];
+ this._previewQueueRunning = false;
+ this.previewsLoaded = 0;
+ this.thumbnailSize = 310;
var self = this;
editor.document.on('dragenter', function(e) {self.dragenter(e);});
editor.document.on('dragover', function(e) {self.dragover(e);});
@@ -42,7 +47,7 @@ PlinnCKDDUploader.prototype.drop = function(e) {
this.handleFiles(dt.files);
};
-PlinnCKDDUploader.prototype.createFileProxy = function(file) {
+PlinnCKDDUploader.prototype.createLinkProxy = function(file) {
var container = new CKEDITOR.dom.element('span');
var rel = CKEDITOR.dom.element.createFromHtml('');
container.append(rel);
@@ -51,31 +56,73 @@ PlinnCKDDUploader.prototype.createFileProxy = function(file) {
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.type = 'link';
proxy.container = container;
proxy.progressBar = progressBar;
proxy.link = link;
return proxy;
};
+PlinnCKDDUploader.prototype.createImageProxy = 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 img = new CKEDITOR.dom.element('img');
+ img.setAttribute('width', 310);
+ img.setAttribute('height', 290);
+ img.setStyle('opacity', 0.2);
+ img.setAttribute('src', 'no_image.jpg');
+ var size = this.thumbnailSize;
+
+ img.on('load', function(e) {
+ var img$ = img.$;
+ if (img$.width > img$.height) { // landscape
+ img$.height = Math.round(size * img$.height / img$.width);
+ img$.width = size;
+ }
+ else {
+ img$.width = Math.round(size * img$.width / img$.height);
+ img$.height = size;
+ }
+ img$.style.opacity = 0.2;
+ });
+
+ container.append(img);
+
+ var proxy = {};
+ proxy.file = file;
+ proxy.type = 'image';
+ proxy.container = container;
+ proxy.progressBar = progressBar;
+ proxy.img = img;
+ return proxy;
+};
+
// Methods about upload
PlinnCKDDUploader.prototype.handleFiles = function(files) {
var file, i, proxy;
for (i=0 ; i