Insertion des images attachées migrée.
[ckeditor.git] / skins / ckeditor / plugins / plinn_image / dialog / plinn_image.js
index 7962d13..bb4883c 100644 (file)
@@ -1,14 +1,10 @@
-// (c) Benoît PIN 2006-2007
+// (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;
-//var FCK                      = editor.FCK ;
-//var FCKLang          = editor.FCKLang ;
-//var FCKConfig        = editor.FCKConfig ;
-//var FCKPlugins       = editor.FCKPlugins;
-//var FCKDebug = editor.FCKDebug ;
 
 window.onload = function() {
        var mainFrame = window.frames['main'];
@@ -20,12 +16,15 @@ window.onload = function() {
        tabsFrame.location.href = tabsFrame.src;
 }
 
-function updateOrInsertImage(url) {
-       var getSizeUrl = url + '/getResizedImageSize';
+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 = FCKConfig.ImageMaxDefaultDimension + '_' + FCKConfig.ImageMaxDefaultDimension;
+       var boxSize = editor.config.imageMaxDefaultDimension + '_' + editor.config.imageMaxDefaultDimension;
        req.send("asXml:boolean=True&size=" + boxSize);
        var doc = req.responseXML.documentElement;
        
@@ -33,11 +32,11 @@ function updateOrInsertImage(url) {
        var height = doc.getElementsByTagName('height')[0].firstChild.nodeValue;
        
        
-       var img = FCK.CreateElement('img');
-       img.src = url + '/getResizedImage?size=' + boxSize;
-       img.width = width;
-       img.height = height;
-       
-       //FCK.InsertElement(img);
+       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