1
/* vim: set expandtab tabstop=4 shiftwidth=4: */
2
// +----------------------------------------------------------------------+
4
// +----------------------------------------------------------------------+
5
// | Copyright (c) 2000-2004 WS Interactive |
6
// | Copyright (c) 2000-2004 Antoine Pouch |
7
// +----------------------------------------------------------------------+
8
// | This source file is subject to version 2.0 of the GPL license, |
9
// | or (at your discretion) to version 3.0 of the PHP license. |
10
// | The first is bundled with this package in the file LICENSE-GPL, and |
11
// | is available at through the world-wide-web at |
12
// | http://www.gnu.org/copyleft/gpl.html. |
13
// | The later is bundled with this package in the file LICENSE-PHP, and |
14
// | is available at through the world-wide-web at |
15
// | http://www.php.net/license/3_0.txt. |
16
// +----------------------------------------------------------------------+
17
// | Author: Frederico Caldeira Knabben (fredck@fckeditor.net) |
18
// | Author: S�bastien Pauchet <sebastien.pauchet@ws-interactive.fr> |
19
// +----------------------------------------------------------------------+
21
// $Id: fckpolymod.js,v 1.1.1.1 2008/11/26 17:12:14 sebastien Exp $
24
* Javascript plugin for FCKeditor
25
* Create Automne medias items insertions
29
* @author Frederico Caldeira Knabben (fredck@fckeditor.net)
30
* @author S�bastien Pauchet <sebastien.pauchet@ws-interactive.fr>
33
var oEditor = window.parent.InnerDialogLoaded() ;
34
var FCK = oEditor.FCK ;
35
var FCKLang = oEditor.FCKLang ;
37
// oSpan: The selected span in the editor if any.
39
// oID: The span id in the editor if any
41
// oContent: The selected text content in the editor if any
45
window.onload = function()
47
// Translate the dialog box texts.
48
oEditor.FCKLanguageManager.TranslatePage(document) ;
49
// Load the selected span informations (if any).
51
//load iframe with span infos
52
GetE('plugin').src = GetE('iframeURL').value + '?id=' + oID + '&content=' + escape(oContent);
53
// Show the initial dialog content.
54
GetE('divInfo').style.display = '' ;
55
// Activate the "OK" button.
56
window.parent.SetOkButton( true ) ;
58
//load current selected span if any and all span infos
59
function LoadSelection()
61
oSpan = FCK.Selection.MoveToAncestorNode( 'SPAN' ) ;
62
if ( oSpan && oSpan.className == 'polymod'){
63
FCK.Selection.SelectNode( oSpan ) ;
65
//oContent = oSpan.textContent;
66
if (typeof oSpan.innerText != 'undefined') { //IE
67
oContent = oSpan.innerText;
68
} else if (typeof oSpan.textContent != 'undefined') { //GECKO
69
oContent = oSpan.textContent;
72
if (FCK.EditorWindow.getSelection) { //GECKO
73
oContent = FCK.EditorWindow.getSelection();
75
var oRange = FCK.EditorDocument.selection.createRange() ;
76
oContent = oRange.text;
81
//The OK button was hit.
84
if (GetE('codeToPaste').value == '') {
85
alert(FCKLang['DlgPolymodNoPage']);
87
var codeToPaste = htmlDecode(GetE('codeToPaste').value);
88
//remove old selection code
89
FCK.Selection.Delete();
90
//then paste the new one
91
FCK.InsertHtml(codeToPaste);
92
//try to exec JS if any
93
/*var re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig;
94
while(match = re.exec(codeToPaste)){
95
if(match[2] && match[2].length > 0){
100
window.parent.Cancel() ;
103
function htmlDecode(value){
104
return !value ? value : String(value).replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, '"');