/[drupal]/contributions/modules/fckeditor/fckeditor.utils.js
ViewVC logotype

Contents of /contributions/modules/fckeditor/fckeditor.utils.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download) (as text)
Tue Feb 12 18:58:53 2008 UTC (21 months, 1 week ago) by wwalc
Branch: MAIN
CVS Tags: DRUPAL-6--1-1-BETA2, HEAD
Changes since 1.3: +4 -4 lines
File MIME type: text/javascript
added missing files, removed info about ImgAssist
1 // $Id: fckeditor.utils.js,v 1.3 2008/02/12 17:54:21 wwalc Exp $
2 var fckIsRunning = new Array;
3 var fckIsLaunching = new Array;
4 var fckLaunchedTextareaId = new Array;
5 var fckLaunchedJsId = new Array;
6 var fckFirstrun = new Array;
7 var fckIsIE = ( /*@cc_on!@*/false ) ? true : false ;
8
9 function Toggle(js_id, textareaID, textTextarea, TextRTE)
10 {
11 if (!fckIsRunning[js_id])
12 {
13 if (!fckIsLaunching[js_id])
14 {
15 fckIsLaunching[js_id] = true;
16 eval(js_id + '.ReplaceTextarea();');
17 }
18 setTimeout("Toggle('" + js_id + "','" + textareaID + "','" + textTextarea + "','" + TextRTE + "');",1000);
19 return ;
20 }
21
22 var oEditor ;
23 if ( typeof( FCKeditorAPI ) != 'undefined' )
24 oEditor = FCKeditorAPI.GetInstance( js_id );
25
26 // Get the _Textarea and _FCKeditor DIVs.
27 var eTextarea = document.getElementById( textareaID );
28 var eFCKeditor = document.getElementById( js_id );
29 var eFCKeditorDiv = document.getElementById('fck_' + js_id);
30 var text;
31
32 // If the _Textarea DIV is visible, switch to FCKeditor.
33 if ( eTextarea.style.display != 'none' )
34 {
35 document.getElementById('switch_' + js_id).innerHTML = textTextarea;
36
37 // Switch the DIVs display.
38 eFCKeditorDiv.style.display = '';
39
40 text = eTextarea.value;
41 if ($('input[@class=teaser-button]').attr('value') == Drupal.t('Join summary')) {
42 var val = $('#edit-teaser-js').val();
43 if (val && val.length) {
44 text = val + '<!--break-->' + text;
45 }
46 }
47 if ( text.length ) {
48 oEditor.SetHTML( text, false);
49 }
50 eTextarea.style.display = 'none';
51
52 // This is a hack for Gecko 1.0.x ... it stops editing when the editor is hidden.
53 if (oEditor && !document.all)
54 {
55 if (oEditor.EditMode == FCK_EDITMODE_WYSIWYG)
56 oEditor.MakeEditable() ;
57 }
58 $('div[@class=teaser-button-wrapper]').hide();
59 $('#edit-teaser-js').parent().hide();
60 $('#edit-teaser-include').parent().show();
61 }
62 else
63 {
64 if (fckFirstrun[js_id]) {
65 fckFirstrun[js_id] = false;
66 }
67 document.getElementById('switch_' + js_id).innerHTML = TextRTE;
68
69 var text = oEditor.GetHTML();
70 var t = text.indexOf('<!--break-->');
71 if (t != -1) {
72 $('#edit-teaser-js').val(text.slice(0,t));
73 eTextarea.value = text.slice(t+12);
74 $('#edit-teaser-js').parent().show();
75 $('#edit-teaser-js').attr('disabled', '');
76 if ($('input[@class=teaser-button]').attr('value') != Drupal.t('Join summary')) {
77 try {$('input[@class=teaser-button]').click();} catch(e) {$('input[@class=teaser-button]').val(Drupal.t('Join summary'));}
78 }
79 }
80 else {
81 $('#edit-teaser-js').attr('disabled', 'disabled');
82 if ($('input[@class=teaser-button]').attr('value') != Drupal.t('Split summary at cursor')) {
83 try {$('input[@class=teaser-button]').click();} catch(e) {$('input[@class=teaser-button]').val(Drupal.t('Split summary at cursor'));}
84 }
85 // Set the textarea value to the editor value.
86 eTextarea.value = text;
87 }
88
89 // Switch the DIVs display.
90 eTextarea.style.display = '';
91 eFCKeditorDiv.style.display = 'none';
92 $('div[@class=teaser-button-wrapper]').show();
93 }
94 }
95
96 function CreateToggle(elId, jsId, fckeditorOn)
97 {
98 var ta = document.getElementById(elId);
99 var ta2 = document.getElementById('fck_' + jsId);
100
101 ta2.value = ta.value;
102 ta.parentNode.insertBefore(ta2, ta);
103 if (fckeditorOn)
104 ta.style.display = 'none';
105 else
106 ta2.style.display = 'none';
107 }
108
109 // The FCKeditor_OnComplete function is a special function called everytime an
110 // editor instance is completely loaded and available for API interactions.
111 function FCKeditor_OnComplete( editorInstance )
112 {
113 fckIsRunning[editorInstance.Name] = true ;
114 fckLaunchedTextareaId.push(editorInstance.Config['TextareaID']) ;
115 fckLaunchedJsId.push(editorInstance.Name) ;
116 fckFirstrun[editorInstance.Name] = true;
117
118 // Enable the switch button. It is disabled at startup, waiting the editor to be loaded.
119 document.getElementById('switch_' + editorInstance.Name).style.display = '' ;
120
121 // If the textarea isn't visible update the content from the editor.
122 editorInstance.LinkedField.form.onsubmit = function() {
123 for( var i = 0 ; i < fckLaunchedJsId.length ; i++ ) {
124 if ( document.getElementById( fckLaunchedTextareaId[i] ).style.display == 'none' )
125 {
126 var text = FCKeditorAPI.GetInstance( fckLaunchedJsId[i] ).GetXHTML();
127 var t = text.indexOf('<!--break-->');
128 if (t != -1) {
129 $('#edit-teaser-js').val(text.slice(0,t));
130 document.getElementById( fckLaunchedTextareaId[i] ).value = text.slice(t+12);
131 }
132 else {
133 $('#edit-teaser-js').val('');
134 $('#edit-teaser-js').attr('disabled', 'disabled');
135 document.getElementById( fckLaunchedTextareaId[i] ).value = text;
136 if ($('input[@class=teaser-button]').attr('value') == Drupal.t('Join summary')) {
137 try {$('input[@class=teaser-button]').click();} catch(e) {$('input[@class=teaser-button]').val(Drupal.t('Join summary'));}
138 }
139 }
140 }
141 }
142 }
143
144 $('#edit-teaser-js').attr('disabled', '');
145 $('div[@class=teaser-button-wrapper]').hide();
146 $('#edit-teaser-js').parent().hide();
147 $('#edit-teaser-include').parent().show();
148
149 //Img_Assist integration
150 //IntegrateWithImgAssist();
151
152 // -- some hacks for IE
153 var oldCheckAndRemovePaddingNode = editorInstance.EditorWindow.parent.FCKDomTools.CheckAndRemovePaddingNode ;
154
155 editorInstance.EditorWindow.parent.FCKDomTools.CheckAndRemovePaddingNode = function( doc, tagName, dontRemove )
156 {
157 try
158 {
159 oldCheckAndRemovePaddingNode( doc, tagName, dontRemove ) ;
160 }
161 catch(e)
162 {}
163 }
164
165 editorInstance.Events.FireEvent = function( eventName, params )
166 {
167 try
168 {
169 return editorInstance.EditorWindow.parent.FCKEvents.prototype.FireEvent.call( this, eventName, params ) ;
170 }
171 catch(e)
172 {}
173 }
174 // -- some hacks for IE
175 }
176 /*
177 function IntegrateWithImgAssist()
178 {
179 var link = document.getElementsByTagName("a");
180 for (var i = 0; i < link.length; i++) {
181 cl = link[i].getAttribute("class");
182 if ( cl == "img_assist-link") {
183 link[i].href = link[i].href.replace("/load/textarea", "/load/fckeditor");
184 }
185 }
186 }*/

  ViewVC Help
Powered by ViewVC 1.1.2