Insertion des images attachées migrée.
authorBenoît Pin <pin@cri.ensmp.fr>
Fri, 19 Aug 2011 08:02:40 +0000 (10:02 +0200)
committerBenoît Pin <pin@cri.ensmp.fr>
Fri, 19 Aug 2011 08:02:40 +0000 (10:02 +0200)
skins/ckeditor/config.js
skins/ckeditor/plugins/plinn_image/dialog/embedded_images.html.pt
skins/ckeditor/plugins/plinn_image/dialog/plinn_image.js
skins/ckeditor/plugins/plinn_image/plugin.js

index 322d3f2..b9eb18c 100644 (file)
@@ -33,5 +33,6 @@ CKEDITOR.editorConfig = function( config )
        config.filebrowserWindowHeight = 600;\r
        config.filebrowserWindowWidth = 801;\r
        config.attachmentBrowserConnectorUrl = CKEDITOR.basePath + 'plugins/plinn_image/connectors/plinn/connector';\r
+       config.imageMaxDefaultDimension = 500 ; // image inserted will be cropped at this size.\r
        config.extraPlugins = 'plinn_image';\r
 };
\ No newline at end of file
index 99e57aa..0034dd1 100644 (file)
            switch (target.tagName) {
              case 'IMG' :
                    var a = target.parentNode;
-                   window.parent.updateOrInsertImage(a.getAttribute('href', 2));
+                   window.parent.updateOrInsertImage(a.getAttribute('href', 2), true);
                    break;
-                 case 'A' :
-                   if (target.name == 'suppr')
-                     var a = target.parentNode.parentNode.getElementsByTagName('a')[0];
-                     var href = a.getAttribute('href', 2);
-                     var imgPath = window.parent.editor.FCKConfig.EditorPath + href;
-                     
-                     var req = new XMLHttpRequest();
-                       req.open("POST", connUrl, false); // synchrone
-                       req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
-                       req.send("command=rm&path="+escape(imgPath));
-                 var doc = req.responseXML.documentElement;
-                 if (doc.tagName == 'done') {
-                   var slide = target.parentNode.parentNode;
-                   slide.parentNode.removeChild(slide);
-                   }
+//               case 'A' :
+//                 if (target.name == 'suppr')
+//                   var a = target.parentNode.parentNode.getElementsByTagName('a')[0];
+//                   var href = a.getAttribute('href', 2);
+//                   var imgPath = window.parent.editor.FCKConfig.EditorPath + href;
+//                   
+//                   var req = new XMLHttpRequest();
+//                             req.open("POST", connUrl, false); // synchrone
+//                             req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
+//                             req.send("command=rm&path="+escape(imgPath));
+//                       var doc = req.responseXML.documentElement;
+//                       if (doc.tagName == 'done') {
+//                         var slide = target.parentNode.parentNode;
+//                         slide.parentNode.removeChild(slide);
+//                 }
                }
-                 
                }
                
                addListener(window, 'load', _initBrowser);
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
index df81531..022af4c 100644 (file)
@@ -35,6 +35,7 @@ function openPlinnImageDialog(path, editor) {
        win.dialogArguments = new Object();
        win.dialogArguments.editor = editor;
        win.dialogArguments.pluginPath = path;
+       win.dialogArguments.CKEDITOR = CKEDITOR;
 }