|
1 <html xmlns="http://www.w3.org/1999/xhtml"> |
|
2 <head> |
|
3 <title>FCKeditor</title> |
|
4 <!-- $id$ --> |
|
5 <script type="text/javascript"> |
|
6 document.write('<scr' + 'ipt src="' + window.opener['Drupal'].settings.basePath + 'misc/jquery.js"></scr' + 'ipt>'); |
|
7 // #### URLParams: holds all URL passed parameters (like ?Param1=Value1&Param2=Value2) |
|
8 var FCKURLParams = new Object() ; |
|
9 |
|
10 var aParams = document.location.search.substr(1).split('&') ; |
|
11 for ( var i = 0 ; i < aParams.length ; i++ ) |
|
12 { |
|
13 var aParam = aParams[i].split('=') ; |
|
14 var sParamName = aParam[0] ; |
|
15 var sParamValue = aParam[1] ; |
|
16 |
|
17 FCKURLParams[ sParamName ] = sParamValue ; |
|
18 } |
|
19 |
|
20 // It is preferable to have the oFCKeditor object defined in the opener window, |
|
21 // so all the configurations will be there. In this way the popup doesn't need |
|
22 // to take care of the configurations "clonning". |
|
23 var oFCKeditor = window.opener[ FCKURLParams[ 'var' ] ] ; |
|
24 oFCKeditor.Width = '100%' ; |
|
25 oFCKeditor.Height = '100%' ; |
|
26 |
|
27 if (FCKURLParams[ 'teaser' ]) { |
|
28 var text = window.opener.document.getElementById( FCKURLParams[ 'teaser' ] ).value ; |
|
29 if (text.length > 0) { |
|
30 text = text + '\n<!--break-->\n'; |
|
31 } |
|
32 oFCKeditor.Value = text + window.opener.document.getElementById( FCKURLParams[ 'el' ] ).value ; |
|
33 } else { |
|
34 oFCKeditor.Value = window.opener.document.getElementById( FCKURLParams[ 'el' ] ).value ; |
|
35 } |
|
36 |
|
37 function FCKeditor_trim(text) { |
|
38 return text.replace(/^\s+/g, '').replace(/\s+$/g, ''); |
|
39 } |
|
40 |
|
41 function Ok() |
|
42 { |
|
43 var oEditor = FCKeditorAPI.GetInstance( oFCKeditor.InstanceName ) ; |
|
44 |
|
45 if (FCKURLParams[ 'teaser' ]) { |
|
46 var text = oEditor.GetData( true ); |
|
47 var t = text.indexOf('<!--break-->'); |
|
48 var textarea = window.opener.document.getElementById( FCKURLParams[ 'el' ] ); |
|
49 var teaser = window.opener.document.getElementById( FCKURLParams[ 'teaser' ] ); |
|
50 console.debug(teaser.parentNode.style.display); |
|
51 // for now, do nothing when the body field is in joined mode |
|
52 if(t != -1 && teaser.parentNode.style.display != 'none') { |
|
53 teaser.value = FCKeditor_trim(text.slice(0,t)); |
|
54 textarea.value = FCKeditor_trim(text.slice(t+12)); |
|
55 } else { |
|
56 teaser.value = ''; |
|
57 textarea.value = text; |
|
58 } |
|
59 } else { |
|
60 window.opener.document.getElementById( FCKURLParams[ 'el' ] ).value = oEditor.GetData( true ) ; // "true" means you want it formatted. |
|
61 } |
|
62 |
|
63 window.opener.focus() ; |
|
64 window.close() ; |
|
65 } |
|
66 |
|
67 function FCKeditor_OnComplete( editorInstance ) |
|
68 { |
|
69 oEditor = editorInstance; |
|
70 var textarea = window.opener.document.getElementById( FCKURLParams[ 'el' ] ); |
|
71 if ($(textarea).attr('class').indexOf("filterxss2") != -1) { |
|
72 $.post(window.opener['Drupal'].settings.basePath + 'index.php?q=fckeditor/xss', { |
|
73 text: oFCKeditor.Value, |
|
74 'filters[]': window.opener['Drupal'].settings.fckeditor_filters[FCKURLParams[ 'var' ]] |
|
75 }, |
|
76 function(text) { |
|
77 oEditor.SetData(text); |
|
78 } |
|
79 ); |
|
80 } |
|
81 } |
|
82 |
|
83 function Cancel() |
|
84 { |
|
85 var oEditor = FCKeditorAPI.GetInstance( oFCKeditor.InstanceName ) ; |
|
86 |
|
87 if ( oEditor.IsDirty() ) |
|
88 { |
|
89 if ( !confirm( 'Are you sure you want to cancel? Your changes will be lost.' ) ) |
|
90 return ; |
|
91 } |
|
92 |
|
93 window.close() ; |
|
94 } |
|
95 |
|
96 </script> |
|
97 </head> |
|
98 <body> |
|
99 <table width="100%" height="100%"> |
|
100 <tr> |
|
101 <td height="100%"> |
|
102 <script type="text/javascript"> |
|
103 |
|
104 //image_assist integration |
|
105 IaObj = window.opener.document.getElementById( 'img_assist-link-' + FCKURLParams[ 'el' ] ); |
|
106 if(IaObj){ |
|
107 IaObj.href = IaObj.href.replace("/load/textarea", "/load/fckeditor"); |
|
108 document.write( '<a className="img_assist-link" href='+ IaObj.href +' id="img_assist-link-' + FCKURLParams[ 'el' ] +'" style="display:none" /></a>' ) ; |
|
109 } |
|
110 |
|
111 var textarea = window.opener.document.getElementById( FCKURLParams[ 'el' ] ); |
|
112 if ($(textarea).attr('class').indexOf("filterxss2") != -1) { |
|
113 var initialHTML = ''; |
|
114 } |
|
115 else { |
|
116 var initialHTML = oFCKeditor.Value; |
|
117 } |
|
118 |
|
119 // For now, it is not possible to retrieve the output HTML, so we must do it by |
|
120 // hand. Future implementations of FCKeditor could bring a |
|
121 // oFCKeditor.CreateHtml() function. |
|
122 document.write( '<input type="hidden" id="' + oFCKeditor.InstanceName + '" name="' + oFCKeditor.InstanceName + '" value="' + oFCKeditor._HTMLEncode( initialHTML ) + '" style="display:none" />' ) ; |
|
123 document.write( oFCKeditor._GetConfigHtml() ) ; |
|
124 document.write( oFCKeditor._GetIFrameHtml() ) ; |
|
125 |
|
126 </script> |
|
127 </td> |
|
128 </tr> |
|
129 <tr> |
|
130 <td> |
|
131 <input type="button" value="Ok" onclick="Ok();" style="width:120px" /> |
|
132 <input type="button" value="Cancel" onclick="Cancel();" /> |
|
133 </td> |
|
134 </tr> |
|
135 </table> |
|
136 </body> |
|
137 </html> |