Déplacement préalable à l'eggification.
[ckeditor.git] / Products / ckeditor / skins / ckeditor / plugins / plinn_image / dialog / plinn_image.js
diff --git a/Products/ckeditor/skins/ckeditor/plugins/plinn_image/dialog/plinn_image.js b/Products/ckeditor/skins/ckeditor/plugins/plinn_image/dialog/plinn_image.js
new file mode 100644 (file)
index 0000000..bb4883c
--- /dev/null
@@ -0,0 +1,42 @@
+// (c) Benoît PIN 2006-2011
+// http://plinn.org
+// Licence GPL
+
+var CKEDITOR   = window.dialogArguments.CKEDITOR;
+var editor             = window.dialogArguments.editor;
+var pluginPath         = window.dialogArguments.pluginPath;
+
+window.onload = function() {
+       var mainFrame = window.frames['main'];
+       mainFrame.src = pluginPath + 'dialog/embedded_images.html';
+       mainFrame.location.href = mainFrame.src;
+       
+       var tabsFrame = window.frames['tabs'];
+       tabsFrame.src = pluginPath + 'dialog/plinn_image_tabs.html';
+       tabsFrame.location.href = tabsFrame.src;
+}
+
+function updateOrInsertImage(url, relative) {
+       if (relative)
+               var getSizeUrl = window.location.protocol + '//' + window.location.host + '/' + editor.contentPath + '/' + url + '/getResizedImageSize';
+       else
+               var getSizeUrl = url + '/getResizedImageSize';
+       var req = new XMLHttpRequest();
+       req.open("POST", getSizeUrl, false); // synchrone
+       req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
+       var boxSize = editor.config.imageMaxDefaultDimension + '_' + editor.config.imageMaxDefaultDimension;
+       req.send("asXml:boolean=True&size=" + boxSize);
+       var doc = req.responseXML.documentElement;
+       
+       var width = doc.getElementsByTagName('width')[0].firstChild.nodeValue;
+       var height = doc.getElementsByTagName('height')[0].firstChild.nodeValue;
+       
+       
+       var imgHtml = '<img src="' + url + '/getResizedImage?size=' + boxSize + '" ' +
+                                 'width="' + width + '" ' +
+                                 'height="' + height + '"' +
+                                 '/>';
+       var img = CKEDITOR.dom.element.createFromHtml(imgHtml);
+       editor.insertElement(img);
+       window.close();
+}
\ No newline at end of file