Utilisation d'une css différentes pour autoriser des customisation parfois nécessaires…
[ckeditor.git] / skins / ckeditor / plugins / plinn_image / dialog / plinn_image.js
1 // (c) Benoît PIN 2006-2011
2 // http://plinn.org
3 // Licence GPL
4
5 var CKEDITOR = window.dialogArguments.CKEDITOR;
6 var editor = window.dialogArguments.editor;
7 var pluginPath = window.dialogArguments.pluginPath;
8
9 window.onload = function() {
10 var mainFrame = window.frames['main'];
11 mainFrame.src = pluginPath + 'dialog/embedded_images.html';
12 mainFrame.location.href = mainFrame.src;
13
14 var tabsFrame = window.frames['tabs'];
15 tabsFrame.src = pluginPath + 'dialog/plinn_image_tabs.html';
16 tabsFrame.location.href = tabsFrame.src;
17 }
18
19 function updateOrInsertImage(url, relative) {
20 if (relative)
21 var getSizeUrl = window.location.protocol + '//' + window.location.host + '/' + editor.contentPath + '/' + url + '/getResizedImageSize';
22 else
23 var getSizeUrl = url + '/getResizedImageSize';
24 var req = new XMLHttpRequest();
25 req.open("POST", getSizeUrl, false); // synchrone
26 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
27 var boxSize = editor.config.imageMaxDefaultDimension + '_' + editor.config.imageMaxDefaultDimension;
28 req.send("asXml:boolean=True&size=" + boxSize);
29 var doc = req.responseXML.documentElement;
30
31 var width = doc.getElementsByTagName('width')[0].firstChild.nodeValue;
32 var height = doc.getElementsByTagName('height')[0].firstChild.nodeValue;
33
34
35 var imgHtml = '<img src="' + url + '/getResizedImage?size=' + boxSize + '" ' +
36 'width="' + width + '" ' +
37 'height="' + height + '"' +
38 '/>';
39 var img = CKEDITOR.dom.element.createFromHtml(imgHtml);
40 editor.insertElement(img);
41 window.close();
42 }