1 var InitializedTinyMCEInstances
= {}
3 function TinyMCEConfig(id
) {
5 this.widget_config
= eval('(' + document
.getElementById (this.id
).title
+ ')');
8 this.init = function() {
10 // Check if already initialized
11 if (typeof (InitializedTinyMCEInstances
[this.id
]) != 'undefined') {
14 InitializedTinyMCEInstances
[this.id
] = 1;
17 var format
= document
.getElementById(this.id
+ '_text_format');
18 if (format
&& format
.tagName
.toLowerCase() == 'input' && format
.value
.indexOf('html') == -1) {
22 // Set textformat to html and hide selector
23 var node
= tinymce
.DOM
.get(this.id
);
24 node
= tinymce
.DOM
.getParent(node
, '.ArchetypesRichWidget,.richTextWidget');
26 node
= tinymce
.DOM
.select('div.fieldTextFormat', node
);
27 if (node
.length
> 0) {
28 tinymce
.DOM
.select('select', node
[0])[0].value
= 'text/html';
29 tinymce
.DOM
.setStyle(node
[0], 'display', 'none');
33 for (var i
= 0; i
< this.widget_config
.customplugins
.length
; i
++) {
34 if (this.widget_config
.customplugins
[i
].indexOf('|') != -1) {
35 e
= this.widget_config
.customplugins
[i
].split('|');
36 tinymce
.PluginManager
.load(e
[0], this.getPortalUrl() + e
[1]);
42 strict_loading_mode
: true,
44 language
: this.getLanguage(),
46 inlinepopups_skin
: "plonepopup",
47 plugins
: this.getPlugins(),
48 // Find out if ieSpell requires gecko spellchecker...
49 gecko_spellcheck
: this.geckoSpellcheckEnabled(),
51 atd_rpc_id
: this.widget_config
.atd_rpc_id
,
52 atd_rpc_url
: this.widget_config
.atd_rpc_url
,
53 atd_show_types
: this.widget_config
.atd_show_types
,
54 atd_ignore_strings
: this.widget_config
.atd_ignore_strings
,
56 labels
: this.widget_config
.labels
,
57 theme_advanced_styles
: this.getStyles(),
58 theme_advanced_buttons1
: this.getToolbar(0),
59 theme_advanced_buttons2
: this.getToolbar(1),
60 theme_advanced_buttons3
: this.getToolbar(2),
61 theme_advanced_buttons4
: this.getToolbar(3),
62 theme_advanced_toolbar_location
: this.getToolbarLocation(),
63 theme_advanced_toolbar_align
: "left",
64 theme_advanced_path_location
: this.getPathLocation(),
65 theme_advanced_path
: false,
66 theme_advanced_resizing
: this.getResizing(),
67 theme_advanced_resizing_use_cookie
: this.getResizingUseCookie(),
68 theme_advanced_resize_horizontal
: this.getResizeHorizontal(),
69 theme_advanced_source_editor_width
: this.getEditorWidth(),
70 theme_advanced_source_editor_height
: this.getEditorHeight(),
72 table_styles
: this.getTableStyles(),
73 table_firstline_th
: true,
74 directionality
: this.getDirectionality(),
75 entity_encoding
: this.getEntityEncoding(),
76 content_css
: this.getContentCSS(),
77 body_class
: "documentContent",
79 document_base_url
: this.getBase(),
80 document_url
: this.getDocumentUrl(),
81 portal_url
: this.getPortalUrl(),
82 navigation_root_url
: this.getNavigationRootUrl(),
83 livesearch
: this.getLivesearch(),
84 valid_elements
: this.getValidElements(),
85 valid_inline_styles
: this.getValidInlineStyles(),
86 link_using_uids
: this.getLinkUsingUids(),
87 allow_captioned_images
: this.getAllowCaptionedImages(),
88 rooted
: this.getRooted(),
89 force_span_wrappers
: true,
90 fix_list_elements
: false
93 window
.tinyMCE
.init(init_dict
);
96 this.getButtonWidth = function(b
) {
104 case 'tablecontrols':
110 this.getTableStyles = function() {
111 return this.widget_config
.table_styles
.join (";");
114 this.getToolbar = function(i
) {
115 return this.toolbars
[i
];
118 this.initToolbars = function() {
119 var t
= [[],[],[],[]];
124 for (var i
= 0; i
< this.widget_config
.buttons
.length
; i
++) {
125 button_width
= this.getButtonWidth(this.widget_config
.buttons
[i
]);
126 if (cur_x
+ button_width
> this.widget_config
.toolbar_width
) {
127 cur_x
= button_width
;
130 cur_x
+= button_width
;
132 if (cur_toolbar
<= 3) {
133 t
[cur_toolbar
].push (this.widget_config
.buttons
[i
]);
137 this.toolbars
= [t
[0].join(','), t
[1].join(','), t
[2].join(','), t
[3].join(',')];
140 this.getStyles = function() {
141 var h
= {'Text': [], 'Selection': [], 'Tables': [], 'Lists': [], 'Print': []};
145 h
['Text'].push('{ title: "Text", tag: "", className: "-", type: "Text" }');
146 h
['Selection'].push('{ title: "Selection", tag: "", className: "-", type: "Selection" }');
147 h
['Tables'].push('{ title: "Tables", tag: "table", className: "-", type: "Tables" }');
148 h
['Lists'].push('{ title: "Lists", tag: "ul", className: "-", type: "Lists" }');
149 h
['Lists'].push('{ title: "Lists", tag: "ol", className: "-", type: "Lists" }');
150 h
['Lists'].push('{ title: "Lists", tag: "dl", className: "-", type: "Lists" }');
151 h
['Print'].push('{ title: "Print", tag: "", className: "-", type: "Print" }');
154 h
['Text'].push('{ title: "' + this.widget_config
.labels
['label_paragraph'] + '", tag: "p", className: "", type: "Text" }');
155 h
['Selection'].push('{ title: "' + this.widget_config
.labels
['label_styles'] + '", tag: "", className: "", type: "Selection" }');
156 h
['Tables'].push('{ title: "'+this.widget_config
.labels
['label_plain_cell'] +'", tag: "td", className: "", type: "Tables" }');
157 h
['Lists'].push('{ title: "'+this.widget_config
.labels
['label_lists'] +'", tag: "dl", className: "", type: "Lists" }');
159 for (var i
= 0; i
< this.widget_config
.styles
.length
; i
++) {
160 e
= this.widget_config
.styles
[i
].split('|');
164 switch (e
[1].toLowerCase()) {
168 styletype
= "Selection";
174 styletype
= "Tables";
188 if (e
[2] == "pageBreak") {
191 h
[styletype
].push('{ title: "' + e
[0] + '", tag: "' + e
[1] + '", className: "' + e
[2] + '", type: "' + styletype
+ '" }');
194 // Add items to array
196 if (h
['Text'].length
> 1) {
197 for (var i
= 0; i
< h
['Text'].length
; i
++) {
198 a
.push(h
['Text'][i
]);
201 if (h
['Selection'].length
> 1) {
202 for (var i
= 0; i
< h
['Selection'].length
; i
++) {
203 a
.push(h
['Selection'][i
]);
206 if (h
['Tables'].length
> 1) {
207 for (var i
= 0; i
< h
['Tables'].length
; i
++) {
208 a
.push(h
['Tables'][i
]);
211 if (h
['Lists'].length
> 1) {
212 for (var i
= 0; i
< h
['Lists'].length
; i
++) {
213 a
.push(h
['Lists'][i
]);
216 if (h
['Print'].length
> 1) {
217 for (var i
= 0; i
< h
['Print'].length
; i
++) {
218 a
.push(h
['Print'][i
]);
221 return '[' + a
.join(',') + ']';
224 this.getValidInlineStyles = function() {
225 return this.widget_config
.valid_inline_styles
.join (',');
228 this.getValidElements = function() {
231 for (var valid_element
in this.widget_config
.valid_elements
) {
232 var s
= valid_element
;
233 if (this.widget_config
.valid_elements
[valid_element
].length
> 0) {
234 s
+= '[' + this.widget_config
.valid_elements
[valid_element
].join ('|') + ']';
241 this.getDocumentUrl = function() {
242 return this.widget_config
.document_url
;
245 this.getBase = function() {
246 return this.widget_config
.parent
;
249 this.getToolbarLocation = function () {
250 return this.widget_config
.toolbar_location
;
253 this.getPathLocation = function () {
254 return this.widget_config
.path_location
;
257 this.getResizing = function () {
258 return this.widget_config
.resizing
;
261 this.getResizingUseCookie = function () {
262 return this.widget_config
.resizing_use_cookie
;
265 this.getResizeHorizontal = function () {
266 return this.widget_config
.resize_horizontal
;
269 this.getEditorWidth = function () {
270 return this.widget_config
.editor_width
;
273 this.getEditorHeight = function () {
274 return this.widget_config
.editor_height
;
277 this.getDirectionality = function () {
278 return this.widget_config
.directionality
;
281 this.getEntityEncoding = function () {
282 return this.widget_config
.entity_encoding
;
285 this.getContentCSS = function () {
286 return this.widget_config
.content_css
;
289 this.getLanguage = function () {
290 return this.widget_config
.language
;
293 this.getLinkUsingUids = function () {
294 return this.widget_config
.link_using_uids
;
297 this.getAllowCaptionedImages = function () {
298 return this.widget_config
.allow_captioned_images
;
301 this.getRooted = function () {
302 return this.widget_config
.rooted
;
305 this.getPortalUrl = function () {
306 return this.widget_config
.portal_url
;
309 this.getNavigationRootUrl = function () {
310 return this.widget_config
.navigation_root_url
;
313 this.getLivesearch = function () {
314 return this.widget_config
.livesearch
;
317 this.getSpellchecker = function () {
318 var sp
= this.widget_config
.libraries_spellchecker_choice
;
319 if ((sp
!= '') && (sp
!= 'browser')) {
327 this.geckoSpellcheckEnabled = function () {
328 if (this.widget_config
.libraries_spellchecker_choice
== 'browser')
334 this.getPlugins = function () {
335 var plugins
= "safari,pagebreak,table,save,advhr,emotions,insertdatetime,preview,media,searchreplace,print,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,inlinepopups,plonestyle,tabfocus,definitionlist,ploneinlinestyles";
337 var sp
= this.getSpellchecker()
341 for (var i
= 0; i
< this.widget_config
.customplugins
.length
; i
++) {
342 if (this.widget_config
.customplugins
[i
].indexOf('|') == -1) {
343 plugins
+= ',' + this.widget_config
.customplugins
[i
];
345 plugins
+= ',' + this.widget_config
.customplugins
[i
].split('|')[0];
348 if (this.widget_config
.contextmenu
) {
349 plugins
+= ',contextmenu';
351 if (this.widget_config
.autoresize
) {
352 plugins
+= ',autoresize';
358 if (typeof(kukit
) != "undefined") {
359 kukit
.actionsGlobalRegistry
.register("init-tinymce", function(oper
) {
360 var config
= new TinyMCEConfig(oper
.node
.id
);
361 delete InitializedTinyMCEInstances
[oper
.node
.id
]
365 kukit
.actionsGlobalRegistry
.register("save-tinymce", function(oper
) {
366 if(tinymce
.EditorManager
!= undefined && tinymce
.EditorManager
.activeEditor
!= null){
367 tinymce
.EditorManager
.activeEditor
.save();